如何在安装葡萄依赖项时排除本地Maven存储库 [英] How to exclude local maven repository when installing grape dependencies

查看:192
本文介绍了如何在安装葡萄依赖项时排除本地Maven存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为我的项目安装一些葡萄品种:

  grape install org.codehaus.groovy.modules.http-builder http-builder 0.6 

如何从我的maven本地存储库中排除下载?在默认情况下,它看起来像是从我的本地仓库下载的。

  found org.codehaus.groovy.modules.http-builder#http -builder; 0.6在localm2中
找到org.apache.httpcomponents#httpclient; 4.2.1在localm2中
找到org.apache.httpcomponents#httpcore; 4.2.1在localm2中
找到commons-logging #commons-logging; 1.1.1 in localm2
found commons-codec#commons-codec; 1.6 in localm2

...

解决方案

您可能在 grapeConfig.xml (〜/ .groovy / grapeConfig.xml ):

 <?xml version =1.0?> 
< ivysettings>
< settings defaultResolver =downloadGrapes/>
< resolvers>
< chain name =downloadGrapes>
<! - todo add'支持groovy extensions'resolver here - >
< filesystem name =cachedGrapes>
< / filesystem>
< ibiblio name =codehausroot =http://repository.codehaus.org/m2compatible =true/>
< ibiblio name =ibibliom2compatible =true/>
< ibiblio name =java.net2root =http://download.java.net/maven/2/m2compatible =true/>
< / chain>
< /解析器>
< / ivysettings>

使用解析器节中的下行线, grape 从本地maven回购中获取工件:

 < ibiblio name =localroot =file:$ {user.home} /。m2 / repository /m2compatible =true/> 

注释它可从配置的回购站下载工件。



编辑:仅在本地使用joda-time进行测试

首先,使用本地maven repo包含在grapeConfig.xml中



 >葡萄安装joda-time joda-time 2.1 
:: loading settings :: url = jar:file:/ C:/Software/groovy-2.1.1/lib/ivy-2.2.0.jar!/ org / apache / ivy / core / settings / ivysettings.xml
::解析dependencies :: caller#all-caller; working16
confs:[default]
found joda-time#joda-time; 2.1在本地
下载文件:C:/Users/jalopaba/.m2/repository/joda-time/joda-time/2.1/joda-time-2.1.jar ...
[成功] joda -time#joda-time; 2.1!joda-time.jar(90ms)

手动删除 joda-time 文件夹位于〜/ .groovy / grapes 并注释掉上面的行:

 >葡萄安装joda-time joda-time 2.1 
:: loading settings :: url = jar:file:/ C:/Software/groovy-2.1.1/lib/ivy-2.2.0.jar!/ org / apache / ivy / core / settings / ivysetti ngs.xml
::解析依赖关系::调用者#all-caller; working09
confs:[默认]
找到joda-time#joda-time ; 2.1 ibiblio
正在下载http://repo1.maven.org/maven2/joda-time/joda-time/2.1/joda-time-2.1.jar ...
[成功] joda- time#joda-time; 2.1!joda-time.jar(2460ms)

编辑2 :请按照以下注释进行编辑:



如果您无法在中创建 grapeConfig.xml 〜/ .groovy 但您可以在其他路径中创建它,您可以执行

  grape -Dgrape.config =< pathTo_grapeConfig.xml>安装joda-time joda-time 2.1 


I want install some grape depencies to my project:

grape install org.codehaus.groovy.modules.http-builder http-builder 0.6

How I can exclude downloading from my maven local repository ? Becase by default it looks like it download from my local repo

found org.codehaus.groovy.modules.http-builder#http-builder;0.6 in localm2
found org.apache.httpcomponents#httpclient;4.2.1 in localm2
found org.apache.httpcomponents#httpcore;4.2.1 in localm2
found commons-logging#commons-logging;1.1.1 in localm2
found commons-codec#commons-codec;1.6 in localm2

...

解决方案

You probably have your local maven repo in the resolvers section of grapeConfig.xml (~/.groovy/grapeConfig.xml):

<?xml version="1.0"?>
<ivysettings>
    <settings defaultResolver="downloadGrapes"/>
    <resolvers>
        <chain name="downloadGrapes">
            <!-- todo add 'endorsed groovy extensions' resolver here -->
            <ibiblio name="local" root="file:${user.home}/.m2/repository/" m2compatible="true"/>
            <filesystem name="cachedGrapes">
                <ivy pattern="${user.home}/.groovy/grapes/[organisation]/[module]/ivy-[revision].xml"/>
                <artifact pattern="${user.home}/.groovy/grapes/[organisation]/[module]/[type]s/[artifact]-[revision].[ext]"/>
            </filesystem>
            <ibiblio name="codehaus" root="http://repository.codehaus.org/" m2compatible="true"/>
            <ibiblio name="ibiblio" m2compatible="true"/>
            <ibiblio name="java.net2" root="http://download.java.net/maven/2/" m2compatible="true"/>
        </chain>
    </resolvers>
</ivysettings>

With the line bellow inside the resolvers section, grape gets artifacts from the local maven repo:

<ibiblio name="local" root="file:${user.home}/.m2/repository/" m2compatible="true"/>

Comment it out to download artifacts from the configured repos.

EDIT: just tested locally with joda-time

First, with my local maven repo included in grapeConfig.xml

> grape install joda-time joda-time 2.1
:: loading settings :: url = jar:file:/C:/Software/groovy-2.1.1/lib/ivy-2.2.0.jar!/org/apache/ivy/core/settings/ivysettings.xml
:: resolving dependencies :: caller#all-caller;working16
        confs: [default]
        found joda-time#joda-time;2.1 in local
downloading file:C:/Users/jalopaba/.m2/repository/joda-time/joda-time/2.1/joda-time-2.1.jar ...
        [SUCCESSFUL ] joda-time#joda-time;2.1!joda-time.jar (90ms)

After manually deleting joda-time folder in ~/.groovy/grapes and commenting out the line above:

> grape install joda-time joda-time 2.1
:: loading settings :: url = jar:file:/C:/Software/groovy-2.1.1/lib/ivy-2.2.0.jar!/org/apache/ivy/core/settings/ivysetti    ngs.xml
:: resolving dependencies :: caller#all-caller;working09
        confs: [default]
        found joda-time#joda-time;2.1 in ibiblio
downloading http://repo1.maven.org/maven2/joda-time/joda-time/2.1/joda-time-2.1.jar ...
        [SUCCESSFUL ] joda-time#joda-time;2.1!joda-time.jar (2460ms)

EDIT 2: edited following my comment below:

If you can't create the grapeConfig.xml in ~/.groovy but you can create it in other path, you can do

grape -Dgrape.config=<pathTo_grapeConfig.xml> install joda-time joda-time 2.1

这篇关于如何在安装葡萄依赖项时排除本地Maven存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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