Skip to content

Commit

Permalink
Warn when the until-build property is specified for IntelliJ Platfo…
Browse files Browse the repository at this point in the history
…rm version `243+` as it is ignored and set it to `null`
  • Loading branch information
hsz committed Feb 13, 2025
1 parent 5d092f9 commit 529c51f
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Add `ide(type: Provider<*>, version: Provider<String>, useInstaller: Provider<Boolean>)` overload to the `pluginVerification.ides` block.
- Warn that since the IntelliJ Platform version `2025.1` (build `251`), the required Kotlin version is `2.0.0` or higher.
- Load the `com.intellij` bundled module by default for all IntelliJ Platform types
- Warn when the "until-build" property is specified for IntelliJ Platform version 243 or higher, as it is ignored

### Fixed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,17 @@ class PluginXmlPatchingIntegrationTest : IntelliJPlatformIntegrationTestBase(
resourceName = "plugin-xml-patching",
) {

override val defaultProjectProperties
get() = super.defaultProjectProperties + mapOf(
"languageVersion" to "17",
"sinceBuild" to "231",
)

@Test
fun `patch plugin_xml`() {
build(Tasks.BUILD_PLUGIN, projectProperties = defaultProjectProperties) {
build(Tasks.BUILD_PLUGIN, projectProperties = defaultProjectProperties + mapOf(
"untilBuild" to "233.*"
)) {
assertTaskOutcome(Tasks.PATCH_PLUGIN_XML, TaskOutcome.SUCCESS)

val patchedPluginXml = buildDirectory.resolve("tmp/patchPluginXml/plugin.xml")
Expand All @@ -29,4 +37,23 @@ class PluginXmlPatchingIntegrationTest : IntelliJPlatformIntegrationTestBase(
""".trimIndent()
}
}

@Test
fun `patch plugin_xml and set the until-build to null if targeted 243+`() {
build(Tasks.BUILD_PLUGIN, projectProperties = defaultProjectProperties + mapOf(
"intellijPlatform.version" to "2024.3",
"languageVersion" to "21",
"sinceBuild" to "243",
)) {
assertTaskOutcome(Tasks.PATCH_PLUGIN_XML, TaskOutcome.SUCCESS)

val patchedPluginXml = buildDirectory.resolve("tmp/patchPluginXml/plugin.xml")
assertExists(patchedPluginXml)

patchedPluginXml containsText //language=xml
"""
<idea-version since-build="243" />
""".trimIndent()
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
val intellijPlatformTypeProperty = providers.gradleProperty("intellijPlatform.type")
val intellijPlatformVersionProperty = providers.gradleProperty("intellijPlatform.version")
val languageVersionProperty = providers.gradleProperty("languageVersion").map { it.toInt() }
val sinceBuildProperty = providers.gradleProperty("sinceBuild")
val untilBuildProperty = providers.gradleProperty("untilBuild")

plugins {
id("org.jetbrains.kotlin.jvm")
Expand All @@ -9,7 +12,7 @@ plugins {
version = "1.0.0"

kotlin {
jvmToolchain(17)
jvmToolchain(languageVersionProperty.get())
}

repositories {
Expand All @@ -23,7 +26,6 @@ repositories {
dependencies {
intellijPlatform {
create(intellijPlatformTypeProperty, intellijPlatformVersionProperty)
instrumentationTools()
}
}

Expand All @@ -33,8 +35,8 @@ intellijPlatform {

pluginConfiguration {
ideaVersion {
sinceBuild = "231"
untilBuild = "233.*"
sinceBuild = sinceBuildProperty
untilBuild = untilBuildProperty
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ import org.jetbrains.intellij.platform.gradle.models.ProductRelease.Channel
import org.jetbrains.intellij.platform.gradle.models.productInfo
import org.jetbrains.intellij.platform.gradle.plugins.configureExtension
import org.jetbrains.intellij.platform.gradle.providers.ProductReleasesValueSource.FilterParameters
import org.jetbrains.intellij.platform.gradle.tasks.*
import org.jetbrains.intellij.platform.gradle.tasks.BuildSearchableOptionsTask
import org.jetbrains.intellij.platform.gradle.tasks.PatchPluginXmlTask
import org.jetbrains.intellij.platform.gradle.tasks.PublishPluginTask
import org.jetbrains.intellij.platform.gradle.tasks.SignPluginTask
import org.jetbrains.intellij.platform.gradle.tasks.VerifyPluginTask.*
import org.jetbrains.intellij.platform.gradle.tasks.aware.PluginVerifierAware
import org.jetbrains.intellij.platform.gradle.tasks.aware.SigningAware
Expand Down Expand Up @@ -454,7 +457,13 @@ abstract class IntelliJPlatformExtension @Inject constructor(
it.runCatching { productInfo.buildNumber.toVersion() }.getOrDefault(Version())
}
sinceBuild.convention(buildVersion.map { "${it.major}.${it.minor}" })
untilBuild.convention(buildVersion.map { "${it.major}.*" })
untilBuild.convention(buildVersion.flatMap { version ->
if (version.major >= 243) {
project.provider { null }
} else {
project.provider { "${version.major}.*" }
}
})
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ abstract class VerifyPluginProjectConfigurationTask : DefaultTask(), IntelliJPla
if (sinceBuild.major < platformBuild.major) {
yield("The since-build='$sinceBuild' is lower than the target IntelliJ Platform major version: '${platformBuild.major}'.")
}
if (sinceBuild.major >= 243 && file.parse { ideaVersion.untilBuild != null }) {
yield("The until-build property is ignored for IntelliJ Platform version 243 or higher.")
}
if (sinceBuildJavaVersion < targetCompatibilityJavaVersion) {
yield("The Java configuration specifies targetCompatibility=$targetCompatibilityJavaVersion but since-build='$sinceBuild' property requires targetCompatibility='$sinceBuildJavaVersion'.")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,38 @@ class VerifyPluginProjectConfigurationTaskTest : IntelliJPluginTestBase() {
}
}

@Test
fun `report ignored until-build for version 243 or higher`() {
buildFile write //language=kotlin
"""
intellijPlatform {
pluginConfiguration {
ideaVersion {
sinceBuild = "243"
untilBuild = "243.*"
}
}
}
""".trimIndent()

pluginXml write //language=xml
"""
<idea-plugin>
<name>PluginName</name>
<description>Lorem ipsum.</description>
<vendor>JetBrains</vendor>
<idea-version since-build="243" until-build="243.*" />
</idea-plugin>
""".trimIndent()

build(Tasks.VERIFY_PLUGIN_PROJECT_CONFIGURATION) {
assertContains(HEADER, output)
assertContains(
"- The until-build property is ignored for IntelliJ Platform version 243 or higher.", output
)
}
}

@Test
fun `report invalid sinceBuild if contains wildcard`() {
buildFile write //language=kotlin
Expand Down

0 comments on commit 529c51f

Please sign in to comment.