New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spock overrides Groovy version in Maven #892

Open
chrylis opened this Issue Sep 3, 2018 · 9 comments

Comments

Projects
None yet
4 participants
@chrylis

chrylis commented Sep 3, 2018

After the conversion of groovy-all to a pom-type dependency, Spock's POM (1.2-RC2-groovy-2.5) has added specific dependencies on several Groovy artifacts to spock-core. However, the version is specified as exactly 2.5.0, and this overrides any newer version set on the including project (absent active redeclarations, version ranges, and further shenanigans).

I'm not sure what the cleanest way to import all of this is, but I think that either or both of using a property named groovy.version for all of the dependencies (which is what most projects use already, so should override) or using [2.5.0,2.6.0) as a version in the Spock POM should resolve the problem.

@leonard84

This comment has been minimized.

Show comment
Hide comment
@leonard84

leonard84 Sep 4, 2018

Member

Version ranges are the bane of reproducible builds.

It is unfortunate, that gradle still does not support something like mavens depdendencyManagement.

You could try https://github.com/spring-gradle-plugins/dependency-management-plugin

Related #71

Member

leonard84 commented Sep 4, 2018

Version ranges are the bane of reproducible builds.

It is unfortunate, that gradle still does not support something like mavens depdendencyManagement.

You could try https://github.com/spring-gradle-plugins/dependency-management-plugin

Related #71

@marcphilipp

This comment has been minimized.

Show comment
Hide comment
@marcphilipp

marcphilipp Sep 4, 2018

Member

Gradle provides quite a few mechanisms to override versions of transitive dependencies. Spring's dependency management plugin should not be needed here.

@chrylis Could you please provide a sample project to reproduce the issue?

Member

marcphilipp commented Sep 4, 2018

Gradle provides quite a few mechanisms to override versions of transitive dependencies. Spring's dependency management plugin should not be needed here.

@chrylis Could you please provide a sample project to reproduce the issue?

@szpak

This comment has been minimized.

Show comment
Hide comment
@szpak

szpak Sep 4, 2018

Contributor

@chrylis With 1.2-RC2 it should be aligned to 2.5.2, but you will hit it with any new Groovy version released. As a quick fix you can do something like that:

ext.groovyVersion = "2.4.12"

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        //Spock 1.2-RC1 depends on Groovy 2.5.0 by default - https://github.com/spockframework/spock/pull/881
        if (details.requested.group == 'org.codehaus.groovy' && details.requested.name.startsWith('groovy-')) {
            if (details.requested.version != groovyVersion) {   //Can be omitted, internally Gradle will keep the same version, but mark as modified
                details.useVersion(groovyVersion)
            }
        }
    }
}

I personally also don't like ranges due to mentioned issues with reproducibility.

Contributor

szpak commented Sep 4, 2018

@chrylis With 1.2-RC2 it should be aligned to 2.5.2, but you will hit it with any new Groovy version released. As a quick fix you can do something like that:

ext.groovyVersion = "2.4.12"

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        //Spock 1.2-RC1 depends on Groovy 2.5.0 by default - https://github.com/spockframework/spock/pull/881
        if (details.requested.group == 'org.codehaus.groovy' && details.requested.name.startsWith('groovy-')) {
            if (details.requested.version != groovyVersion) {   //Can be omitted, internally Gradle will keep the same version, but mark as modified
                details.useVersion(groovyVersion)
            }
        }
    }
}

I personally also don't like ranges due to mentioned issues with reproducibility.

@chrylis chrylis changed the title from Spock overrides Groovy version to Spock overrides Groovy version in Maven Sep 5, 2018

@chrylis

This comment has been minimized.

Show comment
Hide comment
@chrylis

chrylis Sep 5, 2018

I'm actually using Maven, not Gradle, and the resolver is picking up the versions from the dependencies in spock-core. The problem is that Spock lists several Groovy modules with explicit inline versions, which causes Maven to immediately fill those versions in when resolving, which "beats" the inclusion of groovy-all by default (I think because Spock is in test scope, which is more specific).

I believe that instead of defining the versions inline simply using ${groovy.version} should make it easy for consumer projects to specify a version without opening up the version-range can of worms.

chrylis commented Sep 5, 2018

I'm actually using Maven, not Gradle, and the resolver is picking up the versions from the dependencies in spock-core. The problem is that Spock lists several Groovy modules with explicit inline versions, which causes Maven to immediately fill those versions in when resolving, which "beats" the inclusion of groovy-all by default (I think because Spock is in test scope, which is more specific).

I believe that instead of defining the versions inline simply using ${groovy.version} should make it easy for consumer projects to specify a version without opening up the version-range can of worms.

@leonard84

This comment has been minimized.

Show comment
Hide comment
@leonard84

leonard84 Sep 5, 2018

Member

Unfortunately groovy currently does not offer a bom, with a bom it would be just:

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-bom</artifactId>
      <version>${groovy-version}</version>
      <scope>import</scope>
    </dependency>
  </dependencies>
</dependencyManagement>

