Gradle upgrade 7.2 > 7.3 breaks with "The value for this property is final and cannot be changed any further" (with Micronaut plugin?)
Asked Answered
K

3

5

I'm using Micronaut 3.1.3 together with Gradle 7.2 to build my project.

After switching to Gradle 7.3, built breaks emitting some context-free error message:

$ ./gradlew clean build
Executed by Gradle 7.3
- using Java 11.0.13
- using Kotlin 1.5.31
- using Groovy 3.0.9

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project '[PROJECT]'.
> The value for this property is final and cannot be changed any further.

With --stacktrace a very long trace appears. The following excerpt makes me guess that the problem might lay in the Micronaut plugin:

* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring root project '[PROJECT]'.
        at org.gradle.configuration.project.LifecycleProjectEvaluator.wrapException(LifecycleProjectEvaluator.java:75)
        at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:68)
        at org.gradle.configuration.project.LifecycleProjectEvaluator.access$400(LifecycleProjectEvaluator.java:51)
        [...]
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:61)
Caused by: java.lang.IllegalStateException: The value for this property is final and cannot be changed any further.
        at org.gradle.api.internal.provider.AbstractProperty$FinalizedValue.beforeMutate(AbstractProperty.java:489)
        at org.gradle.api.internal.provider.AbstractProperty.assertCanMutate(AbstractProperty.java:263)
        at org.gradle.api.internal.provider.AbstractProperty.setSupplier(AbstractProperty.java:212)
        at org.gradle.api.internal.provider.DefaultProperty.set(DefaultProperty.java:71)
        at org.gradle.api.tasks.testing.Test.useTestFramework(Test.java:979)
        at org.gradle.api.tasks.testing.Test.useJUnitPlatform(Test.java:1049)
        at org.gradle.api.tasks.testing.Test.useJUnitPlatform(Test.java:1032)
        at io.micronaut.gradle.MicronautLibraryPlugin.lambda$null$1(MicronautLibraryPlugin.java:103)
        at org.gradle.configuration.internal.DefaultUserCodeApplicationContext$CurrentApplication$1.execute(DefaultUserCodeApplicationContext.java:123)
        [...]
        at org.gradle.api.internal.DefaultDomainObjectCollection.withType(DefaultDomainObjectCollection.java:201)
        at io.micronaut.gradle.MicronautLibraryPlugin.lambda$apply$4(MicronautLibraryPlugin.java:101)
        at org.gradle.configuration.internal.DefaultUserCodeApplicationContext$CurrentApplication$1.execute(DefaultUserCodeApplicationContext.java:123)
        [...]
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:61)

Cause "problem occurred configuring root project" I'm not sure which part of my build.gradle raises the problem. So following my first guess regarding Micronaut plugin, here is an excerpt telling you the list of plugins in use and config of this plugin:

plugins {
  id('org.jetbrains.kotlin.jvm') version "${kotlinVersion}"
  id('groovy')
  id('org.jetbrains.kotlin.kapt') version "${kotlinVersion}"
  id('com.github.johnrengelman.shadow') version '7.+'
  id('io.micronaut.application') version '2.+'
  id('org.jetbrains.kotlin.plugin.allopen') version "${kotlinVersion}"
  id('com.google.cloud.tools.jib') version '3.+'
  id('org.openapi.generator') version '5.+'
  id('com.heroku.sdk.heroku-gradle') version '2.+'
}

[...]

micronaut {
  runtime('netty')
  testRuntime('spock2')
  processing {
    incremental(true)
    annotations('[PACKAGE]')
  }
}

Maybe this gives enough information to tackle down the cause of the problem? If not please let me know.

Regards

Knockout answered 12/11, 2021 at 8:30 Comment(6)
We're not DE-CIX customer support department and the question doesn't tell why Gradle 7.3 would even be required to build with. I reads: MicronautLibraryPlugin.java:103 tried to change a final value, which is verboten... trying moving that block above the java block; if it won't crash the other way around that may work. Or just just downgrade back to 7.2, problem solved.Drizzle
Hi Martin, not sure if I get your comment right, but to me it sounds like * support only certain colleagues, * if a 3rd-party upgrade breaks, stick with what has worked in the past (regardless of the reason/source of problem). * Not sure what you recommend regarding movement of blocks: Which block to move above which other block?Knockout
@Knockout I totally agree. Your want to know why the update breaks the build, so downgrading is not an answer here. Have you tried removing the Micronaut plugin? Does that still throw an error?Mcpeak
This is being worked on, see github.com/micronaut-projects/micronaut-gradle-plugin/issues/…Trinhtrini
@Knockout You did not provide the least reason, why you even build with Gradle 7.3, therefore I'd not bother to support this in any way - this has nothing to do with Spezlwirtschaft... you could have searched or filed on issue on GitHub right away - common sense may suggest, that it's the responsibility of the author.Drizzle
@JustInCoding Sole removal of micronaut block shown in the code excerpt vanishes mentioned error (but, of course, breaks the build in other regards, e.g. because of missing Spock lib in class path). @BurtBeckwith Thanks for the link. Error message cited there gives more details regarding possible root cause than my setup does.Knockout
D
3

I hit the same issue with my Java build and asked for help on gradle slack channel. It found to be a change in Gradle 7.3 behavior.

This issue contains an explanation of the cause and how to fix it. It helped me to solve the issue with my build: I had options defined in one of the test tasks and then useJUnitPlatform was applied across all test tasks afterwards using this snippet:

tasks.withType(Test).configureEach {
  useJUnitPlatform()    // <-- this line was breaking the build
}

This broke the build after migrating to Gradle 7.3. Removing options solved the problem for me.

Here's an issue requesting to convert this breaking behavior to a warning in Gradle 7.3 and make it a breaking change in 8.0.

Davies answered 19/11, 2021 at 18:2 Comment(2)
@Jeremy, @Davies Thanks for links and explanations. As my build.gradle does not create/touch Test targets explicitly, it seems that Micronaut plugin has to get adjusted accordingly.Knockout
As explained at github.com/gradle/gradle/issues/23544, starting with Gradle 8 the actual solution is to remove useJUnitPlatform() (as that's the default now, and keeping it causes problems even if you don't use options).Pubescent
E
2

This issue of micronuat build failing with Gradle 7.3 version has been fixed by Gradle team in Gradle 7.3.1 release . Here is the issue raised for the same (which is now fixed) and here is the changelog of Gradle 7.3.1 mentioning the same.

Solution: Not to use the Gradle 7.3 version, instead upgrade to Gradle 7.3.1 release or higher.

Eschar answered 23/3, 2023 at 7:23 Comment(0)
K
1

FYI: Upgrade to Gradle 7.3.1 brings back successful builds.

Knockout answered 2/12, 2021 at 7:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.