From bd9ec9d2acc78fa85ade394615eb9a7dd17c60b1 Mon Sep 17 00:00:00 2001 From: AlexanderBartash Date: Thu, 17 Oct 2024 20:25:00 +0300 Subject: [PATCH] Fixed generation of duplicate files in ".intellijPlatform/localPlatformArtifacts" with different version numbers. --- CHANGELOG.md | 1 + .../IntelliJPlatformDependenciesHelper.kt | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6828c4b81d..2e4acc22c3 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ - Fixed issue #1778 by removing a hash of the absolute artifact path appended to the end of the version string. That hash made artifact version different on different PCs and also breaks Gradle dependency locking. - Add the missing `org.jetbrains.kotlin.platform.type=jvm` attribute to the `intellijPlatformRuntimeClasspath` configuration manually as it's not inherited from the `runtimeClasspath`. - Fixed `Could not generate a decorated class for type PluginArtifactRepository.` when creating a custom plugin repository. +- Fixed generation of duplicate files in ".intellijPlatform/localPlatformArtifacts" with different version numbers. ## [2.1.0] 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 bf1f99c678..3974412cb6 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 @@ -741,7 +741,7 @@ class IntelliJPlatformDependenciesHelper( } val artifactPath = requireNotNull(plugin.originalFile) - val version = baseVersion.orElse(productInfo.map { it.version }).get() + val version = getVersionForBundledPlugin(plugin) writeIvyModule(Dependencies.BUNDLED_PLUGIN_GROUP, id, version) { IvyModule( @@ -773,7 +773,7 @@ class IntelliJPlatformDependenciesHelper( .let { requireNotNull(it) { "Specified bundledModule '$id' doesn't exist." } } val platformPath = platformPath.get() val artifactPaths = bundledModule.classPath.map { path -> platformPath.resolve(path).toIvyArtifact() } - val version = baseVersion.orElse(productInfo.map { it.version }).get() + val version = getVersionForBundledModule() writeIvyModule(Dependencies.BUNDLED_MODULE_GROUP, id, version) { IvyModule( @@ -793,6 +793,12 @@ class IntelliJPlatformDependenciesHelper( ) } + // These two methods were created to make clearly visible that we want to use consistent version numbers in + // collectDependencies as well as in createIntelliJPlatformBundledModule & createIntelliJPlatformBundledPlugin + // When the version is retrieved like this, it is impossible to change it one place & forger to chang another. + private fun getVersionForBundledModule() = productInfo.get().buildNumber + private fun getVersionForBundledPlugin(plugin: IdePlugin) = requireNotNull(plugin.pluginVersion) + /** * Collects all dependencies on plugins or modules of the current [IdePlugin]. * The [path] parameter is a list of already traversed entities, used to avoid circular dependencies when walking recursively. @@ -802,7 +808,6 @@ class IntelliJPlatformDependenciesHelper( private fun IdePlugin.collectDependencies(path: List = emptyList()): List { val id = requireNotNull(pluginId) val dependencyIds = (dependencies.map { it.id } + optionalDescriptors.map { it.dependency.id } + modulesDescriptors.map { it.name } - id).toSet() - val buildNumber by lazy { productInfo.get().buildNumber } val platformPath by lazy { platformPath.get() } val plugins = dependencyIds @@ -811,7 +816,7 @@ class IntelliJPlatformDependenciesHelper( val artifactPath = requireNotNull(plugin.originalFile) val group = Dependencies.BUNDLED_PLUGIN_GROUP val name = requireNotNull(plugin.pluginId) - val version = requireNotNull(plugin.pluginVersion) + val version = getVersionForBundledPlugin(plugin) writeIvyModule(group, name, version) { IvyModule( @@ -839,7 +844,7 @@ class IntelliJPlatformDependenciesHelper( val artifactPaths = it.classPath.map { path -> platformPath.resolve(path).toIvyArtifact() } val group = Dependencies.BUNDLED_MODULE_GROUP val name = it.name - val version = buildNumber + val version = getVersionForBundledModule() writeIvyModule(group, name, version) { IvyModule(