ben-manes / gradle-versions-plugin

Gradle plugin to discover dependency updates
Apache License 2.0
3.86k stars 199 forks source link

Failed to resolve junit-pioneer snapshot 0.1 #239

Closed Siedlerchr closed 6 years ago

Siedlerchr commented 6 years ago

Hi,

I was checking build log of our app, and noticed that several dependenices did not resolve, I added the log here and you can see the build.gradle there, too. https://github.com/JabRef/jabref/pull/4131 When I removed our resolution strategy code to determine the failure I get the error about junit-pioneer:

I looked at the documentation and only found a way to exclude versions from the the dependencies, but not to include 0.1 snapshot for only a lib. And the repo is correctly added. https://github.com/junit-pioneer/junit-pioneer#getting-on-board

Failed to determine the latest version for the following dependencies (use --info for details):
 - org.junit-pioneer:junit-pioneer
The exception that is the cause of unresolved state: Could not find any version that matches org.junit-pioneer:junit-pioneer:+.
Versions rejected by component selection rules:
  - 1.0-SNAPSHOT
  - 0.1-SNAPSHOT
Searched in the following locations:
  - https://jcenter.bintray.com/org/junit-pioneer/junit-pioneer/maven-metadata.xml
  - https://jcenter.bintray.com/org/junit-pioneer/junit-pioneer/
  - file:/C:/Users/CS/.m2/repository/org/junit-pioneer/junit-pioneer/maven-metadata.xml
  - file:/C:/Users/CS/.m2/repository/org/junit-pioneer/junit-pioneer/
  - https://jcenter.bintray.com/org/junit-pioneer/junit-pioneer/maven-metadata.xml
  - https://jcenter.bintray.com/org/junit-pioneer/junit-pioneer/
  - https://oss.sonatype.org/content/groups/public/org/junit-pioneer/junit-pioneer/maven-metadata.xml
Failed to resolve issues:

Failed to resolve ::annotationProcessor
Failed to resolve ::jmhImplementation
Failed to resolve ::jmhRuntime
Failed to resolve ::jmhRuntimeClasspath
Failed to resolve ::jmhRuntimeOnly
Failed to resolve ::jython
Failed to resolve ::runtime
Failed to resolve ::runtimeClasspath
Failed to resolve ::runtimeElements
Failed to resolve ::runtimeOnly
Failed to resolve ::shadow
Failed to resolve ::testAnnotationProcessor
Failed to resolve ::testCompile
Failed to resolve ::testCompileClasspath
Failed to resolve ::testCompileOnly
Failed to resolve ::apiElements
Failed to resolve ::archives
Failed to resolve ::testImplementation
Failed to resolve ::checkstyle
Failed to resolve ::testRuntime
Failed to resolve ::testRuntimeClasspath
Failed to resolve ::testRuntimeOnly
Failed to resolve ::xjc
Failed to resolve ::compile
Failed to resolve ::compileClasspath
Failed to resolve ::compileOnly
Failed to resolve ::classpath
Failed to resolve ::default
Failed to resolve ::errorprone
Failed to resolve ::implementation
Failed to resolve ::jacocoAgent
Failed to resolve ::jacocoAnt
Failed to resolve ::jmh
Failed to resolve ::jmhAnnotationProcessor
Failed to resolve ::jmhCompile
Failed to resolve ::jmhCompileClasspath
Failed to resolve ::jmhCompileOnly
------------------------------------------------------------
: Project Dependency Updates (report to plain text file)
------------------------------------------------------------
The following dependencies are using the latest milestone version:
 - org.antlr:antlr:3.5.2
 - org.antlr:antlr4:4.7.1
Gradle updates:
 - Gradle: [4.8: UP-TO-DATE]
ben-manes commented 6 years ago

There are a few little quirks you are running into.

  1. For the SNAPSHOT, you should set the revision property to integration. By default snapshots (milestone) is excluded in the resolution. When you allow snapshots, though, you'll start seeing that for any other dependencies you have.
