How can I get gradle 1.10 to use my local maven repository? When I run my gradle script it always looks for the artifact in /Applications/Android Studio.app/sdk/extras/android/m2repository/
instead of ${HOME}/.m2/repository/
In the build.gradle I have tried:
repositories {
mavenCentral()
mavenLocal()
}
and tried this:
repositories {
mavenCentral()
maven {
url '${HOME}/.m2/repository/'
}
}
I then have a dependency that is located in my local .m2 repository:
dependencies {
compile 'com.android.support:support-v4:20.0.+'
compile 'com.android.support:appcompat-v7:20.0.+'
compile 'com.google.android.gms:play-services:4.0.30'
compile 'com.profferapp:proffer_dto_customer_android:1.0'
compile 'com.test:artifact:1.0' // this is in my .m2 repository
}
None of these configurations point to my local maven repository.
Because of the misquoted string, it's probably not seeing your local repository. Also, the other question about the plugin implicitly adding the Maven repo in your SDK is also correct. This will pick up Android support dependencies. Gradle Single vs Double Quotes has a little more information and a link you can follow. Show activity on this post.
If no settings.xml is available, Gradle uses the default location USER_HOME /.m2/repository. As a general advice, you should avoid adding mavenLocal () as a repository. There are different issues with using mavenLocal () that you should be aware of: Maven uses it as a cache, not a repository, meaning it can contain partial modules.
The artifact was published using the maven-publish plugin. In the local maven repository metadata was published as maven-metadata-local.xml (as before). However Gradle 6.0 seems to be exclusively looking for a file named maven-metadata.xml - which isn't there.
the android plugin adds another repository - the one under your SDK. It contains those support and extension libraries. com.test:artifact:1.0 is likely taken form you local Maven repository. Thanks for contributing an answer to Stack Overflow! Please be sure to answer the question.
If you want to do ${...} variable substitution, you need to use double quotes (") instead of single quotes ('). Double quotes denote GStrings, which can do that, but strings with single quotes are always interpreted literally.
So:
repositories {
mavenCentral()
maven {
url "${HOME}/.m2/repository/"
}
}
Make sure you put this block in your module's build file, not the buildscript
block of the top-level build file; the latter only determines where to find the Android plugin, not your module-specific dependencies
Because of the misquoted string, it's probably not seeing your local repository. Also, the other question about the plugin implicitly adding the Maven repo in your SDK is also correct. This will pick up Android support dependencies.
Gradle Single vs Double Quotes has a little more information and a link you can follow.
I want to comment Scott Barta's answer but I have not enough reputation.
So, the final solution I use is:
// in the top-level build.gradle:
buildscript {
...
}
allprojects {
repositories {
mavenCentral()
maven { url System.getenv('HOME') + "/.m2/repository/" }
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With