Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Gradle to version 8.5 fails #977

Closed
matsev opened this issue Jan 8, 2024 · 10 comments
Closed

Upgrade Gradle to version 8.5 fails #977

matsev opened this issue Jan 8, 2024 · 10 comments

Comments

@matsev
Copy link

matsev commented Jan 8, 2024

What happened?

Upgrading Gradle wrapper to version 8.5 does not currently work:

./gradlew wrapper --gradle-version 8.5

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/mseverson/Projects/palantir/palantir-java-format/gradle-palantir-java-format/build.gradle' line: 27

* What went wrong:
A problem occurred evaluating project ':gradle-palantir-java-format'.
> Adding a Configuration as a dependency is no longer allowed as of Gradle 8.0.

This is documented in the Configurations no longer allowed as Dependencies in the Gradle user guide:

Adding a Configuration as a dependency in the dependencies DSL block, or programmatically using the DependencyHandler classes' doAdd(Configuration, Object, Closure) method, is no longer allowed and will fail with an exception. To replicate many aspects of this behavior, extend configurations using the extendsFrom(Configuration) method on Configuration instead.

What did you want to happen?

Upgrading Gradle wrapper should work

Why this is relevant

The Gradle Compatibility Matrix states that:

  • Gradle version 8.4 is required for compiling and testing Java 21 projects
  • Gradle version 8.5 is required for running Gradle on Java 21 JVM

Consequently, upgrading Gradle is a blocker for Java 21 related tickets, e.g. #931, #933, #934, #952, #966

@koppor
Copy link
Contributor

koppor commented Jan 9, 2024

A workaround is to use Gradle's toolchain feature, which relatively simple to implement: #978 - and enables parallel work on an update of Gradle and working on Java 21 related issues.

@matsev
Copy link
Author

matsev commented Jan 9, 2024

@koppor I just tried to build locally using the Gradle toolchain config that is currently provided in #978. Regrettably my build fails with a similar stack trace as the one triggered on the build server:

