If you are using Grapes to download dependency at runtime for your groovy script, you can see big delay on script startup.

When you first run script, it makes sense, because Groovy is resolving dependencies and downloading all required jars, but why there is still delay on next launches?

Because some maven artifacts specify that they always want to use the latest version of its dependency X, forcing groovy to check the maven repository for new version of the dependency on each execution.

This happened with HttpBuilder plugin with me. It was taking 30-40 seconds to start and was really annoying.

There is an easy way to solve this. You can specify caching for ify in Grape config file. Create “~/.groovy/grapeConfig.xml” file with following content (~ stands for your home directory):

<?xml version="1.0" encoding="utf-8"?>
<ivysettings>
    <settings defaultResolver="downloadGrapes" />
    <property name="ivy.cache.ttl.default" value="15h"/>
    <resolvers>
       <chain name="downloadGrapes">
          <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="codehaus.snapshots" root="http://snapshots.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>

“ivy.cache.ttl.default” property defines the caching timeout. So you will experience this pause only once in that interval.