Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle: force use of a repository for a dependency

I would like to know if there is a way to force gradle to use a repository for one dependency. For instance with:

buildscript {
repositories {
    jcenter()
    mavenCentral()
    maven { url 'https://www.testfairy.com/maven' }
    maven { url 'https://maven.fabric.io/repo' }
    maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}

dependencies {
    classpath 'com.android.tools.build:gradle:1.0.1'
    classpath "io.fabric.tools:gradle:1.+"
    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
wearApp project(':wear')
compile project(':shimmer')
compile('com.twitter.sdk.android:twitter:1.1.1@aar') {
    transitive = true;
}
compile('com.twitter.sdk.android:tweet-composer:0.7.2@aar') {
    transitive = true;
}
compile 'com.android.support:appcompat-v7:21.0.3'
// Dagger 2 dependencies
compile 'com.google.dagger:dagger:2.0-SNAPSHOT'
apt 'com.google.dagger:dagger-compiler:2.0-SNAPSHOT'
provided 'org.glassfish:javax.annotation:10.0-b28'

}

I want com.google.dagger to be checked out from https://oss.sonatype.org/content/repositories/snapshots because for now it tries to check it out from https://maven.fabric.io/repo which result in the following error:

Error:Could not GET 'https://maven.fabric.io/repo/com/google/dagger/
dagger-compiler/2.0-SNAPSHOT/maven-metadata.xml'. Received status code 401      from server: Unauthorized
<a href="toggle.offline.mode">Enable Gradle 'offline mode' and sync project</a>

Thank you.

like image 566
E-Kami Avatar asked Feb 22 '15 14:02

E-Kami


2 Answers

Same thing happened to me last night, I could solve by adding the following lines in gradle file.

compile 'com.google.dagger:dagger:2.1-SNAPSHOT'
apt 'com.google.dagger:dagger-compiler:2.1-SNAPSHOT'

Version 2.0 is not already available in the repository.

like image 200
Lex Karel Zayas Avatar answered Oct 24 '22 08:10

Lex Karel Zayas


No, not yet. The ordering is important, so you could try putting the fabric.io repo last.

When I try this locally from the command-line, I see dagger come from sonatype without changing anything. Does it work from the command-line for you too?

like image 35
bigguy Avatar answered Oct 24 '22 08:10

bigguy