dependencyUpdates.revision = 'integration'
  1. The configuration failures is because your resolution strategy results in a runtime error. I don't know how to do Gradle's implicit contexts, which is done via a runtime enhancement. Instead you need to explicitly call the methods on the incoming variable, e.g. rules.withModule...

    dependencyUpdates.resolutionStrategy = {
    componentSelection { rules ->
        rules.withModule("org.controlsfx:controlsfx") { ComponentSelection selection ->
            if (selection.candidate.version ==~ /9.*/) { // Reject version 9 or higher
                // selection.reject("Cannot be updated to 9.*.* until Jabref works with Java 9")
            }
        }
  2. Note that we already hide toolVersion dependencies, so your jacoco exclusions shouldn't be needed.


$ gradle dU

> Configure project :
Task :jmh Last added: null

> Task :dependencyUpdates

------------------------------------------------------------
: Project Dependency Updates (report to plain text file)
------------------------------------------------------------

The following dependencies are using the latest integration version:
 - com.github.ben-manes.versions:com.github.ben-manes.versions.gradle.plugin:0.19.0
 - com.github.bkromhout:java-diff-utils:2.1.1
 - com.google.guava:guava:25.1-jre
 - com.jgoodies:jgoodies-common:1.8.1
 - com.jgoodies:jgoodies-forms:1.9.0
 - com.mashape.unirest:unirest-java:1.4.9
 - com.microsoft.azure:applicationinsights-core:2.1.1
 - com.microsoft.azure:applicationinsights-logging-log4j2:2.1.1
 - com.sibvisions.external.jvxfx:dndtabpane:0.1
 - com.simonharrer.modernizer:com.simonharrer.modernizer.gradle.plugin:1.6.0-1
 - commons-cli:commons-cli:1.4
 - de.jensd:fontawesomefx-materialdesignfont:1.7.22-4
 - de.sebastianboegl.shadow.transformer.log4j:de.sebastianboegl.shadow.transformer.log4j.gradle.plugin:2.1.1
 - info.debatty:java-string-similarity:1.1.0
 - javax.inject:javax.inject:1
 - mysql:mysql-connector-java:5.1.46
 - net.java.dev.glazedlists:glazedlists_java15:1.9.1
 - org.antlr:antlr:3.5.2
 - org.antlr:antlr-runtime:3.5.2
 - org.antlr:antlr4:4.7.1
 - org.antlr:antlr4-runtime:4.7.1
 - org.apache.logging.log4j:log4j-api:2.11.0
 - org.apache.logging.log4j:log4j-core:2.11.0
 - org.apache.logging.log4j:log4j-jcl:2.11.0
 - org.apache.logging.log4j:log4j-jul:2.11.0
 - org.apache.logging.log4j:log4j-slf4j-impl:2.11.0
 - org.apache.pdfbox:fontbox:2.0.9
 - org.apache.pdfbox:pdfbox:2.0.9
 - org.apache.pdfbox:xmpbox:2.0.9
 - org.assertj:assertj-swing-junit:3.8.0
 - org.bouncycastle:bcprov-jdk15on:1.59
 - org.citationstyles:locales:1.0.1-SNAPSHOT
 - org.citationstyles:styles:1.0.1-SNAPSHOT
 - org.fxmisc.flowless:flowless:0.6.1
 - org.jsoup:jsoup:1.11.3
 - org.libreoffice:juh:5.4.2
 - org.libreoffice:jurt:5.4.2
 - org.libreoffice:ridl:5.4.2
 - org.libreoffice:unoil:5.4.2
 - org.python:jython-standalone:2.7.1
 - org.reflections:reflections:0.9.11
 - org.slf4j:slf4j-api:1.8.0-beta2
 - org.testfx:testfx-core:4.0.13-alpha
 - org.testfx:testfx-junit5:4.0.13-alpha

The following dependencies have later integration versions:
 - com.github.johnrengelman.shadow:com.github.johnrengelman.shadow.gradle.plugin [2.0.2 -> 2.0.4]
 - com.github.tomakehurst:wiremock [2.17.0 -> 2.18.0]
     http://wiremock.org
 - com.github.tomtung:latex2unicode_2.12 [0.2.2 -> 0.2.4]
     https://github.com/tomtung/latex2unicode
 - com.gradle.build-scan:com.gradle.build-scan.gradle.plugin [1.11 -> 1.14]
 - com.install4j.gradle:com.install4j.gradle.gradle.plugin [7.0.4 -> 7.0.6]
 - com.puppycrawl.tools:checkstyle [8.10.1 -> 8.11-SNAPSHOT]
     http://checkstyle.sourceforge.net/
 - com.sun.xml.bind:jaxb-xjc [2.2.4-1 -> 2.3.0.1]
     http://jaxb.java.net
 - com.tngtech.archunit:archunit-junit [0.8.0 -> 0.8.1]
     https://github.com/TNG/ArchUnit
 - de.saxsys:mvvmfx [1.7.0 -> 1.8.0-SNAPSHOT]
     http://www.saxsys.de
 - de.saxsys:mvvmfx-validation [1.7.0 -> 1.8.0-SNAPSHOT]
     http://www.saxsys.de
 - de.undercouch:citeproc-java [1.0.1 -> 1.1.0-SNAPSHOT]
     http://www.michel-kraemer.com
 - me.champeau.gradle.jmh:me.champeau.gradle.jmh.gradle.plugin [0.4.3 -> 0.4.6]
 - net.ltgt.errorprone:net.ltgt.errorprone.gradle.plugin [0.0.13 -> 0.0.14]
 - org.controlsfx:controlsfx [8.40.15-SNAPSHOT -> 9.0.1-SNAPSHOT]
     http://www.controlsfx.org/
 - org.fxmisc.easybind:easybind [1.0.3 -> 1.0.4-SNAPSHOT]
     http://www.fxmisc.org/easybind/
 - org.fxmisc.richtext:richtextfx [0.9.0 -> 1.0.0-SNAPSHOT]
     http://www.fxmisc.org/richtext/
 - org.junit-pioneer:junit-pioneer [0.1-SNAPSHOT -> 1.0-SNAPSHOT]
     https://github.com/junit-pioneer/junit-pioneer
 - org.junit.jupiter:junit-jupiter-api [5.2.0 -> 5.3.0-SNAPSHOT]
     http://junit.org/junit5/
 - org.junit.jupiter:junit-jupiter-engine [5.2.0 -> 5.3.0-SNAPSHOT]
     http://junit.org/junit5/
 - org.junit.jupiter:junit-jupiter-params [5.2.0 -> 5.3.0-SNAPSHOT]
     http://junit.org/junit5/
 - org.junit.platform:junit-platform-launcher [1.2.0 -> 1.3.0-SNAPSHOT]
     http://junit.org/junit5/
 - org.junit.vintage:junit-vintage-engine [5.2.0 -> 5.3.0-SNAPSHOT]
     http://junit.org/junit5/
 - org.mockito:mockito-core [2.18.3 -> 2.19.0]
     https://github.com/mockito/mockito
 - org.postgresql:postgresql [42.2.2 -> 42.2.3.jre7-SNAPSHOT]
     https://github.com/pgjdbc/pgjdbc-parent-poms
 - org.xmlunit:xmlunit-core [2.6.0 -> 2.6.1-SNAPSHOT]
     https://www.xmlunit.org/
 - org.xmlunit:xmlunit-matchers [2.6.0 -> 2.6.1-SNAPSHOT]
     https://www.xmlunit.org/

Gradle updates:
 - Gradle: [4.8: UP-TO-DATE]
Siedlerchr commented 6 years ago

Thank you very much! Works now. The dependencyUpdates.revision = 'integration' is only possible globally, so I can't say, I just want to have the snapshot check for a specific library?

ben-manes commented 6 years ago

It is global. In early versions of Gradle, that was the only control over resolution due to the dependency management being built on Ivy (since rewritten). You can write a resolution strategy to restrict that to only some dependencies.

resolutionStrategy { ResolutionStrategy componentSelection ->
  componentSelection.componentSelection { rules ->
    rules.all { ComponentSelection selection, ComponentMetadata metadata ->
      if ((metadata.status == 'integration') &&
          !(selection.candidate.group in ['a', 'b']))) {
        selection.reject("Component status ${metadata.status}")
      }
    }
  }
}