I am explicitly adding the dependency artifact like the example below but it is ignoring the artifact all together. The example is straight from the DependencyHandler documentation and what I am doing is something similar. This works in 1.12 but when I upgrade to 2.0 it ignores the artifact closure.
apply plugin: 'java' //so that I can declare 'compile' dependencies
dependencies {
//configuring dependency to specific configuration of the module
compile configuration: 'someConf', group: 'org.someOrg', name: 'someModule', version: '1.0'
//configuring dependency on 'someLib' module
compile(group: 'org.myorg', name: 'someLib', version:'1.0') {
//explicitly adding the dependency artifact:
artifact {
//useful when some artifact properties unconventional
name = 'someArtifact' //artifact name different than module name
extension = 'someExt'
type = 'someType'
classifier = 'someClassifier'
}
}
}
Here is the build output when I try do use gradle version 2.0:
C:\Users\jmessmer\IdeaProjects\gradleDependencyHandlerTest>which gradle
C:\Program Files\gradle\gradle-2.0\bin\gradle
C:\Users\jmessmer\IdeaProjects\gradleDependencyHandlerTest>gradle build
:compileJava
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all dependencies for configuration ':compile'.
> Could not find com.example:mytools:3535
Searched in the following locations:
http://myArtifactoryURL.com:8081/artifactory/public/com/example/mytools/3535/mytools.3535.pom
http://myArtifactoryURL.com:8081/artifactory/public/com/example/mytools/3535/mytools-3535.jar
http://myArtifactoryURL.com:8081/artifactory/prerelease/com.example/mytools/3535/jar/mytools-3535.jar
http://myArtifactoryURL.com:8081/artifactory/external/com.example/mytools/3535/ivy/ivy-3535.xml
http://myArtifactoryURL.com:8081/artifactory/external/com.example/mytools/3535/jar/mytools-3535.jar
http://myArtifactoryURL.com:8081/artifactory/repo1-cache/com/example/mytools/3535/ivy/ivy-3535.xml
http://myArtifactoryURL.com:8081/artifactory/repo1-cache/com/example/mytools/3535/ivy-3535.xml
http://myArtifactoryURL.com:8081/artifactory/repo1-cache/com/example/mytools/3535/jar/mytools-3535.jar
http://myArtifactoryURL.com:8081/artifactory/repo1-cache/com/example/mytools/3535/mytools-3535.jar
Required by:
:gradleDependencyHandlerTest:1.0
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 7.425 secs
C:\Users\jmessmer\IdeaProjects\gradleDependencyHandlerTest>
As you can see, my artifact has a different nomenclature than the module name…I am not sure if I need to do something different and how when I go to gradle 2.0
Is this exactly the output you’re seeing? There seems to be something missing from the Gradle 2.0 output.
Can you further simplify this by: 1) Remove all repository declarations except for the ‘prerelease’ one 2) Add a simple task that does nothing more than resolve the configuration:
task fetch(type: Copy) {
from configurations.compile
into "build/fetch"
}
Post the output of ‘gradle --refresh-dependencies fetch’ for Gradle 1.12 and Gradle 2.0. If you can grab the debug output and make it available via Gist that would be even better.
Actually, nevermind. I can confirm this is a regression in dependency resolution in Gradle 2.0. The issue occurs when there is no ivy.xml for a module, and the artifact name does not match the module name.
I’ve raised GRADLE-3118 to track this issue.
The tricky thing is that it looks like this has been already fixed in master, even though there’s been no corresponding bug report. Can you try a recent nightly build (http://gradle.org/nightly) and see if it fixes your problem?