Separate jar for java-plugin. Supported different resource jars.

This commit is contained in:
Alexander Podkhalyuzin
2017-11-16 11:22:20 +03:00
parent 0c64f54f52
commit ebce859ec3
11 changed files with 93 additions and 57 deletions
@@ -18,12 +18,6 @@ abstract class BaseIdeaProperties extends ProductProperties {
"debugger-openapi",
"dom-openapi",
"execution-openapi",
"java-analysis-api",
"java-indexing-api",
"java-psi-api",
"jsp-openapi",
"jsp-base-openapi",
"openapi",
"remote-servers-java-api",
"testFramework-java"
]
@@ -34,18 +28,12 @@ abstract class BaseIdeaProperties extends ProductProperties {
"execution-impl",
"external-system-impl",
"idea-ui",
"java-analysis-impl",
"java-indexing-impl",
"java-impl",
"java-psi-impl",
"java-structure-view",
"jsp-spi",
"manifest",
"remote-servers-java-impl",
"testFramework",
"tests_bootstrap",
"ui-designer-core",
"uast-java"
"ui-designer-core"
]
protected static final List<String> BUNDLED_PLUGIN_MODULES = [
"copyright", "properties", "terminal", "editorconfig", "settings-repository", "yaml",
@@ -73,9 +61,30 @@ abstract class BaseIdeaProperties extends ProductProperties {
putAll("javac2.jar", ["javac2", "forms-compiler", "forms_rt", "instrumentation-util", "instrumentation-util-8", "javac-ref-scanner-8"])
productLayout.additionalPlatformJars.putAll("annotations-java8.jar", ["annotations-common", "annotations-java8"])
def JAVA_API_JAR = "java-api.jar"
def JAVA_IMPL_JAR = "java-impl.jar"
productLayout.additionalPlatformJars.putAll(JAVA_API_JAR, [])
productLayout.additionalPlatformJars.putAll(JAVA_IMPL_JAR, [])
productLayout.platformLayoutCustomizer = { PlatformLayout layout ->
layout.customize {
withModule("java-runtime", "idea_rt.jar", false)
def JAVA_RESOURCES_JAR = "java_resources_en.jar"
withModule("java-analysis-api", JAVA_API_JAR, JAVA_RESOURCES_JAR)
withModule("java-indexing-api", JAVA_API_JAR, JAVA_RESOURCES_JAR)
withModule("java-psi-api", JAVA_API_JAR, JAVA_RESOURCES_JAR)
withModule("openapi", JAVA_API_JAR, JAVA_RESOURCES_JAR)
withModule("jsp-base-openapi", JAVA_API_JAR, JAVA_RESOURCES_JAR)
withModule("jsp-openapi", JAVA_API_JAR, JAVA_RESOURCES_JAR)
withModule("uast-common", JAVA_API_JAR, JAVA_RESOURCES_JAR)
withModule("java-analysis-impl", JAVA_IMPL_JAR, JAVA_RESOURCES_JAR)
withModule("java-indexing-impl", JAVA_IMPL_JAR, JAVA_RESOURCES_JAR)
withModule("java-psi-impl", JAVA_IMPL_JAR, JAVA_RESOURCES_JAR)
withModule("java-impl", JAVA_IMPL_JAR, JAVA_RESOURCES_JAR)
withModule("jsp-spi", JAVA_IMPL_JAR, JAVA_RESOURCES_JAR)
withModule("uast-java", JAVA_IMPL_JAR, JAVA_RESOURCES_JAR)
withModule("java-runtime", "idea_rt.jar", null)
withArtifact("debugger-agent", "rt")
withArtifact("debugger-agent-storage", "rt")
withProjectLibrary("Eclipse")
@@ -32,10 +32,12 @@ class IdeaCommunityProperties extends BaseIdeaProperties {
toolsJarRequired = true
buildCrossPlatformDistribution = true
productLayout.platformApiModules = CommunityRepositoryModules.PLATFORM_API_MODULES + JAVA_API_MODULES
productLayout.platformImplementationModules = CommunityRepositoryModules.PLATFORM_IMPLEMENTATION_MODULES + JAVA_IMPLEMENTATION_MODULES +
["duplicates-analysis", "structuralsearch", "structuralsearch-java", "typeMigration", "platform-main"] -
["jps-model-impl", "jps-model-serialization"]
productLayout.platformApiModules = CommunityRepositoryModules.PLATFORM_API_MODULES
productLayout.platformImplementationModules = CommunityRepositoryModules.PLATFORM_IMPLEMENTATION_MODULES
productLayout.productApiModules = JAVA_API_MODULES
productLayout.productImplementationModules = JAVA_IMPLEMENTATION_MODULES +
["duplicates-analysis", "structuralsearch", "structuralsearch-java", "typeMigration", "platform-main"] -
["jps-model-impl", "jps-model-serialization"]
productLayout.additionalPlatformJars.put("resources.jar", "community-resources")
productLayout.bundledPluginModules = BUNDLED_PLUGIN_MODULES
productLayout.mainModules = ["community-main"]
@@ -59,9 +59,9 @@ class PythonCommunityPluginModules {
directoryName = name
mainJarName = "${name}.jar"
modules.each { module ->
withModule(module, mainJarName, false)
withModule(module, mainJarName, null)
}
withModule(buildPatchesModule, mainJarName, false)
withModule(buildPatchesModule, mainJarName, null)
withResourceFromModule("python-helpers", "", "helpers")
withCustomVersion { BuildContext context ->
// TODO: Make the Python plugin follow the conventional scheme for plugin versioning, build the plugin together with the IDE
@@ -52,7 +52,6 @@ class CommunityRepositoryModules {
"xml-openapi",
"xml-psi-api",
"xml-structure-view-api",
"uast-common",
]
static List<String> PLATFORM_IMPLEMENTATION_MODULES = [
@@ -112,7 +111,7 @@ class CommunityRepositoryModules {
withModule("properties-psi-impl", "properties.jar")
},
plugin("git4idea") {
withModule("git4idea-rt", "git4idea-rt.jar", false)
withModule("git4idea-rt", "git4idea-rt.jar", null)
withOptionalModule("remote-servers-git")
withOptionalModule("remote-servers-git-java", "remote-servers-git.jar")
},
@@ -210,7 +209,7 @@ class CommunityRepositoryModules {
withModule("devkit-jps-plugin")
},
plugin("eclipse") {
withModule("eclipse-jps-plugin", "eclipse-jps-plugin.jar", false)
withModule("eclipse-jps-plugin", "eclipse-jps-plugin.jar", null)
withModule("common-eclipse-util")
},
plugin("coverage") {
@@ -244,8 +243,8 @@ class CommunityRepositoryModules {
withModule("manifest-merger")
withModule("repository")
withModule("common", "android-common.jar")
withModule("android-common", "android-common.jar", false)
withModule("android-rt", "android-rt.jar", false)
withModule("android-common", "android-common.jar", null)
withModule("android-rt", "android-rt.jar", null)
withModule("android-annotations", "androidAnnotations.jar")
withModule("sdklib", "sdklib.jar")
withModule("sdk-common", "sdk-common.jar")
@@ -269,7 +268,7 @@ class CommunityRepositoryModules {
withModule("instant-run-common", "sdk-tools.jar")
withModule("instant-run-client", "sdk-tools.jar")
withModule("instant-run-runtime", "sdk-tools.jar")
withModule("android-jps-plugin", "jps/android-jps-plugin.jar", false)
withModule("android-jps-plugin", "jps/android-jps-plugin.jar", null)
withProjectLibrary("freemarker-2.3.20") //todo[nik] move to module libraries
withProjectLibrary("jgraphx-3.4.0.1") //todo[nik] move to module libraries
withProjectLibrary("kxml2") //todo[nik] move to module libraries
@@ -28,22 +28,34 @@ import java.util.function.Consumer
@CompileStatic
class ProductModulesLayout {
/**
* Name of the main product JAR file. Outputs of {@link #platformImplementationModules} will be packed into it.
* Name of the main product JAR file. Outputs of {@link #productImplementationModules} will be packed into it.
*/
String mainJarName
/**
* Names of the modules which need to be packed into openapi.jar in the product's 'lib' directory.
* Names of the modules which need to be packed into platform-api.jar in the product's 'lib' directory.
* @see CommunityRepositoryModules#PLATFORM_API_MODULES
*/
List<String> platformApiModules = []
/**
* Names of the modules which need to be included into {@link #mainJarName} in the product's 'lib' directory
* Names of the modules which need to be included into platform-impl in the product's 'lib' directory
* @see CommunityRepositoryModules#PLATFORM_IMPLEMENTATION_MODULES
*/
List<String> platformImplementationModules = []
/**
* Names of the modules which need to be packed into openapi.jar in the product's 'lib' directory.
* @see CommunityRepositoryModules#PLATFORM_API_MODULES
*/
List<String> productApiModules = []
/**
* Names of the modules which need to be included into {@link #mainJarName} in the product's 'lib' directory
* @see CommunityRepositoryModules#PLATFORM_IMPLEMENTATION_MODULES
*/
List<String> productImplementationModules = []
/**
* Names of the main modules (containing META-INF/plugin.xml) of the plugins which need to be bundled with the product. It may also
* includes names of optional modules (added via {@link org.jetbrains.intellij.build.impl.PluginLayout.PluginLayoutSpec#withOptionalModule})
@@ -144,6 +156,6 @@ class ProductModulesLayout {
}
List<String> getIncludedPlatformModules() {
platformApiModules + platformImplementationModules + additionalPlatformJars.values()
productApiModules + productImplementationModules + additionalPlatformJars.values()
}
}
@@ -36,11 +36,11 @@ abstract class BaseLayout {
final List<ModuleLibraryData> includedModuleLibraries = []
/** JAR name -> name of project library which content should be unpacked */
final MultiValuesMap<String, String> projectLibrariesToUnpack = new MultiValuesMap<>()
protected final Set<String> modulesWithLocalizableResourcesInCommonJar = new LinkedHashSet<>()
protected final Map<String, String> modulesWithLocalizableResourcesInCommonJar = new LinkedHashMap<>()
final List<String> modulesWithExcludedModuleLibraries = []
final List<Pair<ResourcesGenerator, String>> resourceGenerators = []
boolean packLocalizableResourcesInCommonJar(String moduleName) {
return modulesWithLocalizableResourcesInCommonJar.contains(moduleName)
String localizableResourcesJarName(String moduleName) {
return modulesWithLocalizableResourcesInCommonJar.get(moduleName)
}
}
@@ -35,9 +35,9 @@ class BaseLayoutSpec {
* @param localizableResourcesInCommonJar if {@code true} the translatable resources from the module (messages, inspection descriptions, etc) will be
* placed into a separate 'resources_en.jar'. <strong>Do not use this for new plugins, this parameter is temporary added to keep layout of old plugins</strong>.
*/
void withModule(String moduleName, String relativeJarPath = "${moduleName}.jar", boolean localizableResourcesInCommonJar = true) {
if (localizableResourcesInCommonJar) {
layout.modulesWithLocalizableResourcesInCommonJar << moduleName
void withModule(String moduleName, String relativeJarPath = "${moduleName}.jar", String localizableResourcesInJar = "resources_en.jar") {
if (localizableResourcesInJar != null) {
layout.modulesWithLocalizableResourcesInCommonJar.put(moduleName, localizableResourcesInJar)
}
layout.moduleJars.put(relativeJarPath, moduleName)
}
@@ -421,8 +421,8 @@ idea.fatal.error.notification=disabled
buildContext.messages.error("productProperties.productLayout.prepareCustomPluginRepositoryForPublishedPlugins option is enabled but no pluginModulesToPublish are specified")
}
checkModules(layout.platformApiModules, "productProperties.productLayout.platformApiModules")
checkModules(layout.platformImplementationModules, "productProperties.productLayout.platformImplementationModules")
checkModules(layout.productApiModules, "productProperties.productLayout.productApiModules")
checkModules(layout.productImplementationModules, "productProperties.productLayout.productImplementationModules")
checkModules(layout.additionalPlatformJars.values(), "productProperties.productLayout.additionalPlatformJars")
checkModules(layout.moduleExcludes.keySet(), "productProperties.productLayout.moduleExcludes")
checkModules(layout.mainModules, "productProperties.productLayout.mainModules")
@@ -88,9 +88,15 @@ class DistributionJARsBuilder {
}
}
productLayout.platformApiModules.each {
withModule(it, "openapi.jar")
withModule(it, "platform-api.jar")
}
productLayout.platformImplementationModules.each {
withModule(it, "platform-impl.jar")
}
productLayout.productApiModules.each {
withModule(it, "openapi.jar")
}
productLayout.productImplementationModules.each {
withModule(it, productLayout.mainJarName)
}
productLayout.moduleExcludes.entrySet().each {
@@ -353,12 +359,12 @@ class DistributionJARsBuilder {
jar(jarPath, true) {
modules.each { moduleName ->
modulePatches([moduleName]) {
if (layout.packLocalizableResourcesInCommonJar(moduleName)) {
if (layout.localizableResourcesJarName(moduleName) != null) {
ant.patternset(refid: resourceExcluded)
}
}
module(moduleName) {
if (layout.packLocalizableResourcesInCommonJar(moduleName)) {
if (layout.localizableResourcesJarName(moduleName) != null) {
ant.patternset(refid: resourceExcluded)
}
layout.moduleExcludes.get(moduleName)?.each {
@@ -374,19 +380,27 @@ class DistributionJARsBuilder {
}
}
}
def modulesWithResources = moduleJars.values().findAll { layout.packLocalizableResourcesInCommonJar(it) }
if (!modulesWithResources.empty) {
jar("resources_en.jar", true) {
modulesWithResources.each { moduleName ->
modulePatches([moduleName]) {
ant.patternset(refid: resourcesIncluded)
}
module(moduleName) {
layout.moduleExcludes.get(moduleName)?.each {
//noinspection GrUnresolvedAccess
ant.exclude(name: "$it/**")
def outputResourceJars = new MultiValuesMap<String, String>()
moduleJars.values().forEach {
def resourcesJarName = layout.localizableResourcesJarName(it)
if (resourcesJarName != null) {
outputResourceJars.put(resourcesJarName, it)
}
}
if (!outputResourceJars.empty) {
outputResourceJars.keySet().forEach { resourceJarName ->
jar(resourceJarName, true) {
outputResourceJars.get(resourceJarName).each { moduleName ->
modulePatches([moduleName]) {
ant.patternset(refid: resourcesIncluded)
}
module(moduleName) {
layout.moduleExcludes.get(moduleName)?.each {
//noinspection GrUnresolvedAccess
ant.exclude(name: "$it/**")
}
ant.patternset(refid: resourcesIncluded)
}
ant.patternset(refid: resourcesIncluded)
}
}
}
@@ -27,8 +27,8 @@ class PyCharmCommunityProperties extends PyCharmPropertiesBase {
applicationInfoModule = "python-community-ide-resources"
brandingResourcePaths = ["$communityHome/python/resources"]
productLayout.platformApiModules = CommunityRepositoryModules.PLATFORM_API_MODULES + ["dom-openapi"]
productLayout.platformImplementationModules = CommunityRepositoryModules.PLATFORM_IMPLEMENTATION_MODULES + [
productLayout.productApiModules = CommunityRepositoryModules.PLATFORM_API_MODULES + ["dom-openapi"]
productLayout.productImplementationModules = CommunityRepositoryModules.PLATFORM_IMPLEMENTATION_MODULES + [
"dom-impl", "python-community", "python-community-ide-resources",
"python-community-ide", "python-community-configure", "python-openapi", "python-psi-api", "platform-main"
]
@@ -19,8 +19,8 @@ class PyCharmEduProperties extends PyCharmPropertiesBase {
brandingResourcePaths = ["$pythonCommunityPath/educational-python/resources"]
productLayout.mainModules = ["main_pycharm_edu"]
productLayout.platformApiModules = CommunityRepositoryModules.PLATFORM_API_MODULES + ["dom-openapi"]
productLayout.platformImplementationModules = CommunityRepositoryModules.PLATFORM_IMPLEMENTATION_MODULES + [
productLayout.productApiModules = CommunityRepositoryModules.PLATFORM_API_MODULES + ["dom-openapi"]
productLayout.productImplementationModules = CommunityRepositoryModules.PLATFORM_IMPLEMENTATION_MODULES + [
"dom-impl", "python-community", "python-community-ide-resources",
"python-community-ide", "python-community-configure", "educational-python", "python-openapi", "python-psi-api", "platform-main"
]