Groovy:General error during canonicalization: Transform org.spockframework.compiler.SpockTransform cannot be run
Describe the bug
Getting ^title during maven compilation after upgrade from 2.3 to 2.4.
Can't locate anything relevant in https://spockframework.org/spock/docs/2.4/release_notes.html#_breaking_changes.
To Reproduce
- https://github.com/pzrep/spock-2.4-canonicalization/pull/2
Expected behavior
tests executed with maven to pass
Actual behavior
compilation breaks
Java version
17, 21, 25
Buildtool version
mvn 3.9.11
What operating system are you using
Linux
Dependencies
groovy 4.0.29
Additional context
From https://github.com/pzrep/spock-2.4-canonicalization/pulls it seems M6 was fine and it broke in M7.
@pzygielo The URL https://github.com/pzrep/spock-2.4-canonicalization/pull/2 is not accessible, it yields a 404.
Can you please add the error message/exception incl stacktrace here.
The URL https://github.com/pzrep/spock-2.4-canonicalization/pull/2 is not accessible, it yields a 404.
My fault. Forgot to make it public. Should be visible now.
Can you please add the error message/exception incl stacktrace here.
Error: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.14.1:testCompile (default-testCompile) on project russel: Compilation failure: Compilation failure:
Error: /home/runner/work/spock-2.4-canonicalization/spock-2.4-canonicalization/russel/src/test-spock/groovy/com/github/pzrep/russel/VoteFilterSpec.groovy:[1,1]
Error: 1. ERROR in /home/runner/work/spock-2.4-canonicalization/spock-2.4-canonicalization/russel/src/test-spock/groovy/com/github/pzrep/russel/VoteFilterSpec.groovy (at line 1)
Error: package com.github.pzrep.russel
Error: ^
Error: Groovy: compiler error: null
Error: /home/runner/work/spock-2.4-canonicalization/spock-2.4-canonicalization/russel/src/test-spock/groovy/com/github/pzrep/russel/VoteFilterSpec.groovy:
Error: 2. ERROR in /home/runner/work/spock-2.4-canonicalization/spock-2.4-canonicalization/russel/src/test-spock/groovy/com/github/pzrep/russel/VoteFilterSpec.groovy (at line 0)
Error: package com.github.pzrep.russel
Error: ^
Error: [ERROR] Groovy:General error during canonicalization: Transform org.spockframework.compiler.SpockTransform cannot be run
Error: [ERROR] Found 2 errors and 0 warnings.
Error: -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.14.1:testCompile (default-testCompile) on project russel: Compilation failure
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:333)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:569)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:255)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:201)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:361)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:314)
Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
at org.apache.maven.plugin.compiler.AbstractCompilerMojo.executeReal (AbstractCompilerMojo.java:1318)
at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute (AbstractCompilerMojo.java:708)
at org.apache.maven.plugin.compiler.TestCompilerMojo.execute (TestCompilerMojo.java:208)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:126)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:328)
at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)
at org.apache.maven.lifecycle.internal.MojoExecutor.access$000 (MojoExecutor.java:75)
at org.apache.maven.lifecycle.internal.MojoExecutor$1.run (MojoExecutor.java:162)
at org.apache.maven.plugin.DefaultMojosExecutionStrategy.execute (DefaultMojosExecutionStrategy.java:39)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:159)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:105)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:73)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build (SingleThreadedBuilder.java:53)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:118)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:261)
at org.apache.maven.DefaultMaven.doExecute (DefaultMaven.java:173)
at org.apache.maven.DefaultMaven.execute (DefaultMaven.java:101)
at org.apache.maven.cli.MavenCli.execute (MavenCli.java:906)
at org.apache.maven.cli.MavenCli.doMain (MavenCli.java:283)
at org.apache.maven.cli.MavenCli.main (MavenCli.java:206)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:77)
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke (Method.java:569)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced (Launcher.java:255)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch (Launcher.java:201)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode (Launcher.java:361)
at org.codehaus.plexus.classworlds.launcher.Launcher.main (Launcher.java:314)
The used Groovy from probably Groovy-Eclipse Compiler returns an empty String from groovy.lang.GroovySystem.getVersion() because the version parsing in the class org.codehaus.groovy.util.ReleaseInfo does not find the META-INF/groovy-release-info.properties file on the groovy compiler classpath. But I am not sure where the Groovy here comes from in the build setup.
The Spock version 2.4 uses the GroovySystem.getVersion() now during startup (class initialization), which does now fail to parse the empty Groovy version, which leads to the ExceptionInInitializerError. This was changed in #2208.
We could make the version parsing in Spock more robust by accepting the "" String,
but without the correct GroovyVersion from groovy.lang.GroovySystem.getVersion(), there will be more failures down the line due to version switches required for different Groovy versions. So a more robust version parsing will not fix the issue here, because we can't know which Groovy version is used.
@pzygielo so IMHO you need to open up a issue probably at the Groovy-Eclipse Compiler, that the groovy.lang.GroovySystem.getVersion() does return a correct Groovy version.
The PR #2285 makes the version parsing more robust, but will not fix the issue here, because it will assume that the used Groovy version is Groovy 4.
@AndreasTu - thanks for checking and for the details from your investigation.
Now that you found and shown so much - I can see for myself that Groovy's ReleaseInfo.RELEASE_INFO is not populated indeed. And with required property set "manually" - everything that comes next works fine.
- https://lists.apache.org/thread/1123lp6jx6n6g9njm65807d9rrf0rk2h
@kriegaex - thanks for checking maven-users list. Here is the case on Spock side.
I noticed that groovy-eclipse-batch seems to be an uber JAR containing some upstream core Groovy classes, but missing META-INF/groovy-release-info.properties. After I had copied the corresponding file from groovy-4.0.29.jar, patching the GrEclipse batch compiler JAR, compilation succeeded ~~, but now tests are no longer executing as of 2.4-M7 with TestEngine with ID 'spock' failed to discover tests~~:
~~@pzygielo, do you see the same problem if you try that, or is that just a quirk in my old sample project? In either case,~~ it probably makes sense to raise an issue at the GrEclipse project, mentioning the missing resource file.
@pzygielo, good news: The follow-up problem mentioned above originated in some junk in my build directory, and I had to call the clean Maven target. Adding the resource file to the groovy-eclipse-batch actually did the trick. I am going to create a GrEclipse issue.
- Alexander, thank you for sharing additional findings and raising groovy/groovy-eclipse#1648. 🎉
Is be fixed by the new version of the Eclipse-Groovy-Compiler.
Thank you All.
I confirm that with new (4.0.29-02) groovy-eclipse-batch Spock upgraded to 2.4 works perfectly fine.
:tada: