Version
Plugin: 1.0.0-rc3
Gradle: 7.4.2
Description
Trying to use this plugin with a Kotlin JVM project fails due to a circular dependency between tasks. Gradle output:
FAILURE: Build failed with an exception.
* What went wrong:
Circular dependency between the following tasks:
:app:addDependenciesModuleInfo
+--- :app:generateModuleInfo
| \--- :app:jar
| +--- :app:classes
| | \--- :app:compileJava
| | \--- :app:addDependenciesModuleInfo (*)
| \--- :app:inspectClassesForKotlinIC
| \--- :app:classes (*)
\--- :app:jar (*)
(*) - details omitted (listed previously)
I also noticed some other issues when using moduleInfoSource; maybe it would be good to add some integration tests for Kotlin projects.
Thanks a lot nonetheless for providing this Gradle plugin and the corresponding Maven plugin. Their functionality is really great!
Reproduction steps
You can skip the steps for creating the project below and instead use https://github.com/Marcono1234/moditect-kotlin-test
- Create a sample Kotlin JVM project (e.g. by using
gradle init)
- Use the following
build.gradle.kts file
plugins {
kotlin("jvm") version "1.6.21"
id("org.moditect.gradleplugin") version "1.0.0-rc3"
}
repositories {
mavenCentral()
}
dependencies {
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
}
tasks.addMainModuleInfo {
version = project.version
jvmVersion.set("9")
overwriteExistingFiles.set(true)
module {
moduleInfoFile = File("$projectDir/src/main/java-9/module-info.java")
}
}
- Run
./gradlew clean build
❌ It fails
Workaround
Add the following to the build.gradle.kts file:
project.afterEvaluate {
val compileJavaTask = tasks.compileJava.get()
compileJavaTask.setDependsOn(compileJavaTask.dependsOn - tasks.addDependenciesModuleInfo.get())
}
(Based on this related StackOverflow answer)
With that ./gradlew clean build succeeds and the generated JAR is properly configured as Multi-Release JAR and contains the compiled module-info.class.
Version
Plugin: 1.0.0-rc3
Gradle: 7.4.2
Description
Trying to use this plugin with a Kotlin JVM project fails due to a circular dependency between tasks. Gradle output:
I also noticed some other issues when using
moduleInfoSource; maybe it would be good to add some integration tests for Kotlin projects.Thanks a lot nonetheless for providing this Gradle plugin and the corresponding Maven plugin. Their functionality is really great!
Reproduction steps
You can skip the steps for creating the project below and instead use https://github.com/Marcono1234/moditect-kotlin-test
gradle init)build.gradle.ktsfileplugins { kotlin("jvm") version "1.6.21" id("org.moditect.gradleplugin") version "1.0.0-rc3" } repositories { mavenCentral() } dependencies { implementation(platform("org.jetbrains.kotlin:kotlin-bom")) } tasks.addMainModuleInfo { version = project.version jvmVersion.set("9") overwriteExistingFiles.set(true) module { moduleInfoFile = File("$projectDir/src/main/java-9/module-info.java") } }./gradlew clean build❌ It fails
Workaround
Add the following to the
build.gradle.ktsfile:project.afterEvaluate { val compileJavaTask = tasks.compileJava.get() compileJavaTask.setDependsOn(compileJavaTask.dependsOn - tasks.addDependenciesModuleInfo.get()) }(Based on this related StackOverflow answer)
With that
./gradlew clean buildsucceeds and the generated JAR is properly configured as Multi-Release JAR and contains the compiledmodule-info.class.