So we are currently working on the migration of ant building/publishing scripts for Android projects to the new Android Gradle build system.
Our projects generally relies on both internal and third-party libraries. The internal libraries have been published on Artifactory repositories and now I'm struggling to resolve the dependencies over them.
buildscript {
repositories {
maven { url 'http://repo1.maven.org/maven2' }
maven{
url 'http://dl.bintray.com/jfrog/jfrog-jars'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '2.1.0')
}
}
apply plugin: 'android'
apply plugin: 'artifactory'
artifactory {
contextUrl = 'my_artifactory_url'
resolve {
repository {
repoKey = 'libs-snapshot'
maven = true
}
}
}
dependencies {
compile files('libs/android-support-v4.jar')
compile(group: 'groupId', name: 'artifact1Id', version: 'artifact1Version')
compile(group: 'groupId', name: 'artifact2Id', version: 'artifact2Version')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
I basically used built-in options in Artifactory to generate the artifactory{} section and the two compile() lines. But I'm having this error when trying to build (and I keep having it whatever minor changes I tried) :
15:34:23.208 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
15:34:23.209 [ERROR] [org.gradle.BuildExceptionReporter]
15:34:23.210 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
15:34:23.210 [ERROR] [org.gradle.BuildExceptionReporter] A problem occurred configuring project ':GradleArtifactoryTest'.
15:34:23.210 [ERROR] [org.gradle.BuildExceptionReporter] > Failed to notify project evaluation listener.
15:34:23.211 [ERROR] [org.gradle.BuildExceptionReporter] > Could not resolve all dependencies for configuration ':GradleArtifactoryTest:compile'.
15:34:23.211 [ERROR] [org.gradle.BuildExceptionReporter] > Could not find groupId:artifact1Id:artifact1Version.
15:34:23.212 [ERROR] [org.gradle.BuildExceptionReporter] Required by:
15:34:23.212 [ERROR] [org.gradle.BuildExceptionReporter] workspace_gradle-artifactory-test:GradleArtifactoryTest:unspecified
15:34:23.213 [ERROR] [org.gradle.BuildExceptionReporter] > Could not find groupId:artifact2Id:artifact2Version.
15:34:23.213 [ERROR] [org.gradle.BuildExceptionReporter] Required by:
15:34:23.214 [ERROR] [org.gradle.BuildExceptionReporter] workspace_gradle-artifactory-test:GradleArtifactoryTest:unspecified
I'm probably missing something big, but as a newcomer to Gradle, Maven & Artifactory, I feel kinda lost for the moment. Can someone enlighten me or perhaps tell me how can I get more precise informations on the problem (I tried the --debug and --info, --s and --S options and it was not very helpful). The initial exception is always :
Caused by: org.gradle.api.internal.artifacts.ivyservice.ModuleVersionNotFoundException: Could not find groupId:artifact1Id:artifact1Version.
Required by:
14:20:51.833 [ERROR] [org.gradle.BuildExceptionReporter] workspace_gradle-artifactory-test:GradleArtifactoryTest:unspecified
14:20:51.833 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.LazyDependencyToModuleResolver$StaticVersionResolveResult.notFound(LazyDependencyToModuleResolver.java:148)
14:20:51.834 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.LazyDependencyToModuleResolver$AbstractVersionResolveResult.resolve(LazyDependencyToModuleResolver.java:89)
14:20:51.834 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder$ModuleVersionSelectorResolveState.resolve(DependencyGraphBuilder.java:943)
14:20:51.835 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder$DefaultModuleRevisionResolveState.getMetaData(DependencyGraphBuilder.java:648)
14:20:51.835 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder$DependencyEdge.calculateTargetConfigurations(DependencyGraphBuilder.java:333)
14:20:51.836 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder$DependencyEdge.attachToTargetConfigurations(DependencyGraphBuilder.java:309)
14:20:51.836 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder.traverseGraph(DependencyGraphBuilder.java:130)
14:20:51.836 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder.resolve(DependencyGraphBuilder.java:66)
14:20:51.837 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DefaultDependencyResolver.resolve(DefaultDependencyResolver.java:7
The 'gradle refresh-dependencies --info' command didn't give more useful information. What is very troubling though is that the debug traces never mentionned the contextUrl I provided. Instead I got the following (which, I suppose, is not what I should have) :
selecting new module version groupId#artifact1Id;artifact1Version
16:58:08.827 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.ivyresolve.UserResolverChain] Attempting to resolve module 'groupId:artifact1Id:artifact1Version' using repositories [maven, maven2]
16:58:08.829 [DEBUG] [org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver] Loading /Applications/Android Studio.app/sdk/extras/android/m2repository/groupId/artifact1Id/artifact1version/artifact1Id-artifact1Version.pom
16:58:08.832 [DEBUG] [org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver] Resource not reachable for groupId#artifact1Id;artifact1Version: res=MissingResource: /Applications/Android Studio.app/sdk/extras/android/m2repository/groupId/artifact1Id/artifact1version/artifact1Id-artifact1Version.pom
16:58:08.833 [DEBUG] [org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver] Loading /Applications/Android Studio.app/sdk/extras/android/m2repository/groupId/artifact1Id/artifact1version/artifact1Id-artifact1Version.apklib
16:58:08.840 [DEBUG] [org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver] Resource not reachable for groupId#artifact1Id;artifact1Version: res=MissingResource: /Applications/Android Studio.app/sdk/extras/android/m2repository/groupId/artifact1Id/artifact1version/artifact1Id-artifact1Version.apklib