简体   繁体   中英

How to set mavenLocal in Gradle

Within Gradle, I have been setting my repositories like so:

repositories {
  maven {
    url "http://eqnyknexus002.company.com:8080/nexus/content/groups/main"
  }
}

and I realized that it would be great to be able to set it simply as

repositories {
  maven {
    mavenLocal() 
  }
}

How can I set mavenLocal within a build script so that I can declare it just once use mavenLocal instead of trying to remember the URL.

mavenLocal() is already used in gradle to point to your local maven repository on your disk (usually at ~/m2/repository folder)

The easiest way to store the url of your local enterprise repo at a central place is to put it in your gradle.properties file:

MVN_REPO_URL=http://eqnyknexus002.company.com:8080/nexus/content/groups/main

Then you can just reference this property in your build files

repositories {
    maven {
        url MVN_REPO_URL
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM