diff --git a/src/main/kotlin/org/jetbrains/intellij/platform/gradle/extensions/IntelliJPlatformDependenciesHelper.kt b/src/main/kotlin/org/jetbrains/intellij/platform/gradle/extensions/IntelliJPlatformDependenciesHelper.kt index 5903d7ebe3..d554d451e0 100644 --- a/src/main/kotlin/org/jetbrains/intellij/platform/gradle/extensions/IntelliJPlatformDependenciesHelper.kt +++ b/src/main/kotlin/org/jetbrains/intellij/platform/gradle/extensions/IntelliJPlatformDependenciesHelper.kt @@ -710,7 +710,10 @@ class IntelliJPlatformDependenciesHelper( localProductInfo.validateSupportedVersion() val type = localProductInfo.productCode.toIntelliJPlatformType() - val version = localProductInfo.buildNumber + // It is crucial to use the IDE type + build number to the version. + // Because if UI & IC are used by different submodules in the same build, they might rewrite each other's Ivy + // XML files, which might have different optional transitive dependencies defined due to IC having fewer plugins. + val version = localProductInfo.getFullVersion() writeIvyModule(Dependencies.LOCAL_IDE_GROUP, type.code, version, artifactPath) { IvyModule( @@ -773,7 +776,11 @@ class IntelliJPlatformDependenciesHelper( } val artifactPath = requireNotNull(plugin.originalFile) - val version = requireNotNull(plugin.pluginVersion) + // It is crucial to use the IDE type + build number to the version. + // Because if UI & IC are used by different submodules in the same build, they might rewrite each other's Ivy + // XML files, which might have different optional transitive dependencies defined due to IC having fewer plugins. + // Should be the same as [collectDependencies] + val version = productInfo.get().getFullVersion() writeIvyModule(Dependencies.BUNDLED_PLUGIN_GROUP, id, version, artifactPath) { IvyModule( @@ -824,7 +831,11 @@ class IntelliJPlatformDependenciesHelper( val artifactPath = requireNotNull(plugin.originalFile) val group = Dependencies.BUNDLED_PLUGIN_GROUP val name = requireNotNull(plugin.pluginId) - val version = requireNotNull(plugin.pluginVersion) + // It is crucial to use the IDE type + build number to the version. + // Because if UI & IC are used by different submodules in the same build, they might rewrite each other's Ivy + // XML files, which might have different optional transitive dependencies defined due to IC having fewer plugins. + // Should be the same as [createIntelliJPlatformBundledPlugin] + val version = productInfo.get().getFullVersion() val doesNotDependOnSelf = id != plugin.pluginId val hasNeverBeenSeen = plugin.pluginId !in alreadyProcessedOrProcessing @@ -867,7 +878,10 @@ class IntelliJPlatformDependenciesHelper( */ private fun writeBundledModuleDependency(name: String, classPath: List): Triple { val group = Dependencies.BUNDLED_MODULE_GROUP - val version = productInfo.get().buildNumber + // It is crucial to use the IDE type + build number to the version. + // Because if UI & IC are used by different submodules in the same build, they might rewrite each other's Ivy + // XML files, which might have different optional transitive dependencies defined due to IC having fewer plugins. + val version = productInfo.get().getFullVersion() val platformPath = platformPath.get() val artifacts = classPath.flatMap { platformPath.resolve(it).toIvyArtifacts(metadataRulesModeProvider, platformPath) @@ -908,7 +922,10 @@ class IntelliJPlatformDependenciesHelper( pluginManager.safelyCreatePlugin(pluginPath).getOrThrow() } - val version = plugin.pluginVersion ?: "0.0.0" + // It is crucial to use the IDE type + build number to the version. + // Because if UI & IC are used by different submodules in the same build, they might rewrite each other's Ivy + // XML files, which might have different optional transitive dependencies defined due to IC having fewer plugins. + val version = productInfo.get().getFullVersion() + "-" + (plugin.pluginVersion ?: "0.0.0") val name = plugin.pluginId ?: artifactPath.name writeIvyModule(Dependencies.LOCAL_PLUGIN_GROUP, name, version, artifactPath) { @@ -943,13 +960,21 @@ class IntelliJPlatformDependenciesHelper( } }.get() + // E.g.: JBR-21.0.4+13-509.17-jcef val javaVendorVersion = runtimeMetadata["java.vendor.version"] requireNotNull(javaVendorVersion) + // E.g.: 21.0.4 val javaVersion = runtimeMetadata["java.version"] requireNotNull(javaVersion) + // E.g.: JBR val name = javaVendorVersion.substringBefore(javaVersion).trim('-') + // It is crucial to use the full version. + // Because if someone decides to bump JBR within the same marketing version, + // but in the next build – it’ll still refer to the incorrect version as they’ll be treated equally. + // They would rewrite each other's Ivy XML files since they would have the same name. + // E.g.: 21.0.4+13-509.17-jcef val version = javaVendorVersion.removePrefix(name).trim('-') writeIvyModule(Dependencies.LOCAL_JETBRAINS_RUNTIME_GROUP, name, version, artifactPath) { diff --git a/src/main/kotlin/org/jetbrains/intellij/platform/gradle/models/ProductInfo.kt b/src/main/kotlin/org/jetbrains/intellij/platform/gradle/models/ProductInfo.kt index 1ec3dcd97e..62d42d6e43 100644 --- a/src/main/kotlin/org/jetbrains/intellij/platform/gradle/models/ProductInfo.kt +++ b/src/main/kotlin/org/jetbrains/intellij/platform/gradle/models/ProductInfo.kt @@ -125,6 +125,9 @@ data class ProductInfo( } } +/** [ProductInfo.productCode] + "-" + [ProductInfo.buildNumber] */ +fun ProductInfo.getFullVersion() = productCode + "-" + buildNumber + /** * Validates that the resolved IntelliJ Platform is supported by checking against the minimal supported IntelliJ Platform version. * diff --git a/src/main/kotlin/org/jetbrains/intellij/platform/gradle/providers/JavaRuntimeMetadataValueSource.kt b/src/main/kotlin/org/jetbrains/intellij/platform/gradle/providers/JavaRuntimeMetadataValueSource.kt index 876be7d840..1daceb0aea 100644 --- a/src/main/kotlin/org/jetbrains/intellij/platform/gradle/providers/JavaRuntimeMetadataValueSource.kt +++ b/src/main/kotlin/org/jetbrains/intellij/platform/gradle/providers/JavaRuntimeMetadataValueSource.kt @@ -30,6 +30,71 @@ abstract class JavaRuntimeMetadataValueSource : ValueSource, val executable: RegularFileProperty } + /** + * Sample output: + * ``` + * user@user-kubuntu:~ $ /opt/ideau/jbr/bin/java -XshowSettings:properties -version + * Property settings: + * awt.toolkit.name = XToolkit + * file.encoding = UTF-8 + * file.separator = / + * intellij.os.virtualization = none + * java.class.path = + * java.class.version = 65.0 + * java.home = /opt/ideau/jbr + * java.io.tmpdir = /tmp + * java.library.path = /usr/java/packages/lib + * /usr/lib64 + * /lib64 + * /lib + * /usr/lib + * java.runtime.name = OpenJDK Runtime Environment + * java.runtime.version = 21.0.4+13-b509.17 + * java.specification.name = Java Platform API Specification + * java.specification.vendor = Oracle Corporation + * java.specification.version = 21 + * java.vendor = JetBrains s.r.o. + * java.vendor.url = https://openjdk.org/ + * java.vendor.url.bug = https://bugreport.java.com/bugreport/ + * java.vendor.version = JBR-21.0.4+13-509.17-jcef + * java.version = 21.0.4 + * java.version.date = 2024-07-16 + * java.vm.compressedOopsMode = Zero based + * java.vm.info = mixed mode + * java.vm.name = OpenJDK 64-Bit Server VM + * java.vm.specification.name = Java Virtual Machine Specification + * java.vm.specification.vendor = Oracle Corporation + * java.vm.specification.version = 21 + * java.vm.vendor = JetBrains s.r.o. + * java.vm.version = 21.0.4+13-b509.17 + * jbr.virtualization.information = No virtualization detected + * jdk.debug = release + * line.separator = \n + * native.encoding = UTF-8 + * os.arch = amd64 + * os.name = Linux + * os.version = 6.8.0-47-generic + * path.separator = : + * stderr.encoding = UTF-8 + * stdout.encoding = UTF-8 + * sun.arch.data.model = 64 + * sun.boot.library.path = /opt/ideau/jbr/lib + * sun.cpu.endian = little + * sun.io.unicode.encoding = UnicodeLittle + * sun.java.launcher = SUN_STANDARD + * sun.jnu.encoding = UTF-8 + * sun.management.compiler = HotSpot 64-Bit Tiered Compilers + * user.country = GB + * user.dir = /home/sasha + * user.home = /home/sasha + * user.language = en + * user.name = sasha + * + * openjdk version "21.0.4" 2024-07-16 + * OpenJDK Runtime Environment JBR-21.0.4+13-509.17-jcef (build 21.0.4+13-b509.17) + * OpenJDK 64-Bit Server VM JBR-21.0.4+13-509.17-jcef (build 21.0.4+13-b509.17, mixed mode) + * ``` + */ override fun obtain() = ByteArrayOutputStream().use { os -> execOperations.exec { commandLine(