Is your feature request related to a problem?
Currently, a build (compilation) with incompatible Spock and Groovy version fails in IDEA 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
It holds also with spock-2.0-groovy-2.5 and Groovy 3.0. The problem is no location returned for CodeSource in:
|
public class GroovyReleaseInfo { |
|
public static VersionNumber getVersion() { |
|
return VersionNumber.parse(ReleaseInfo.getVersion()); |
|
} |
|
|
|
public static String getArtifactPath() { |
|
return GroovyObject.class.getProtectionDomain().getCodeSource().getLocation().toString(); |
|
} |
Describe the solution you'd like
Some of:
- Explain why Idea do that and report a bug.
- Find a "better" way to get JAR location.
- Be more resilient to the unexpected exceptions to show the intended error message about incompatibilities (even in a reduced form) instead of NPE.
Describe alternatives you've considered
No response
Additional context
The problem seems to occur only in IDEA with Maven projects and Gradle projects with "build and run" switched to Idea (instead of Gradle).
Is your feature request related to a problem?
Currently, a build (compilation) with incompatible Spock and Groovy version fails in IDEA with:
With a newer Java version the exception (NPE) is more verbose:
It holds also with spock-2.0-groovy-2.5 and Groovy 3.0. The problem is no location returned for CodeSource in:
spock/spock-core/src/main/java/org/spockframework/util/GroovyReleaseInfo.java
Lines 20 to 27 in d222bd2
Describe the solution you'd like
Some of:
Describe alternatives you've considered
No response
Additional context
The problem seems to occur only in IDEA with Maven projects and Gradle projects with "build and run" switched to Idea (instead of Gradle).