You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is problematic to compile project with Spock 2.0-groovy-3.0 and Groovy 4.0.0 in IDEA when compilation is done by IDEA (in a Maven project or a Gradle project with "build and run" switched to Idea (instead of Gradle).
and import it in IDEA (tested with 2021.2.3) as a Maven.
(or as a Gradle project with changed "Build and run" from "Gradle" to "IntelliJ IDEA" in File | Settings | Build, Execution, Deployment | Build Tools | Gradle).
Try to build (CTRL-F9).
Expected behavior
Project compiles fine (or at least an error about incompatible Spock and Groovy version is emitted, which is possible to override with -Dspock.iKnowWhatImDoing.disableGroovyVersionCheck).
Actual behavior
Build (compilation) fails with:
Groovyc: While compiling [tests of spock2-groovy4-gradle.test]: Could not instantiate global transform class org.spockframework.compiler.SpockTransform specified at jar:file:/home/foobar/.m2/repository/org/spockframework/spock-core/2.0-groovy-3.0/spock-core-2.0-groovy-3.0.jar!/META-INF/services/org.codehaus.groovy.transform.ASTTransformation because of exception java.lang.NullPointerException
With a newer Java version the exception (NPE) is more verbose:
Groovyc: While compiling [tests of spock2-groovy4-gradle.test]: Could not instantiate global transform class org.spockframework.compiler.SpockTransform specified at jar:file:/home/foobar/.m2/repository/org/spockframework/spock-core/2.0-groovy-3.0/spock-core-2.0-groovy-3.0.jar!/META-INF/services/org.codehaus.groovy.transform.ASTTransformation because of exception java.lang.NullPointerException: Cannot invoke "java.net.URL.toString()" because the return value of "java.security.CodeSource.getLocation()" is null
Java version
Tested with 11, 15, 17.
Buildtool version
Gradle 7.3, Idea 2021.2.3.
What operating system are you using
Linux
Dependencies
spock-2.0-groovy-3.0
groovy-4.0.0
Additional context
I'm not sure where the problem is located, because the compilation:
works with Groovy 3.x (also in Idea) - problem with Groovy 4?
works with Gradle (natively and when Gradle build project inside Idea) - problem with IDEA?
works with Maven (natively) - problem with IDEA?
Spock uses that method as follow:
public class GroovyReleaseInfo {
public static VersionNumber getVersion() {
return VersionNumber.parse(ReleaseInfo.getVersion());
}
public static String getArtifactPath() {
return GroovyObject.class.getProtectionDomain().getCodeSource().getLocation().toString();
}
}
The IDEA could be problematic to return null as location, but it works fine with Groovy 3... Any hints?
The text was updated successfully, but these errors were encountered:
Describe the bug
It is problematic to compile project with Spock 2.0-groovy-3.0 and Groovy 4.0.0 in IDEA when compilation is done by IDEA (in a Maven project or a Gradle project with "build and run" switched to Idea (instead of Gradle).
To Reproduce
Download a sample Spock 2.0 + Groovy 4.0 project (from my blog post):
https://github.com/szpak/code-examples-and-poc/tree/master/spock2-groovy4-gradle-maven
and import it in IDEA (tested with 2021.2.3) as a Maven.
(or as a Gradle project with changed "Build and run" from "Gradle" to "IntelliJ IDEA" in File | Settings | Build, Execution, Deployment | Build Tools | Gradle).
Try to build (CTRL-F9).
Expected behavior
Project compiles fine (or at least an error about incompatible Spock and Groovy version is emitted, which is possible to override with
-Dspock.iKnowWhatImDoing.disableGroovyVersionCheck
).Actual behavior
Build (compilation) fails with:
With a newer Java version the exception (NPE) is more verbose:
Java version
Tested with 11, 15, 17.
Buildtool version
Gradle 7.3, Idea 2021.2.3.
What operating system are you using
Linux
Dependencies
spock-2.0-groovy-3.0
groovy-4.0.0
Additional context
I'm not sure where the problem is located, because the compilation:
Spock uses that method as follow:
The IDEA could be problematic to return
null
as location, but it works fine with Groovy 3... Any hints?The text was updated successfully, but these errors were encountered: