Skip to content

Commit 79f8625

Browse files
committed
Support version-specific IntelliJ Platform type resolution and introduce UNIFIED_INTELLIJ_IDEA_VERSION and UNIFIED_INTELLIJ_IDEA_BUILD_NUMBER constants to help distinguish between IntelliJ IDEA and IntelliJ IDEA Ultimate when parsing IU code.
1 parent fd8ba3b commit 79f8625

File tree

12 files changed

+65
-33
lines changed

12 files changed

+65
-33
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- Update `String.parseIdeNotation()` to throw an exception for invalid IntelliJ Platform notation instead of returning a default value
1313
- Deprecate `IntelliJPlatformType.IntellijIdeaCommunity` and `IntelliJPlatformType.IntellijIdeaUltimate` with replacement suggestions to `IntelliJPlatformType.IntellijIdea`. JetBrains/intellij-platform-gradle-plugin#2021
1414
- Deprecate `intellijIdeaCommunity` and `intellijIdeaUltimate` dependency helpers with replacement suggestions to `intellijIdea`. JetBrains/intellij-platform-gradle-plugin#2021
15+
- Support version-specific IntelliJ Platform type resolution and introduce `UNIFIED_INTELLIJ_IDEA_VERSION` and `UNIFIED_INTELLIJ_IDEA_BUILD_NUMBER` constants to help distinguish between IntelliJ IDEA and IntelliJ IDEA Ultimate when parsing `IU` code.
1516

1617
### Fixed
1718

api/IntelliJPlatformGradlePlugin.api

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ public final class org/jetbrains/intellij/platform/gradle/Constants$Constraints
119119
public final fun getMINIMAL_INTELLIJ_PLATFORM_BUILD_NUMBER ()Lorg/jetbrains/intellij/platform/gradle/utils/Version;
120120
public final fun getMINIMAL_INTELLIJ_PLATFORM_VERSION ()Lorg/jetbrains/intellij/platform/gradle/utils/Version;
121121
public final fun getMINIMAL_SPLIT_MODE_BUILD_NUMBER ()Lorg/jetbrains/intellij/platform/gradle/utils/Version;
122+
public final fun getUNIFIED_INTELLIJ_IDEA_BUILD_NUMBER ()Lorg/jetbrains/intellij/platform/gradle/utils/Version;
123+
public final fun getUNIFIED_INTELLIJ_IDEA_VERSION ()Lorg/jetbrains/intellij/platform/gradle/utils/Version;
122124
}
123125

124126
public final class org/jetbrains/intellij/platform/gradle/Constants$Extensions {
@@ -336,11 +338,11 @@ public final class org/jetbrains/intellij/platform/gradle/IntelliJPlatformType :
336338

337339
public final class org/jetbrains/intellij/platform/gradle/IntelliJPlatformType$Companion {
338340
public final fun fromCode (Ljava/lang/String;)Lorg/jetbrains/intellij/platform/gradle/IntelliJPlatformType;
341+
public final fun fromCode (Ljava/lang/String;Ljava/lang/String;)Lorg/jetbrains/intellij/platform/gradle/IntelliJPlatformType;
339342
}
340343

341344
public final class org/jetbrains/intellij/platform/gradle/IntelliJPlatformTypeKt {
342-
public static final fun toIntelliJPlatformType (Ljava/lang/Object;)Lorg/jetbrains/intellij/platform/gradle/IntelliJPlatformType;
343-
public static final fun toIntelliJPlatformType (Lorg/gradle/api/provider/Provider;)Lorg/gradle/api/provider/Provider;
345+
public static final fun toIntelliJPlatformType (Ljava/lang/Object;Ljava/lang/String;)Lorg/jetbrains/intellij/platform/gradle/IntelliJPlatformType;
344346
}
345347

346348
public final class org/jetbrains/intellij/platform/gradle/ProductMode : java/lang/Enum {
@@ -3567,6 +3569,7 @@ public final class org/jetbrains/intellij/platform/gradle/utils/Version : java/l
35673569
public final fun getPatch ()I
35683570
public final fun getVersion ()Ljava/lang/String;
35693571
public fun hashCode ()I
3572+
public final fun isBuildNumber ()Z
35703573
public fun toString ()Ljava/lang/String;
35713574
}
35723575

src/main/kotlin/org/jetbrains/intellij/platform/gradle/Constants.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ object Constants {
4141
val MINIMAL_INTELLIJ_PLATFORM_BUILD_NUMBER = "223".toVersion()
4242
val MINIMAL_INTELLIJ_PLATFORM_VERSION = "2022.3".toVersion()
4343
val MINIMAL_SPLIT_MODE_BUILD_NUMBER = "241.14473".toVersion()
44+
val UNIFIED_INTELLIJ_IDEA_BUILD_NUMBER = "253".toVersion()
45+
val UNIFIED_INTELLIJ_IDEA_VERSION = "2025.3".toVersion()
4446
}
4547

4648
object Extensions {

src/main/kotlin/org/jetbrains/intellij/platform/gradle/IntelliJPlatformType.kt

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
package org.jetbrains.intellij.platform.gradle
44

5-
import org.gradle.api.provider.Provider
65
import org.jetbrains.intellij.platform.gradle.models.Coordinates
6+
import org.jetbrains.intellij.platform.gradle.utils.Version
77

88
// TODO any changes must be synchronized with
99
// IntelliJPlatformDependenciesExtension
@@ -137,30 +137,43 @@ enum class IntelliJPlatformType(
137137
private val map = values().associateBy(IntelliJPlatformType::code)
138138

139139
/**
140+
* Note: this method returns [IntellijIdea] for `IU` value, ignoring the [IntellijIdeaUltimate] type.
141+
*
142+
* @param code the product code name
143+
* @return the IntelliJ Platform type for the specified code name
140144
* @throws IllegalArgumentException
141145
*/
142146
@Throws(IllegalArgumentException::class)
143147
fun fromCode(code: String) = requireNotNull(map[code]) {
144148
"Specified type '$code' is unknown. Supported values: ${values().joinToString()}"
145149
}
150+
/**
151+
* Note: this method returns [IntellijIdea] for `IU` value, ignoring the [IntellijIdeaUltimate] type.
152+
*
153+
* @param code the product code name
154+
* @return the IntelliJ Platform type for the specified code name
155+
* @throws IllegalArgumentException
156+
*/
157+
@Throws(IllegalArgumentException::class)
158+
fun fromCode(code: String, version: String) = fromCode(code).run {
159+
when {
160+
this == IntellijIdea -> {
161+
with (Version.parse(version)) {
162+
when {
163+
isBuildNumber() && this < Constants.Constraints.UNIFIED_INTELLIJ_IDEA_BUILD_NUMBER -> IntellijIdeaUltimate
164+
!isBuildNumber() && this < Constants.Constraints.UNIFIED_INTELLIJ_IDEA_VERSION -> IntellijIdeaUltimate
165+
else -> IntellijIdea
166+
}
167+
}
168+
}
169+
else -> this
170+
}
171+
}
146172
}
147173

148174
override fun toString() = code
149175
}
150176

151-
/**
152-
* Maps the value held by this [Provider] to an [IntelliJPlatformType].
153-
*
154-
* This extension function transforms a [Provider] containing a value that can be converted
155-
* to an [IntelliJPlatformType] into a [Provider] of [IntelliJPlatformType].
156-
157-
* @receiver A [Provider] containing a value that can be converted to [IntelliJPlatformType]
158-
* @return A [Provider] of [IntelliJPlatformType] for the given provider value
159-
* @throws IllegalArgumentException if the provider value cannot be converted to [IntelliJPlatformType]
160-
*/
161-
@Throws(IllegalArgumentException::class)
162-
fun Provider<*>.toIntelliJPlatformType() = map { it.toIntelliJPlatformType() }
163-
164177
/**
165178
* Maps the value to an [IntelliJPlatformType].
166179
*
@@ -171,8 +184,8 @@ fun Provider<*>.toIntelliJPlatformType() = map { it.toIntelliJPlatformType() }
171184
* @throws IllegalArgumentException if the value cannot be converted to [IntelliJPlatformType]
172185
*/
173186
@Throws(IllegalArgumentException::class)
174-
fun Any.toIntelliJPlatformType(): IntelliJPlatformType = when (this) {
187+
fun Any.toIntelliJPlatformType(version: String) = when (this) {
175188
is IntelliJPlatformType -> this
176-
is String -> IntelliJPlatformType.fromCode(this)
189+
is String -> IntelliJPlatformType.fromCode(this, version)
177190
else -> throw IllegalArgumentException("Invalid argument type: '$javaClass'. Supported types: String or ${IntelliJPlatformType::class.java}")
178191
}

src/main/kotlin/org/jetbrains/intellij/platform/gradle/extensions/IntelliJPlatformDependenciesExtension.kt

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ abstract class IntelliJPlatformDependenciesExtension @Inject constructor(
8181
version: String,
8282
configure: Action<IntelliJPlatformDependencyConfiguration> = Action {},
8383
) = create {
84-
this.type = type.toIntelliJPlatformType()
84+
this.type = type.toIntelliJPlatformType(version)
8585
this.version = version
8686
apply(configure::execute)
8787
}
@@ -99,7 +99,7 @@ abstract class IntelliJPlatformDependenciesExtension @Inject constructor(
9999
version: Provider<String>,
100100
configure: Action<IntelliJPlatformDependencyConfiguration> = Action {},
101101
) = create {
102-
this.type = type.toIntelliJPlatformType()
102+
this.type = version.map { type.toIntelliJPlatformType(it) }
103103
this.version = version
104104
apply(configure::execute)
105105
}
@@ -117,7 +117,7 @@ abstract class IntelliJPlatformDependenciesExtension @Inject constructor(
117117
version: Provider<String>,
118118
configure: Action<IntelliJPlatformDependencyConfiguration> = Action {},
119119
) = create {
120-
this.type = type.toIntelliJPlatformType()
120+
this.type = type.zip(version) { typeValue, versionValue -> typeValue.toIntelliJPlatformType(versionValue) }
121121
this.version = version
122122
apply(configure::execute)
123123
}
@@ -814,7 +814,7 @@ abstract class IntelliJPlatformDependenciesExtension @Inject constructor(
814814
productMode: ProductMode = ProductMode.MONOLITH,
815815
) = create {
816816
val (type, version) = notation.parseIdeNotation()
817-
this.type = type.toIntelliJPlatformType()
817+
this.type = type
818818
this.version = version
819819
this.useInstaller = useInstaller
820820
this.productMode = productMode
@@ -838,8 +838,13 @@ abstract class IntelliJPlatformDependenciesExtension @Inject constructor(
838838
productMode: ProductMode = ProductMode.MONOLITH,
839839
) = create {
840840
val parsedNotationProvider = notation.map { it.parseIdeNotation() }
841-
this.type = parsedNotationProvider.map { it.first }.toIntelliJPlatformType()
842-
this.version = parsedNotationProvider.map { it.second }
841+
val version = parsedNotationProvider.map { it.second }
842+
val type = parsedNotationProvider.map { it.first }.zip(version) { typeValue, versionValue ->
843+
typeValue.toIntelliJPlatformType(versionValue)
844+
}
845+
846+
this.type = type
847+
this.version = version
843848
this.useInstaller = useInstaller
844849
this.productMode = productMode
845850
}

src/main/kotlin/org/jetbrains/intellij/platform/gradle/extensions/IntelliJPlatformExtension.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,7 @@ abstract class IntelliJPlatformExtension @Inject constructor(
932932
version: String,
933933
configure: IntelliJPlatformDependencyConfiguration.() -> Unit = {},
934934
) = create {
935-
this.type = type.toIntelliJPlatformType()
935+
this.type = type.toIntelliJPlatformType(version)
936936
this.version = version
937937
configure()
938938
}
@@ -950,7 +950,7 @@ abstract class IntelliJPlatformExtension @Inject constructor(
950950
version: Provider<String>,
951951
configure: IntelliJPlatformDependencyConfiguration.() -> Unit = {},
952952
) = create {
953-
this.type = type.toIntelliJPlatformType()
953+
this.type = version.map { type.toIntelliJPlatformType(it) }
954954
this.version = version
955955
configure()
956956
}
@@ -968,7 +968,9 @@ abstract class IntelliJPlatformExtension @Inject constructor(
968968
version: Provider<String>,
969969
configure: IntelliJPlatformDependencyConfiguration.() -> Unit = {},
970970
) = create {
971-
this.type = type.toIntelliJPlatformType()
971+
this.type = type.zip(version) { typeValue, versionValue ->
972+
typeValue.toIntelliJPlatformType(versionValue)
973+
}
972974
this.version = version
973975
configure()
974976
}

src/main/kotlin/org/jetbrains/intellij/platform/gradle/extensions/extensions.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import org.jetbrains.intellij.platform.gradle.toIntelliJPlatformType
1515
*/
1616
internal fun String.parseIdeNotation() = trim().split('-').let {
1717
when {
18-
it.size == 2 -> it.first().toIntelliJPlatformType() to it.last()
18+
it.size == 2 -> it.let { (type, version) -> type.toIntelliJPlatformType(version) to version }
1919
else -> throw IllegalArgumentException("Invalid IntelliJ Platform notation: '$this'. Expected format: '<type>-<version>', like 'IU-2025.3'.")
2020
}
2121
}

src/main/kotlin/org/jetbrains/intellij/platform/gradle/models/ProductInfo.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ val ProductInfo.fullVersion
177177
get() = "$productCode-$buildNumber"
178178

179179
val ProductInfo.type
180-
get() = productCode.toIntelliJPlatformType()
180+
get() = productCode.toIntelliJPlatformType(buildNumber)
181181

182182
/**
183183
* Validates that the resolved IntelliJ Platform is supported by checking against the minimal supported IntelliJ Platform version.

src/main/kotlin/org/jetbrains/intellij/platform/gradle/providers/ProductReleasesValueSource.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import org.gradle.api.provider.ValueSource
88
import org.gradle.api.provider.ValueSourceParameters
99
import org.gradle.api.tasks.Input
1010
import org.gradle.api.tasks.Optional
11+
import org.jetbrains.intellij.platform.gradle.Constants.Constraints
1112
import org.jetbrains.intellij.platform.gradle.GradleProperties
1213
import org.jetbrains.intellij.platform.gradle.IntelliJPlatformType
1314
import org.jetbrains.intellij.platform.gradle.models.AndroidStudioReleases
@@ -94,7 +95,9 @@ abstract class ProductReleasesValueSource : ValueSource<List<String>, ProductRel
9495
product.channels.forEach channel@{ channelEntry ->
9596
channelEntry.builds.forEach { build ->
9697
product.codes.forEach codes@{ code ->
97-
val type = runCatching { code.toIntelliJPlatformType() }.getOrElse { return@codes }
98+
val type = runCatching {
99+
code.toIntelliJPlatformType(Constraints.UNIFIED_INTELLIJ_IDEA_BUILD_NUMBER.version)
100+
}.getOrElse { return@codes }
98101
val channel = runCatching { Channel.valueOf(channelEntry.status.uppercase()) }.getOrElse { return@channel }
99102

100103
yield(

src/main/kotlin/org/jetbrains/intellij/platform/gradle/utils/IntelliJPlatformCacheResolver.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class IntelliJPlatformCacheResolver internal constructor(
7676
version: String,
7777
configure: IntelliJPlatformDependencyConfiguration.() -> Unit = {},
7878
) = resolve {
79-
this.type = type.toIntelliJPlatformType()
79+
this.type = type.toIntelliJPlatformType(version)
8080
this.version = version
8181
configure()
8282
}
@@ -98,7 +98,7 @@ class IntelliJPlatformCacheResolver internal constructor(
9898
version: Provider<String>,
9999
configure: IntelliJPlatformDependencyConfiguration.() -> Unit = {},
100100
) = resolve {
101-
this.type = type.toIntelliJPlatformType()
101+
this.type = version.map { type.toIntelliJPlatformType(it) }
102102
this.version = version
103103
configure()
104104
}
@@ -120,7 +120,7 @@ class IntelliJPlatformCacheResolver internal constructor(
120120
version: Provider<String>,
121121
configure: IntelliJPlatformDependencyConfiguration.() -> Unit = {},
122122
) = resolve {
123-
this.type = type.toIntelliJPlatformType()
123+
this.type = type.zip(version) { typeValue, versionValue -> typeValue.toIntelliJPlatformType(versionValue) }
124124
this.version = version
125125
configure()
126126
}

0 commit comments

Comments
 (0)