settings.xml中配置本地仓库地址,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | <?xml version="1.0" encoding="UTF-8"?> <settings> <localRepository>C:\Users\lv\.m2\repository</localRepository> <mirrors> <mirror> <id>alimaven</id> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror> <mirror> <id>jitpack</id> <mirrorOf>jitpack</mirrorOf> <name>jitpack库</name> <url>https://jitpack.io</url> </mirror> </mirrors> </settings> |
android build.gradle中使用mavelLocal()引用
1 2 3 4 5 6 7 8 9 10 11 | allprojects { repositories { mavenLocal() maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' } maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' } maven { url 'http://maven.aliyun.com/nexus/content/repositories/google' } maven { url 'http://maven.aliyun.com/nexus/content/repositories/gradle-plugin' } mavenCentral() maven { url "https://jitpack.io" } } } |
mavenLocal的解释
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | /** * Adds a repository which looks in the local Maven cache for dependencies. The name of the repository is * {@value org.gradle.api.artifacts.ArtifactRepositoryContainer#DEFAULT_MAVEN_LOCAL_REPO_NAME}. * * <p>Examples:</p> * <pre class='autoTested'> * repositories { * mavenLocal() * } * </pre> * <p> * The location for the repository is determined as follows (in order of precedence): * </p> * <ol> * <li>The value of system property 'maven.repo.local' if set;</li> * <li>The value of element <localRepository> of <code>~/.m2/settings.xml</code> if this file exists and element is set;</li> * <li>The value of element <localRepository> of <code>$M2_HOME/conf/settings.xml</code> (where <code>$M2_HOME</code> is the value of the environment variable with that name) if this file exists and element is set;</li> * <li>The path <code>~/.m2/repository</code>.</li> * </ol> * * @return the added resolver */ MavenArtifactRepository mavenLocal(); |