Skip to content

Commit

Permalink
Introduce VerifyPluginProjectConfigurationTask.hasModulePlugin to e…
Browse files Browse the repository at this point in the history
…xclude modules using `org.jetbrains.intellij.platform.module` subplugin from `plugin.xml` checks.
  • Loading branch information
hsz committed May 20, 2024
1 parent aa26216 commit 92e4348
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 22 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ abstract class VerifyPluginProjectConfigurationTask : DefaultTask(), IntelliJPla
@get:Internal
abstract val kotlinxCoroutinesLibraryPresent: Property<Boolean>

/**
* Defines if the current module is a main project or imported module, which uses [Plugins.MODULE] plugin.
*/
@get:Internal
abstract val hasModulePlugin: Property<Boolean>

private val log = Logger(javaClass)

init {
Expand All @@ -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()
Expand Down Expand Up @@ -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')")
Expand Down Expand Up @@ -308,23 +317,13 @@ abstract class VerifyPluginProjectConfigurationTask : DefaultTask(), IntelliJPla
)
}

hasModulePlugin.convention(project.provider {
project.pluginManager.hasPlugin(Plugins.MODULE)
})

project.tasks.withType<JavaCompile> {
dependsOn(this@registerTask)
}
}
}

// TODO: check it
// private fun verifyJavaPluginDependency(project: Project, ideaDependency: IdeaDependency, plugins: List<Any>) {
// 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)")
// }
// }
// }
// }
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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)

)

0 comments on commit 92e4348

Please sign in to comment.