> Task :palantir-java-format-spi:compileJava FAILED
error: An unhandled exception was thrown by the Error Prone static analysis plugin.
     Please report this at https://github.com/google/error-prone/issues/new and include the following:
  
     error-prone version: 2.19.1
     BugPattern: (see stack trace)
     Stack Trace:
     java.lang.NoSuchMethodError: 'com.sun.tools.javac.tree.JCTree$JCExpression com.sun.tools.javac.tree.TreeMaker.Select(com.sun.tools.javac.tree.JCTree$JCExpression, com.sun.tools.javac.code.Symbol)'
        at org.checkerframework.errorprone.javacutil.trees.TreeBuilder.buildValueOfMethodAccess(TreeBuilder.java:392)
        at org.checkerframework.errorprone.dataflow.cfg.builder.CFGTranslationPhaseOne.box(CFGTranslationPhaseOne.java:872)
        at org.checkerframework.errorprone.dataflow.cfg.builder.CFGTranslationPhaseOne.commonConvert(CFGTranslationPhaseOne.java:1187)
        at org.checkerframework.errorprone.dataflow.cfg.builder.CFGTranslationPhaseOne.methodInvocationConvert(CFGTranslationPhaseOne.java:1232)
        at org.checkerframework.errorprone.dataflow.cfg.builder.CFGTranslationPhaseOne.convertCallArguments(CFGTranslationPhaseOne.java:1310)
        at org.checkerframework.errorprone.dataflow.cfg.builder.CFGTranslationPhaseOne.visitMethodInvocation(CFGTranslationPhaseOne.java:1453)
        at org.checkerframework.errorprone.dataflow.cfg.builder.CFGTranslationPhaseOne.visitMethodInvocation(CFGTranslationPhaseOne.java:198)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodInvocation.accept(JCTree.java:1832)
        at org.checkerframework.errorprone.dataflow.cfg.builder.CFGTranslationPhaseOne.scan(CFGTranslationPhaseOne.java:550)
        at org.checkerframework.errorprone.dataflow.cfg.builder.CFGTranslationPhaseOne.convertCallArguments(CFGTranslationPhaseOne.java:1309)
        at org.checkerframework.errorprone.dataflow.cfg.builder.CFGTranslationPhaseOne.visitNewClass(CFGTranslationPhaseOne.java:3338)
        at org.checkerframework.errorprone.dataflow.cfg.builder.CFGTranslationPhaseOne.visitNewClass(CFGTranslationPhaseOne.java:198)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCNewClass.accept(JCTree.java:1893)
        at org.checkerframework.errorprone.dataflow.cfg.builder.CFGTranslationPhaseOne.scan(CFGTranslationPhaseOne.java:550)
        at org.checkerframework.errorprone.dataflow.cfg.builder.CFGTranslationPhaseOne.visitReturn(CFGTranslationPhaseOne.java:3385)
        at org.checkerframework.errorprone.dataflow.cfg.builder.CFGTranslationPhaseOne.visitReturn(CFGTranslationPhaseOne.java:198)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCReturn.accept(JCTree.java:1736)
        at org.checkerframework.errorprone.dataflow.cfg.builder.CFGTranslationPhaseOne.scan(CFGTranslationPhaseOne.java:550)
        at org.checkerframework.errorprone.dataflow.cfg.builder.CFGTranslationPhaseOne.visitBlock(CFGTranslationPhaseOne.java:2218)
        at org.checkerframework.errorprone.dataflow.cfg.builder.CFGTranslationPhaseOne.visitBlock(CFGTranslationPhaseOne.java:198)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1104)
        at org.checkerframework.errorprone.dataflow.cfg.builder.CFGTranslationPhaseOne.scan(CFGTranslationPhaseOne.java:550)
        at org.checkerframework.errorprone.dataflow.cfg.builder.CFGTranslationPhaseOne.process(CFGTranslationPhaseOne.java:447)
        at org.checkerframework.errorprone.dataflow.cfg.builder.CFGTranslationPhaseOne.process(CFGTranslationPhaseOne.java:498)
        at org.checkerframework.errorprone.dataflow.cfg.builder.CFGBuilder.build(CFGBuilder.java:73)
        at com.google.errorprone.dataflow.DataFlow$2.load(DataFlow.java:125)
        at com.google.errorprone.dataflow.DataFlow$2.load(DataFlow.java:93)
        at com.github.benmanes.caffeine.cache.LocalLoadingCache.lambda$newMappingFunction$3(LocalLoadingCache.java:183)
        at com.github.benmanes.caffeine.cache.BoundedLocalCache.lambda$doComputeIfAbsent$14(BoundedLocalCache.java:2688)
        at java.base/java.util.concurrent.ConcurrentHashMap.compute(ConcurrentHashMap.java:1916)
        at com.github.benmanes.caffeine.cache.BoundedLocalCache.doComputeIfAbsent(BoundedLocalCache.java:2686)
        at com.github.benmanes.caffeine.cache.BoundedLocalCache.computeIfAbsent(BoundedLocalCache.java:2669)
        at com.github.benmanes.caffeine.cache.LocalCache.computeIfAbsent(LocalCache.java:112)
        at com.github.benmanes.caffeine.cache.LocalLoadingCache.get(LocalLoadingCache.java:58)
        at com.google.errorprone.dataflow.DataFlow.methodDataflow(DataFlow.java:172)
        at com.google.errorprone.dataflow.DataFlow.expressionDataflow(DataFlow.java:229)
        at com.palantir.baseline.errorprone.safety.SafetyAnalysis.of(SafetyAnalysis.java:35)
        at com.palantir.baseline.errorprone.SafeLoggingPropagation$ReturnStatementSafetyScanner.visitReturn(SafeLoggingPropagation.java:364)
        at com.palantir.baseline.errorprone.SafeLoggingPropagation$ReturnStatementSafetyScanner.visitReturn(SafeLoggingPropagation.java:347)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCReturn.accept(JCTree.java:1736)
        at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:92)
        at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:96)
        at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:111)
        at jdk.compiler/com.sun.source.util.TreeScanner.visitBlock(TreeScanner.java:272)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCBlock.accept(JCTree.java:1104)
        at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:92)
        at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:96)
        at jdk.compiler/com.sun.source.util.TreeScanner.visitMethod(TreeScanner.java:224)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:948)
        at com.palantir.baseline.errorprone.SafeLoggingPropagation.matchMethod(SafeLoggingPropagation.java:340)
        at com.google.errorprone.scanner.ErrorProneScanner.processMatchers(ErrorProneScanner.java:449)
        at com.google.errorprone.scanner.ErrorProneScanner.visitMethod(ErrorProneScanner.java:739)
        at com.google.errorprone.scanner.ErrorProneScanner.visitMethod(ErrorProneScanner.java:150)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCMethodDecl.accept(JCTree.java:948)
        at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:92)
        at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
        at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
        at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:111)
        at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:119)
        at jdk.compiler/com.sun.source.util.TreeScanner.visitClass(TreeScanner.java:203)
        at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:548)
        at com.google.errorprone.scanner.ErrorProneScanner.visitClass(ErrorProneScanner.java:150)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:855)
        at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:92)
        at com.google.errorprone.scanner.Scanner.scan(Scanner.java:74)
        at com.google.errorprone.scanner.Scanner.scan(Scanner.java:48)
        at jdk.compiler/com.sun.source.util.TreeScanner.scan(TreeScanner.java:111)
        at jdk.compiler/com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:119)
        at jdk.compiler/com.sun.source.util.TreeScanner.visitCompilationUnit(TreeScanner.java:152)
        at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:560)
        at com.google.errorprone.scanner.ErrorProneScanner.visitCompilationUnit(ErrorProneScanner.java:150)
        at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:623)
        at jdk.compiler/com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:66)
        at com.google.errorprone.scanner.Scanner.scan(Scanner.java:58)
        at com.google.errorprone.scanner.ErrorProneScannerTransformer.apply(ErrorProneScannerTransformer.java:43)
        at com.google.errorprone.ErrorProneAnalyzer.finished(ErrorProneAnalyzer.java:156)
        at jdk.compiler/com.sun.tools.javac.api.MultiTaskListener.finished(MultiTaskListener.java:133)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1436)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.flow(JavaCompiler.java:1383)
        at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:963)
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:104)
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.invocationHelper(JavacTaskImpl.java:152)
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:100)
        at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:94)
        at org.gradle.internal.compiler.java.IncrementalCompileTask.call(IncrementalCompileTask.java:92)
        at org.gradle.api.internal.tasks.compile.AnnotationProcessingCompileTask.call(AnnotationProcessingCompileTask.java:94)
        at org.gradle.api.internal.tasks.compile.ResourceCleaningCompilationTask.call(ResourceCleaningCompilationTask.java:57)
        at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:55)
        at org.gradle.api.internal.tasks.compile.JdkJavaCompiler.execute(JdkJavaCompiler.java:39)
        at org.gradle.api.internal.tasks.compile.daemon.AbstractDaemonCompiler$CompilerWorkAction.execute(AbstractDaemonCompiler.java:135)
        at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)
        at org.gradle.workers.internal.AbstractClassLoaderWorker$1.create(AbstractClassLoaderWorker.java:49)
        at org.gradle.workers.internal.AbstractClassLoaderWorker$1.create(AbstractClassLoaderWorker.java:43)
        at org.gradle.internal.classloader.ClassLoaderUtils.executeInClassloader(ClassLoaderUtils.java:100)
        at org.gradle.workers.internal.AbstractClassLoaderWorker.executeInClassLoader(AbstractClassLoaderWorker.java:43)
        at org.gradle.workers.internal.FlatClassLoaderWorker.run(FlatClassLoaderWorker.java:32)
        at org.gradle.workers.internal.FlatClassLoaderWorker.run(FlatClassLoaderWorker.java:22)
        at org.gradle.workers.internal.WorkerDaemonServer.run(WorkerDaemonServer.java:87)
        at org.gradle.workers.internal.WorkerDaemonServer.run(WorkerDaemonServer.java:56)
        at org.gradle.process.internal.worker.request.WorkerAction$1.call(WorkerAction.java:138)
        at org.gradle.process.internal.worker.child.WorkerLogEventListener.withWorkerLoggingProtocol(WorkerLogEventListener.java:41)
        at org.gradle.process.internal.worker.request.WorkerAction.run(WorkerAction.java:135)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
        at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:182)
        at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:164)
        at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:414)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
        at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:49)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
        at java.base/java.lang.Thread.run(Thread.java:1583)
1 error

FAILURE: Build failed with an exception.

@koppor
Copy link
Contributor

koppor commented Jan 9, 2024

@matsev Thank you for investigating. Had the same issue, but I forgot to mention 🙈.

I tried to remove error prone from the build, but did not find "errorprone" in the build files. Maybe, it is injected from some upstream palantir projects? -- While quickly checking, I found palantir/gradle-baseline#2651, thus, it shoujld be "easy" to do an error prone update?

@matsev
Copy link
Author

matsev commented Jan 10, 2024

@koppor I am sorry, I don't know how errorprone is used in this project or whether or not it is up for removal.

@carterkozak
Copy link
Contributor

Are you still seeing issues with the latest errorprone version on the develop branch of this repo?

Errorprone can be temporarily disabled using:

allprojects {
    pluginManager.withPlugin('java') {
        tasks.withType(JavaCompile) {
            options.errorprone {
                enabled = false
            }
        }
    }
}

@koppor
Copy link
Contributor

koppor commented Jan 12, 2024

Thank you for the hint! I tried it, and now I got stuck at

error: exporting a package from system module jdk.compiler is not allowed with --release

I think, the export is needed. As it is not possible to disable the --release flag in Gradle 7.x (at least to the results of my experiments today), this was a dead end. Sorry for the noise!

@mandrean
Copy link

@matsev thoughts? #1011

@koppor
Copy link
Contributor

koppor commented Mar 7, 2024

Details were provided at #997. As far as I understood, we need to wait for the release of 2.0 of the IntelliJ gradle plugin. https://github.com/JetBrains/gradle-intellij-plugin/milestone/85

@koppor
Copy link
Contributor

koppor commented Jul 13, 2024

According to #1011 (comment), #1028 got merged.

According to

distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
, gradle 8.8 is used.

Thus, this ticket can be closed, can't it?

@matsev
Copy link
Author

matsev commented Jul 13, 2024

👍 closing. I checked out bf9e642 (which is the current version of the develop branch, based on the #1103 pr). Executing the Gradle wrapper confirms that version 8.8 is used:

./gradlew -v

------------------------------------------------------------
Gradle 8.8
------------------------------------------------------------

Build time:   2024-05-31 21:46:56 UTC
Revision:     4bd1b3d3fc3f31db5a26eecb416a165b8cc36082

Kotlin:       1.9.22
Groovy:       3.0.21
Ant:          Apache Ant(TM) version 1.10.13 compiled on January 4 2023
JVM:          17.0.1 (Eclipse Adoptium 17.0.1+12)
OS:           Mac OS X 11.4 x86_64

@matsev matsev closed this as completed Jul 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants