From 92e4348bcc64d6b958f7fb53f043aa61719566ca Mon Sep 17 00:00:00 2001 From: Jakub Chrzanowski Date: Mon, 20 May 2024 10:36:25 +0200 Subject: [PATCH] Introduce `VerifyPluginProjectConfigurationTask.hasModulePlugin` to exclude modules using `org.jetbrains.intellij.platform.module` subplugin from `plugin.xml` checks. --- CHANGELOG.md | 6 ++- .../VerifyPluginProjectConfigurationTask.kt | 37 +++++++++---------- .../gradle/utils/PlatformJavaVersions.kt | 2 + .../gradle/utils/PlatformKotlinVersions.kt | 1 - 4 files changed, 24 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 950b3ab1af..e43010a446 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,11 @@ ## [next] -## [2.0.0-beta3] - 2024-05-18 +### Added -The **IntelliJ Platform Gradle Plugin `2.0.0-beta3`** is a plugin for the Gradle build system to help configure environments for building, testing, verifying, and publishing plugins for IntelliJ-based IDEs. It is a successor of _Gradle IntelliJ Plugin 1.x_. +- Introduce `VerifyPluginProjectConfigurationTask.hasModulePlugin` to exclude modules using `org.jetbrains.intellij.platform.module` subplugin from `plugin.xml` checks. + +## [2.0.0-beta3] - 2024-05-18 ### Added diff --git a/src/main/kotlin/org/jetbrains/intellij/platform/gradle/tasks/VerifyPluginProjectConfigurationTask.kt b/src/main/kotlin/org/jetbrains/intellij/platform/gradle/tasks/VerifyPluginProjectConfigurationTask.kt index 7c1e0f44d0..9e8c4fba08 100644 --- a/src/main/kotlin/org/jetbrains/intellij/platform/gradle/tasks/VerifyPluginProjectConfigurationTask.kt +++ b/src/main/kotlin/org/jetbrains/intellij/platform/gradle/tasks/VerifyPluginProjectConfigurationTask.kt @@ -128,6 +128,12 @@ abstract class VerifyPluginProjectConfigurationTask : DefaultTask(), IntelliJPla @get:Internal abstract val kotlinxCoroutinesLibraryPresent: Property + /** + * Defines if the current module is a main project or imported module, which uses [Plugins.MODULE] plugin. + */ + @get:Internal + abstract val hasModulePlugin: Property + private val log = Logger(javaClass) init { @@ -140,9 +146,9 @@ abstract class VerifyPluginProjectConfigurationTask : DefaultTask(), IntelliJPla val platformBuild = productInfo.buildNumber.toVersion() val platformVersion = productInfo.version.toVersion() val platformJavaVersion = getPlatformJavaVersion(platformBuild) - val sourceCompatibilityJavaVersion = JavaVersion.toVersion(sourceCompatibility.get()) - val targetCompatibilityJavaVersion = JavaVersion.toVersion(targetCompatibility.get()) - val jvmTargetJavaVersion = kotlinJvmTarget.orNull?.let { JavaVersion.toVersion(it) } + val sourceCompatibilityJavaVersion = sourceCompatibility.get().toJavaVersion() + val targetCompatibilityJavaVersion = targetCompatibility.get().toJavaVersion() + val jvmTargetJavaVersion = kotlinJvmTarget.orNull?.toJavaVersion() val kotlinApiVersion = kotlinApiVersion.orNull?.toVersion() val kotlinLanguageVersion = kotlinLanguageVersion.orNull?.toVersion() val kotlinPluginAvailable = kotlinPluginAvailable.get() @@ -174,8 +180,11 @@ abstract class VerifyPluginProjectConfigurationTask : DefaultTask(), IntelliJPla yield("The Kotlin configuration specifies apiVersion='$kotlinApiVersion' but since-build='$sinceBuild' property requires apiVersion='$sinceBuildKotlinApiVersion'.") } } - ?: yield("The plugin.xml descriptor file could not be found.") - + ?: run { + if (!hasModulePlugin.get()) { + this@sequence.yield("The plugin.xml descriptor file could not be found.") + } + } if (platformBuild < MINIMAL_INTELLIJ_PLATFORM_BUILD_NUMBER) { yield("The minimal supported IntelliJ Platform version is `$MINIMAL_INTELLIJ_PLATFORM_VERSION` (branch `$MINIMAL_INTELLIJ_PLATFORM_BUILD_NUMBER`), current: '$platformVersion' ('$platformBuild')") @@ -308,23 +317,13 @@ abstract class VerifyPluginProjectConfigurationTask : DefaultTask(), IntelliJPla ) } + hasModulePlugin.convention(project.provider { + project.pluginManager.hasPlugin(Plugins.MODULE) + }) + project.tasks.withType { dependsOn(this@registerTask) } } } - - // TODO: check it -// private fun verifyJavaPluginDependency(project: Project, ideaDependency: IdeaDependency, plugins: List) { -// val hasJavaPluginDependency = plugins.contains("java") || plugins.contains("com.intellij.java") -// if (!hasJavaPluginDependency && File(ideaDependency.classes, "plugins/java").exists()) { -// sourcePluginXmlFiles(project).forEach { path -> -// parsePluginXml(path)?.dependencies?.forEach { -// if (it.dependencyId == "com.intellij.modules.java") { -// throw BuildException("The project depends on 'com.intellij.modules.java' module but doesn't declare a compile dependency on it.\nPlease delete 'depends' tag from '${path}' or add Java plugin to Gradle dependencies (https://plugins.jetbrains.com/docs/intellij/plugin-compatibility.html#java)") -// } -// } -// } -// } -// } } diff --git a/src/main/kotlin/org/jetbrains/intellij/platform/gradle/utils/PlatformJavaVersions.kt b/src/main/kotlin/org/jetbrains/intellij/platform/gradle/utils/PlatformJavaVersions.kt index 9d3176a377..9031d21f7c 100644 --- a/src/main/kotlin/org/jetbrains/intellij/platform/gradle/utils/PlatformJavaVersions.kt +++ b/src/main/kotlin/org/jetbrains/intellij/platform/gradle/utils/PlatformJavaVersions.kt @@ -13,3 +13,5 @@ val PlatformJavaVersions = mapOf( Version(203) to JavaVersion.VERSION_11, Version(0) to JavaVersion.VERSION_1_8, ) + +internal fun String.toJavaVersion() = JavaVersion.toVersion(this) diff --git a/src/main/kotlin/org/jetbrains/intellij/platform/gradle/utils/PlatformKotlinVersions.kt b/src/main/kotlin/org/jetbrains/intellij/platform/gradle/utils/PlatformKotlinVersions.kt index b44797ad1b..a046e78c6d 100644 --- a/src/main/kotlin/org/jetbrains/intellij/platform/gradle/utils/PlatformKotlinVersions.kt +++ b/src/main/kotlin/org/jetbrains/intellij/platform/gradle/utils/PlatformKotlinVersions.kt @@ -12,5 +12,4 @@ val PlatformKotlinVersions = mapOf( Version(232) to Version(1, 8, 20), Version(231) to Version(1, 8, 0), Version(223) to Version(1, 7, 0) - )