diff --git a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/DistributionJARsBuilder.groovy b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/DistributionJARsBuilder.groovy
index e51bfdd8f144..e0c5cc12beff 100644
--- a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/DistributionJARsBuilder.groovy
+++ b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/DistributionJARsBuilder.groovy
@@ -406,7 +406,7 @@ class DistributionJARsBuilder {
}
}
layout.includedProjectLibraries.each {
- projectLibrary(it)
+ projectLibrary(it, layout instanceof PlatformLayout && layout.projectLibrariesWithRemovedVersionFromJarNames.contains(it))
}
layout.includedArtifacts.entrySet().each {
def artifactName = it.key
diff --git a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/LayoutBuilder.groovy b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/LayoutBuilder.groovy
index 35eabbcf1123..aa7b0b3fbf2d 100644
--- a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/LayoutBuilder.groovy
+++ b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/LayoutBuilder.groovy
@@ -26,6 +26,8 @@ import org.jetbrains.jps.model.artifact.JpsArtifactService
import org.jetbrains.jps.model.library.JpsLibrary
import org.jetbrains.jps.model.library.JpsOrderRootType
import org.jetbrains.jps.model.module.JpsModule
+
+import java.util.regex.Pattern
/**
* Use this class to pack output of modules and libraries into JARs and lay out them by directories. It delegates the actual work to
* {@link jetbrains.antlayout.tasks.LayoutTask}.
@@ -157,13 +159,15 @@ class LayoutBuilder {
/**
* Include JARs added as classes roots of project library {@code libraryName} to the current place in the layout
+ * @param removeVersionFromJarName if {@code true} versions will be removed from the JAR names. It may be used to temporary
+ * keep names of JARs included into bootstrap classpath only.
*/
- def projectLibrary(String libraryName) {
+ def projectLibrary(String libraryName, boolean removeVersionFromJarName = false) {
def library = project.libraryCollection.findLibrary(libraryName)
if (library == null) {
throw new IllegalArgumentException("Cannot find library $libraryName in the project")
}
- jpsLibrary(library)
+ jpsLibrary(library, removeVersionFromJarName)
}
/**
@@ -195,9 +199,21 @@ class LayoutBuilder {
jpsLibrary(library)
}
- def jpsLibrary(JpsLibrary library) {
+ private static final Pattern JAR_NAME_WITH_VERSION_PATTERN = ~/(.*)-\d+(?:\.\d+)*\.jar*/
+
+ /**
+ * @param removeVersionFromJarName if {@code true} versions will be removed from the JAR names. It may be used to temporary
+ * * keep names of JARs included into bootstrap classpath only.
+ **/
+ def jpsLibrary(JpsLibrary library, boolean removeVersionFromJarName = false) {
library.getFiles(JpsOrderRootType.COMPILED).each {
- ant.fileset(file: it.absolutePath)
+ def matcher = it.name =~ JAR_NAME_WITH_VERSION_PATTERN
+ if (removeVersionFromJarName && matcher.matches()) {
+ ant.renamedFile(filePath: it.absolutePath, newName: matcher.group(1) + ".jar")
+ }
+ else {
+ ant.fileset(file: it.absolutePath)
+ }
}
}
diff --git a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/PlatformLayout.groovy b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/PlatformLayout.groovy
index b5bdeaebc1c9..1b8c5b84a739 100644
--- a/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/PlatformLayout.groovy
+++ b/platform/build-scripts/groovy/org/jetbrains/intellij/build/impl/PlatformLayout.groovy
@@ -32,6 +32,7 @@ import java.util.function.Consumer
*/
class PlatformLayout extends BaseLayout {
List excludedProjectLibraries = []
+ final List projectLibrariesWithRemovedVersionFromJarNames = []
static PlatformLayout platform(Consumer customizer, @DelegatesTo(PlatformLayoutSpec) Closure body = {}) {
def layout = new PlatformLayout()
@@ -61,6 +62,16 @@ class PlatformLayout extends BaseLayout {
layout.excludedProjectLibraries << libraryName
}
+ /**
+ * Remove version numbers from {@code libraryName}'s JAR file names before copying to the product distributions. Currently it's needed
+ * for libraries included into bootstrap classpath of the platform, because their names are hardcoded in startup scripts and it's not
+ * convenient to change them each time the library is updated. Do not use this method for anything else. This method
+ * will be removed when build scripts automatically compose bootstrap classpath.
+ */
+ void removeVersionFromProjectLibraryJarNames(String libraryName) {
+ layout.projectLibrariesWithRemovedVersionFromJarNames << libraryName
+ }
+
/**
* Include all project libraries from dependencies of modules already included into layout to 'lib' directory
*/