Skip to content

Commit

Permalink
Fixed generation of duplicate files in ".intellijPlatform/localPlatfo…
Browse files Browse the repository at this point in the history
…rmArtifacts" with different version numbers.
  • Loading branch information
AlexanderBartash committed Oct 17, 2024
1 parent 1a41a35 commit bd9ec9d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand All @@ -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.
Expand All @@ -802,7 +808,6 @@ class IntelliJPlatformDependenciesHelper(
private fun IdePlugin.collectDependencies(path: List<String> = emptyList()): List<IvyModule.Dependency> {
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
Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit bd9ec9d

Please sign in to comment.