spock
spock copied to clipboard
Don't include groovy-all as a compile dependency
spock-core has a compile-scoped dependency on groovy-all. I'm using the indy package for 2.4.3, but including Spock pulls in groovy-all:2.3, which breaks the runtime classpath. Instead, I suggest making the dependency provided.
+1
+1 I have to do this for every project that I include spock in, as it's always not quite the correct version. Anyone using spock will need a groovy dep anyway...
:+1: This could make for cleaner build files for projects that use Spock.
It looks like this is a common thing. A quick and incomplete survey of some projects using spock that exclude groovy-all:
- netflix nebula gradle plugins
- betamax
- geb
- ratpack
- gpars
- grails
- groovy-wslite
- groovy-core
This issue is still open for debate, as it will possibly break the builds of 'simple' users of spock, i.e., users that only use spock+groovy for testing, since they would need an explicit dependency on groovy.
@leonard84 , what do you think if the dependency is published as <scope>runtime</scope>?
runtime is transitive.
runtimeThis scope indicates that the dependency is not required for compilation, but is for execution. It is in the runtime and test classpaths, but not the compile classpath.
Then end-users don't have to to include groovy-all explicitly, however they would be protected from accidental use of groovy classes at compilation time.
If you use java-library plugin from Gradle, then implementation dependency is the one that produces the desired result.
Here's an example: https://github.com/apache/jmeter/blob/7556991464f6e5aa214889fbf22be00e8d929083/src/core/build.gradle.kts#L68-L75
Resulting POM file: https://repository.apache.org/content/repositories/snapshots/org/apache/jmeter/ApacheJMeter_core/5.2.0-SNAPSHOT/ApacheJMeter_core-5.2.0-20190806.021509-4.pom
In other words, implementation("commons-collections:commons-collections") is transformed to
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.2</version>
<scope>runtime</scope>
</dependency>