kordamp / jdeps-gradle-plugin

Run JDeps on a Gradle build
Apache License 2.0
35 stars 10 forks source link

Failure with Kotlin 1.5.0: Configuration with name 'runtime' not found. #17

Closed McPringle closed 3 years ago

McPringle commented 3 years ago

Works fine with Kotlin <= 1.4.31:

$> git clone https://github.com/McPringle/moodini.git
$> cd moodini
$> ./gradlew check

Build successful! Now change Kotlin version in gradle.properties from 1.4.31 to 1.5.0 (line 19) and run check again:

$> ./gradlew check

Build fails:

> Task :jdepsReport FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':jdepsReport'.
> Configuration with name 'runtime' not found.

I know, the configuration names changed in Gradle. But I did not change my Gradle version, just the Kotlin compiler version. I did both runs with Gradle v7.0.1 and jdeps 0.12.0. There is no project-specific jdeps configuration in my build file.

aalmiray commented 3 years ago

Well, the latest version of the plugin does define runtime as the default configuration to be inspected

https://github.com/kordamp/jdeps-gradle-plugin/blob/eb27972e78564f69cd2c230727aa687edbc8feb5/src/main/groovy/org/kordamp/gradle/plugin/jdeps/tasks/JDepsReportTask.groovy#L81

As a workaround you can set the value of configurations to something else.

aalmiray commented 3 years ago

FWIW the plugin should work alright with Gradle 6.x. It's the jump to 7.x that will break it.

aalmiray commented 3 years ago

https://github.com/kordamp/jdeps-gradle-plugin/commit/8e4767622916d63a16ab4ef103a893b75c9f090e

McPringle commented 3 years ago

Crazy: With Gradle 7 and Kotlin 1.4.31 the build is green, with Gradle 7 and Kotlin 1.5.0 the build fails. If the plugin is not compatible with Gradle 7, why did it work the first time? Or did it not work and there is another problem, so the plugin is not getting executed? Just guessing.

If I modify the configuration to use runtimeOnly (new) instead of runtime (old), I get a new failure:

> Resolving dependency configuration 'runtimeOnly' is not allowed as it is defined as 'canBeResolved=false'.
  Instead, a resolvable ('canBeResolved=true') dependency configuration that extends 'runtimeOnly' should be resolved.

Same with implementation, but runtimeClasspath seems to work fine!

aalmiray commented 3 years ago

Ah yes, Gradle 7 tightens up how configurations may be resolved 😓 I'll update the code to use runtimeClasspath in stead of runtimeOnly by default.

Now, why the plugin did not fail with Gradle 7 and Kotlin 1.4.31 but it did with Gradle 7 and Kotlin 1.5.0 is a mystery for me. Gradle compatibility rules no longer make sense to me.

McPringle commented 3 years ago

Anyway, with the temporary solution to set the configuration manually and your fix for the next version of jdeps-gradle-plugin, this issue is fixed.

thank you very much for your help, @aalmiray, I highly appreciate it!