But since there is no bom you'll have to define something like this (these are all groovy dependencies, you can strip many of them since spock doesn't use all):

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-ant</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-cli-commons</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-cli-picocli</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-console</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-datetime</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-docgenerator</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-groovydoc</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-groovysh</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-jmx</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-json</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-jsr223</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-macro</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-nio</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-servlet</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-sql</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-swing</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-templates</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-test</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-test-junit5</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-testng</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-xml</artifactId>
      <version>${groovy-version}</version>
    </dependency>    
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-bsf</artifactId>
      <version>${groovy-version}</version>
    </dependency> 
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-cli-commons</artifactId>
      <version>${groovy-version}</version>
    </dependency> 
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-dateutil</artifactId>
      <version>${groovy-version}</version>
    </dependency> 
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-jaxb</artifactId>
      <version>${groovy-version}</version>
    </dependency>
  </dependencies>
</dependencyManagement>
Member

leonard84 commented Sep 5, 2018

Unfortunately groovy currently does not offer a bom, with a bom it would be just:

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-bom</artifactId>
      <version>${groovy-version}</version>
      <scope>import</scope>
    </dependency>
  </dependencies>
</dependencyManagement>

But since there is no bom you'll have to define something like this (these are all groovy dependencies, you can strip many of them since spock doesn't use all):

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-ant</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-cli-commons</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-cli-picocli</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-console</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-datetime</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-docgenerator</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-groovydoc</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-groovysh</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-jmx</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-json</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-jsr223</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-macro</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-nio</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-servlet</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-sql</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-swing</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-templates</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-test</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-test-junit5</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-testng</artifactId>
      <version>${groovy-version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-xml</artifactId>
      <version>${groovy-version}</version>
    </dependency>    
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-bsf</artifactId>
      <version>${groovy-version}</version>
    </dependency> 
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-cli-commons</artifactId>
      <version>${groovy-version}</version>
    </dependency> 
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-dateutil</artifactId>
      <version>${groovy-version}</version>
    </dependency> 
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-jaxb</artifactId>
      <version>${groovy-version}</version>
    </dependency>
  </dependencies>
</dependencyManagement>
@leonard84

This comment has been minimized.

Show comment
Hide comment
@leonard84

leonard84 Sep 5, 2018

Member

This is the current subset

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy</artifactId>
      <version>${groovy.version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-ant</artifactId>
      <version>${groovy.version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-cli-picocli</artifactId>
      <version>${groovy.version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-console</artifactId>
      <version>${groovy.version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-groovysh</artifactId>
      <version>${groovy.version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-json</artifactId>
      <version>${groovy.version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-macro</artifactId>
      <version>${groovy.version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-nio</artifactId>
      <version>${groovy.version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-sql</artifactId>
      <version>${groovy.version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-test</artifactId>
      <version>${groovy.version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-xml</artifactId>
      <version>${groovy.version}</version>
    </dependency>    
  </dependencies>
</dependencyManagement>
Member

leonard84 commented Sep 5, 2018

This is the current subset

<dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy</artifactId>
      <version>${groovy.version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-ant</artifactId>
      <version>${groovy.version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-cli-picocli</artifactId>
      <version>${groovy.version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-console</artifactId>
      <version>${groovy.version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-groovysh</artifactId>
      <version>${groovy.version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-json</artifactId>
      <version>${groovy.version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-macro</artifactId>
      <version>${groovy.version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-nio</artifactId>
      <version>${groovy.version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-sql</artifactId>
      <version>${groovy.version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-test</artifactId>
      <version>${groovy.version}</version>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-xml</artifactId>
      <version>${groovy.version}</version>
    </dependency>    
  </dependencies>
</dependencyManagement>
@szpak

This comment has been minimized.

Show comment
Hide comment
@szpak

szpak Sep 5, 2018

Contributor

This week I will try to work on #882 to reduce number of transitive dependencies exposed to the public (to make the list somehow shorter). But, it is just a mitigation.

Contributor

szpak commented Sep 5, 2018

This week I will try to work on #882 to reduce number of transitive dependencies exposed to the public (to make the list somehow shorter). But, it is just a mitigation.

@chrylis

This comment has been minimized.

Show comment
Hide comment
@chrylis

chrylis Sep 5, 2018

What I'm seeing in the Spock POM itself is inline 2.5.2 versions. I may be mistaken, but I believe that using ${groovy.version} inline there would allow consumers to override it.

chrylis commented Sep 5, 2018

What I'm seeing in the Spock POM itself is inline 2.5.2 versions. I may be mistaken, but I believe that using ${groovy.version} inline there would allow consumers to override it.

@szpak

This comment has been minimized.

Show comment
Hide comment
@szpak

szpak Sep 5, 2018

Contributor

@chrylis Not really. The exact version is resolved at the Spock build time and placed in the pom.xml file(s) published to Maven Central.

Contributor

szpak commented Sep 5, 2018

@chrylis Not really. The exact version is resolved at the Spock build time and placed in the pom.xml file(s) published to Maven Central.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment