We have the following working line of build script running on Gradle 5.2.1:
version = object {
val value : String by lazy {
VersionBuilderPlugin.versionFromGitTag()
}
override fun toString() : String = value
}
On attempting to run the build on Gradle 6.1.1, we get an error:
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/tester/Documents/gradle-plugins-common/build.gradle.kts' line: 18
* What went wrong:
'void Build_gradle$1.<init>(Build_gradle)'
* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Exception is:
java.lang.NoSuchMethodError: 'void Build_gradle$1.<init>(Build_gradle)'
at Build_gradle.<init>(build.gradle.kts:18)
at Program.execute(Unknown Source)
It’s hard to say without a little more context around the offending line but it does look like a Kotlin compiler bug we have seen recently.
Could you provide more context around the offending line, in particular, if it’s part of a lambda expression and/or there are lambda expressions close to the offending line?
The real version also takes a string parameter, which might be the key difference… once I remove that, it somehow works.
If you need more than that, I’m about 10% of the way towards a standalone repro but there’s a lot of stuff in the build that I still have to fish through.
I at least reduced the surface area of the build script:
import com.acme.gradle.plugins.common.VersionBuilderPlugin
plugins {
`java-gradle-plugin`
}
apply(from = "common-build.gradle.kts")
version = object {
val value : String by lazy {
VersionBuilderPlugin.gitTagVersion(project.getProjectDir().getAbsolutePath())
// VersionBuilderPlugin.gitTagVersion()
}
override fun toString() : String = value
}
Actually so that’s a standalone reproduction now. The only files I have other than the Gradle wrapper is that 6 line build script and a one-line settings.gradle.kts setting the name of the project.