grapeConfig.xml
您可能在( )的解析器部分中有本地 maven 存储库~/.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>
使用该resolvers
部分内的以下行,grape
从本地 maven 存储库获取工件:
<ibiblio name="local" root="file:${user.home}/.m2/repository/" m2compatible="true"/>
将其注释掉以从配置的存储库中下载工件。
编辑:刚刚用 joda-time 在本地测试
首先,在grapeConfig.xml 中包含我的本地maven repo
> 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)
在手动删除joda-time
文件夹~/.groovy/grapes
并注释掉上面的行之后:
> 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)
编辑2:在我的评论之后编辑:
如果您无法创建grapeConfig.xml
in~/.groovy
但可以在其他路径中创建它,则可以
grape -Dgrape.config=<pathTo_grapeConfig.xml> install joda-time joda-time 2.1