spock icon indicating copy to clipboard operation
spock copied to clipboard

Don't include groovy-all as a compile dependency

Open chrylis opened this issue 10 years ago • 5 comments

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.

chrylis avatar Mar 25 '15 07:03 chrylis

+1

jirutka avatar Mar 25 '15 10:03 jirutka

+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...

tomdcc avatar May 12 '15 03:05 tomdcc

:+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

david-w-millar avatar Jun 22 '15 22:06 david-w-millar

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 avatar Jun 23 '15 09:06 leonard84

@leonard84 , what do you think if the dependency is published as <scope>runtime</scope>? runtime is transitive.

runtime This 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>

vlsi avatar Aug 06 '19 14:08 vlsi