How to verify that Gradle can get artifacts from a nexus repo, and how to troubleshoot if it is not?

I have an existing Ant build.xml, which originally just assumed that its dependencies were stored in a “lib” subdir. I tried adding Ivy to this mix, so that one task downloads all the required artifacts either from MavenCentral or a local intranet repo (nexus). Some of the artifacts on that Nexus repo and release artifacts, but one is a snapshot artifact, and the files stored on the repo are timestamped (timestamp is in the file name). This artifact is built by Maven.

I’m trying to write a corresponding Gradle build script, although only the portions that specify and install dependencies. I’ve only just started to read the Gradle docs.

Here is what I have for my build script so far (with some values elided):

------------------------ apply plugin:‘java’

repositories {

maven {

url “~/.m2/repository”

}

maven {

url “http:///nexus/content/repositories/cditspoc-snapshots”

}

maven {

url “http:///nexus/content/repositories/cditspoc-3rd-party”

}

mavenCentral() }

dependencies {

compile “:poc-domain-model:0.0.1-SNAPSHOT” } ---------------------

I tried to just run “gradle dependencies”, and it said the following: ---------------- :dependencies

------------------------------------------------------------ Root project ------------------------------------------------------------

archives - Configuration for archive artifacts. No dependencies

compile - Compile classpath for source set ‘main’. — :poc-domain-model:0.0.1-SNAPSHOT FAILED

default - Configuration for default artifacts. — :poc-domain-model:0.0.1-SNAPSHOT FAILED

runtime - Runtime classpath for source set ‘main’. — :poc-domain-model:0.0.1-SNAPSHOT FAILED

testCompile - Compile classpath for source set ‘test’. — :poc-domain-model:0.0.1-SNAPSHOT FAILED

testRuntime - Runtime classpath for source set ‘test’. — :poc-domain-model:0.0.1-SNAPSHOT FAILED

BUILD SUCCESSFUL

Total time: 51.907 secs ------------------------------

This sounds like it was unable to find the artifact on the repo.

It looks to me as if you are missing the ‘groupId’ coordinate of the declared Maven dependency.

Yeah, that’s what it looks like, but that’s not the case. I didn’t realize that this forum elided what I put there. I had tried to replace the groupid with a generic name between angle brackets, but the forum decided to remove that entirely. In my actual build script, I copied all three of the GAV pieces of the dependency.

I’d try to run it with the ‘-i’ command line flag to see if you can get more information. It might also help if you could post the contents of the POM file for this artifact.

Running “gradle -i dependencies” just added the following before the output I provided before: -------------------------------- Connected to the daemon. Dispatching Build{id=d708d16d-510a-4e1f-b19c-6a17fc1473f9.1, currentDir===home==\git\atg\coherence_poc} request. The client will now receive all logging from the daemon (pid: 9936). The daemon log file: ==home==.gradle\daemon\1.11\daemon-9936.out.log Executing build with daemon context: DefaultDaemonContext[uid=9c4275a8-a475-4435-8498-14d1e1990e0b,javaHome=C:\eclipse\Java\jdk1.6.0_30,daemonRegistryDir===home==.gradle\daemon,pid=9936,idleTimeout=10800000,daemonOpts=-XX:MaxPermSize=256m,-XX:+HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=windows-1252] Starting Build Settings evaluated using empty settings script. Projects loaded. Root project using build file ‘==home==\git\atg\coherence_poc\build.gradle’. Included projects: [root project ‘coherence_poc’] In-memory cache of ==home==\git\atg\coherence_poc.gradle\1.11\taskArtifacts\fileHashes.bin: Size{0}, CacheStats{hitCount=0, missCount=0, loadSuccessCount=0, loadExceptionCount=0, totalLoadTime=0, evictionCount=0} In-memory cache of ==home==\git\atg\coherence_poc.gradle\1.11\taskArtifacts\outputFileStates.bin: Size{0}, CacheStats{hitCount=0, missCount=0, loadSuccessCount=0, loadExceptionCount=0, totalLoadTime=0, evictionCount=0} In-memory cache of ==home==\git\atg\coherence_poc.gradle\1.11\taskArtifacts\fileSnapshots.bin: Size{4}, CacheStats{hitCount=0, missCount=0, loadSuccessCount=0, loadExceptionCount=0, totalLoadTime=0, evictionCount=0} In-memory cache of ==home==\git\atg\coherence_poc.gradle\1.11\taskArtifacts\taskArtifacts.bin: Size{2}, CacheStats{hitCount=0, missCount=0, loadSuccessCount=0, loadExceptionCount=0, totalLoadTime=0, evictionCount=0} Evaluating root project ‘coherence_poc’ using build file ‘==home==\git\atg\coherence_poc\build.gradle’. All projects evaluated. Selected primary task ‘dependencies’ Tasks to be executed: [task ‘:dependencies’] :dependencies (Thread[Daemon Thread 3,5,main]) started. :dependencies Executing task ‘:dependencies’ (up-to-date check took 0.019 secs) due to:

Task.upToDateWhen is false. ------------------------------------

There really isn’t much in the pom for that artifact. It specifies the same groupid and artifact that I’m specifying. The build of this artifact works fine. However, I did just notice that the pom doesn’t specify a version, so it’s apparently using a default of “0.0.1-SNAPSHOT”. That’s the value I would specify anyway, but it is odd that it doesn’t specify a value. I’m attempting to check in a new version that rectifies that possibly irrelevant discrepancy, but I’m having some temporary problems with logging into my git repo.

I’m still waiting for our help desk to fix my git repo problem, but I would think there should be something else I can do here to get more information about why this is failing. I also don’t really think my missing “version” property in the pom really makes that much difference, as it appears that the default value is exactly what I’m asking for. Nevertheless, I’m still pushing forward with trying to check in that change.

I think I just figured out something that should have been simple. I didn’t think to set the proxy. After I set that in my ~/.gradle/gradle.properties, running “gradle dependencies” seems to return sane information. Now I need to move forward with building this out and verifying that it’s actually downloading the dependency. When I tried this with Gradle, it was able to verify that the artifact was present on the repo (from the pom it could read), but the attempt to download the actual artifact failed, supposedly because it couldn’t grok the filename containing the timestamp.