Groovy';s常春藤缓存(@Grab)不是缓存?
我使用groovyConsole(版本1.8.1)运行这个简单的groovy脚本: 通常,它执行速度非常快(约0秒) 但是,有时(每5次运行一次),它会在完成运行前暂停3-5秒。 我正在使用Wireshark()进行嗅探,并查看对Groovy';s常春藤缓存(@Grab)不是缓存?,groovy,grape,Groovy,Grape,我使用groovyConsole(版本1.8.1)运行这个简单的groovy脚本: 通常,它执行速度非常快(约0秒) 但是,有时(每5次运行一次),它会在完成运行前暂停3-5秒。 我正在使用Wireshark()进行嗅探,并查看对repository.codehaus.org的HTTP请求(我在Wireshark流中看到一些404响应,但脚本成功运行,因此显然在某个点上找到了JAR) 我的问题是-一旦脚本运行一次,它通过@Grab下载的jar不会永远被缓存吗?为什么经常查询实际的Ivy/Mave
repository.codehaus.org
的HTTP请求(我在Wireshark流中看到一些404响应,但脚本成功运行,因此显然在某个点上找到了JAR)
我的问题是-一旦脚本运行一次,它通过@Grab下载的jar不会永远被缓存吗?为什么经常查询实际的Ivy/Maven存储库?文件应该缓存在
~/.groovy/grapes
中。如果使用-Divy.message.logger.level=4
重新运行脚本,您将从ivy获得一些可能有用的调试信息
此外,如果你有一颗葡萄需要很长时间才能解决,你可以告诉常春藤少检查。将默认常春藤配置从复制到~/.groovy/grapeConfig.xml
,并将属性ivy.cache.ttl.default
添加到等待一定时间后再检查。例如:
<ivysettings>
<property name="ivy.cache.ttl.default" value="24h"/>
<settings defaultResolver="downloadGrapes"/>
<resolvers>
<chain name="downloadGrapes" returnFirst="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](-[classifier]).[ext]"/>
</filesystem>
<ibiblio name="localm2" root="file:${user.home}/.m2/repository/" checkmodified="true" changingPattern=".*" changingMatcher="regexp" m2compatible="true"/>
<!-- todo add 'endorsed groovy extensions' resolver here -->
<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>
脚本中的@Grab
就是这些吗?我只是问一下,因为常春藤(它支撑着@Grab
)似乎在寻找大量不相关的软件包。但我不是常春藤专家:-/@tim_yates-是的,这就是整个剧本。
<ivysettings>
<property name="ivy.cache.ttl.default" value="24h"/>
<settings defaultResolver="downloadGrapes"/>
<resolvers>
<chain name="downloadGrapes" returnFirst="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](-[classifier]).[ext]"/>
</filesystem>
<ibiblio name="localm2" root="file:${user.home}/.m2/repository/" checkmodified="true" changingPattern=".*" changingMatcher="regexp" m2compatible="true"/>
<!-- todo add 'endorsed groovy extensions' resolver here -->
<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>