简体   繁体   English

如何在Gradle中设置MavenLocal

[英]How to set mavenLocal in Gradle

Within Gradle, I have been setting my repositories like so: 在Gradle中,我一直在这样设置我的存储库:

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,以便可以使用mavenLocal一次声明它,而不是尝试记住URL。

mavenLocal() is already used in gradle to point to your local maven repository on your disk (usually at ~/m2/repository folder) mavenLocal()已在gradle中用于指向磁盘上的本地maven存储库(通常位于〜/ m2 / repository文件夹中)

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: 在本地位置存储本地企业存储库URL的最简单方法是将其放在gradle.properties文件中:

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
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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