mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
build scripts: allow removing version numbers from JAR names
When a library is converted to repository library, its version is included into its JAR name. So if we convert a library included into bootstrap classpath (names of such libraries are hardcoded in executables) we need to keep the old name to avoid changing executables each time the library is updated. Later we can automatically compose bootstrap classpath and this won't be needed.
This commit is contained in:
+1
-1
@@ -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
|
||||
|
||||
+20
-4
@@ -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. <strong>It may be used to temporary
|
||||
* keep names of JARs included into bootstrap classpath only.</strong>
|
||||
*/
|
||||
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. <strong>It may be used to temporary
|
||||
* * keep names of JARs included into bootstrap classpath only.</strong>
|
||||
**/
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import java.util.function.Consumer
|
||||
*/
|
||||
class PlatformLayout extends BaseLayout {
|
||||
List<String> excludedProjectLibraries = []
|
||||
final List<String> projectLibrariesWithRemovedVersionFromJarNames = []
|
||||
|
||||
static PlatformLayout platform(Consumer<PlatformLayout> 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. <strong>Do not use this method for anything else.</strong> 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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user