如何在gradle构建文件中配置maven本地和远程存储库? [英] How to configure maven local and remote repository in gradle build file?

查看:212
本文介绍了如何在gradle构建文件中配置maven本地和远程存储库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将Maven本地仓库另外用于Maven远程仓库。我发现了JIRA-问题 http://issues.gradle.org/browse/GRADLE-1173,但以这种方式调整我的gradle构建文件,仍然没有找到仅在本地maven存储库中可用的快照依赖项。

是否可以拥有一个本地和一个远程Maven仓库?



以下是我的gradle构建文件的相关部分:

  apply plugin:'maven'

存储库{

mavenLocal()

maven {
凭证{
用户名myusername
密码mypassword
}
urlhttp:// myremoterepository
}

}

$我还需要对我的项目进行类似的设置,并且我可以验证您的build.gradle安装程序,只要您的Maven安装正确。

Gradle mavenLocal()依赖于 settings.xml 的localRepository 定义 code> file:

 < localRepository> USER_HOME \.m2\repository< / localRepository> ; 

settings.xml应该位于 M2_HOME / conf 或您的 USER_HOME / .m2目录。您应该检查:


  1. maven 安装正确

  2. M2_HOME 存在环境变量
  3. settings.xml 具有正确的 localRepository 定义..


i want to use the maven local repository additionally to a maven remote one. I found the JIRA-Issue http://issues.gradle.org/browse/GRADLE-1173 for that, but adapting my gradle build file in that way some snapshot dependencies which are only available in the local maven repository are still not found. I get an error that the Snapshot-Dependency is not found.

Is it possible to have one local and one remote maven repository?

Here is the relevant part of my gradle build file:

apply plugin: 'maven'

repositories {

    mavenLocal()

    maven {
        credentials {
            username "myusername"
            password "mypassword"
        }
        url "http://myremoterepository"
    }

}

解决方案

I also needed to do a similar setup with my project and I can verify your build.gradle setup works provided your Maven is setup correctly.

Gradle's mavenLocal() relies on the localRepository definition from the maven settings.xml file:

  <localRepository>USER_HOME\.m2\repository</localRepository>

The settings.xml should be in either your M2_HOME/conf or your USER_HOME/.m2 directory. You should check:

  1. maven is installed correctly
  2. M2_HOME environment variable exists
  3. settings.xml has the correct localRepository defined..

这篇关于如何在gradle构建文件中配置maven本地和远程存储库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