I'm having an hard time trying to figure out how to resolve a dependency over a remote artifact in Artifactory, from a Gradle build.
This Artifact is available at :
http://192.168.2.130:8081/artifactory/simple/libs-snapshot-local/com/company/test/1.0-SNAPSHOT/TestArtifact-1.0-20130607.104006-2.apklib
My build.gradle is :
buildscript {
repositories {
maven {
url "http://192.168.2.130:8081/artifactory/gradle"
credentials {
username = "$artifactory_user"
password = "$artifactory_password"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4.2'
classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '2.0.12', changing: true)
}
}
}
allprojects {
apply plugin: 'idea'
apply plugin: 'android'
apply plugin: 'artifactory'
}
repositories {
maven {
url "http://192.168.2.130:8081/artifactory"
credentials {
username = "$artifactory_user"
password = "$artifactory_password"
}
}
}
artifactory {
contextUrl = 'http://192.168.2.130:8081/artifactory/simple'
resolve {
repository {
repoKey = 'libs-snapshot'
maven = true
}
}
}
On Artifactory, the repository libs-snapshot
use the maven unique snapshot behavior and is binding to the maven-2-default
layout which has the following configuration :
Artifact Path Pattern : [orgPath]/[module]/[baseRev](-[folderItegRev])/[module]-[baseRev](-[fileItegRev])(-[classifier]).[ext]
Folder Integration Revision RegExp : SNAPSHOT
File Integration Revision RegExp : SNAPSHOT|(?:(?:[0-9]{8}.[0-9]{6})-(?:[0-9]+))
So from my understanding Gradle should resolve the dependency by looking at :
http://192.168.2.130:8081/artifactory/simple/libs-snapshot/com/company/test/TestArtifact/1.0-SNAPSHOT/TestArtifact-1.0-xxxxxxxx.xxxxxx-x.apklib
but it is actually looking at :
http://192.168.2.130:8081/artifactory/com/company/test/TestArtifact/1.0/TestArtifact-1.0.apklib
So obviously it does not resolve the dependency. I also tried to use the gradle compile line generated by Artifactory but it didn't do the trick either :
compile(group: 'com.company.test', name: 'TestArtifact', version: '1.0-20130607.104006-2', ext: 'apklib')
Although I spent some times reading posts and Gradle/Artifactory documentations, I'm even more confused now that I was in the beginning... So, I got a few questions :
1) Gradle doesn't seem to be using the artifactory {} section. In fact, it is only using the url that I declare in the repositories {} section. But when I remove the repositories {} section, it only looks for dependencies locally. Why is that? What is the proper way to declare the Artifactory repositories?
2) Will Gradle be aware of the underlying libs-snapshot
layout? If not, does the Artifactory plugin offers a way to customize artifact search pattern (in straight Maven, not with Ivy)? Because I'm only using the free version of Artifactory thus I won't be able to edit repositories layouts.
3) Why does Artifactory generate a gradle compile line that do not seems to match the layout used by the artifact container repository?
Thanks in advance!