Upgrading gradle version to 2.14 from 1.12, fails to find snapshot dependencies


(Dilini) #1

After the update it is unable to find the SNAPSHOT versions of the dependencies in the nexus maven repository. It is possible to build with 1.12 and older versions of gradle but when upgraded to 2.0 or later, it fails to find the dependencies. Has anyone come across a similar situation?

Following is my build file:

// Apply the java plugin to add support for Java
apply plugin: 'java'

// In this section you declare where to find the dependencies of your project
repositories {
// Use 'maven central' for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
mavenCentral()
 maven {
    name = 'Public'
    credentials {
        username = 'abc'
        password = 'abc'
    }
    url 'http://mydomain/nexus/content/groups/public/'
}

}

// In this section you declare the dependencies for your production and test   code
dependencies {
// The production code uses the SLF4J logging API at compile time
compile( 

[group: 'com.test.comp', name: 'comp-app-interface', version: "3.0.9_SNAPSHOT"],
[group: 'com.test.comp', name: 'comp-app-common', version: "3.0.10_SNAPSHOT", classifier: 'lib'],
)
// Declare the dependency for your favourite test framework you want to use in your tests.
// TestNG is also supported by the Gradle Test task. Just change the
// testCompile dependency to testCompile 'org.testng:testng:6.8.1' and add
// 'test.useTestNG()' to your build script.
testCompile "junit:junit:4.11"
}

And I’m getting the following error:

FAILURE: Build failed with an exception.    

\* What went wrong:
Could not resolve all dependencies for configuration ':COMP-Testing-  Common:compileClasspath'.    

\> Could not find com.test.comp:comp-app-common:3.0.10_SNAPSHOT.
Searched in the following locations:
file:/C:/Users/myname/.m2/repository/com/test/comp/comp-app-common/3.0.10_SNAPSHOT/comp-app-common-3.0.10_SNAPSHOT.pom
file:/C:/Users/myname/.m2/repository/com/test/comp/comp-app-common/3.0.10_SNAPSHOT/comp-app-common-3.0.10_SNAPSHOT-lib.jar
http://example.com/nexus/content/groups/public/com/test/comp/comp-app-common/3.0.10_SNAPSHOT/comp-app-common-3.0.10_SNAPSHOT.pom
http://example.com/nexus/content/groups/public/com/test/comp/comp-app-common/3.0.10_SNAPSHOT/comp-app-common-3.0.10_SNAPSHOT-lib.jar
Required by:
com.test.comp:COMP-Testing-Common:3.0.10

(Jared Burrows) #2

Can you show you build.gradle files?


(Dilini) #3

I found and fixed the issue.
Gradle does not identify that they were snapshots because of the format of the version number.
eg: when there is an underscore between the version number and ‘snapshot’, 3.0.9_SNAPSHOT gradle simply looks for the dependency with that version. But if it has a dash instead of the underscore in between (i.e 3.0.9-SNAPSHOT), gradle will read the maven-metadata.xml and finds the latest snapshot.
The underscore was working fine when using gradle 1.xxx versions.