gpt4 book ai didi

Gradle 升级 7.2 > 7.3 使用 "The value for this property is final and cannot be changed any further"中断(使用 Micronaut 插件?)

转载 作者:行者123 更新时间:2023-12-04 17:08:45 25 4
gpt4 key购买 nike

我正在使用 Micronaut 3.1.3 和 Gradle 7.2 来构建我的项目。

切换到 Gradle 7.3 后,构建中断发出一些上下文无关的错误消息:

$ ./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.

使用 --stacktrace 会出现很长的跟踪。以下摘录让我猜测问题可能出在 Micronaut 插件上:

* 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)

原因“配置根项目时出现问题”我不确定我的哪一部分build.gradle 引发了这个问题。所以按照我对 Micronaut 的第一个猜测插件,这里是一个摘录,告诉你正在使用的插件列表和这个插件的配置:

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]')
}
}

也许这提供了足够的信息来解决问题的原因?如果没有,请告诉我。

问候

最佳答案

我在构建 Java 时遇到了同样的问题,并在 gradle slack channel 上寻求帮助。它被发现是 Gradle 7.3 行为的变化。

This issue contains an explanation of the cause以及如何修复它。它帮助我解决了我的构建问题:我在其中一个测试任务中定义了 options,然后使用此代码段将 useJUnitPlatform 应用于所有测试任务:

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

这在迁移到 Gradle 7.3 后破坏了构建。删除 options 解决了我的问题。

这是 an issue requesting to convert this breaking behavior to a warning在 Gradle 7.3 中并使其成为 8.0 中的重大更改。

关于Gradle 升级 7.2 > 7.3 使用 "The value for this property is final and cannot be changed any further"中断(使用 Micronaut 插件?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69939935/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com