Warnings emitted when module-info.java is present

I’ve a project here that I’m looking to make modular by adding a lib/src/main/java/module-info.java. However, upon doing so, the following warnings are emitted to the console. When paired with the compiler argument -Werror, the build fails. Upon deleting the module file, the warnings disappear.

> Task :compileKotlin
w: file:///me/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-reflect/2.0.20/580c610641d75b6448825cbe455a1ded220e148b/kotlin-reflect-2.0.20.jar The root is ignored because a module with the same name 'kotlin.reflect' has been found earlier on the module path at: /me/.gradle/wrapper/dists/gradle-8.11.1-bin/bpt9gzteqjrbo1mjrsomdt32c/gradle-8.11.1/lib/kotlin-reflect-2.0.20.jar
w: file:///me/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/2.0.20/7388d355f7cceb002cd387ccb7ab3850e4e0a07f/kotlin-stdlib-2.0.20.jar The root is ignored because a module with the same name 'kotlin.stdlib' has been found earlier on the module path at: /me/.gradle/wrapper/dists/gradle-8.11.1-bin/bpt9gzteqjrbo1mjrsomdt32c/gradle-8.11.1/lib/kotlin-stdlib-2.0.20.jar

Using Gradle 8.11.1 with Kotlin Gradle plugin 2.0.20.

Don’t apply KGP and kotlin-dsl.
As you do not develop a Gradle plugin, the latter makes no sense.

1 Like

After reading the docs again, I now see the following:

The Kotlin DSL Plugin provides a convenient way to develop Kotlin-based projects that contribute build logic. This includes buildSrc projects, included builds, and Gradle plugins.

However, apart from this passing statement, there’s no other indication that the Kotlin DSL Plugin shouldn’t be used for libraries and applications. Could the docs be updated to make this crystal clear, perhaps by turning the above statement into a warning?

You can apply it just fine, it just does not make much sense in your context.
You can also apply the codenarc plugin to a Kotlin project, it just does not make much sense in that context, should a warning be added there too? :wink:

Anyway, I’m just a user like you.
While I do not agree that the docs need more clarity at that spot, feel free to open a documentation issue or PR to improve on that, then it is up to the Gradle folks what they do. :slight_smile:

I’m confused, because your previous comment led me to think the problem in my post was caused by the kotlin-dsl plugin. If its presence isn’t doing any harm, then you didn’t really answer my question.
Also, I noticed that the plugin adds a bunch of *plugin tasks that previously had me wondering. Now I understand those tasks were added by the plugin.

I didn’t say it does not do harm.
Nor did I say it does harm.
It does things.
And in your project those things do not make sense.
And when making the project JPMS aware you obviously get problems because you have the Kotlin libraries on the module path twice, which without JPMS is not that much of a problem especially if it is the same version.
But in your situation now that plugin causes problems. :man_shrugging: