Миша Кошелев
Миша Кошелев

Reputation: 1513

Gradle/ivy use cached repos?

I would like Grade/Ivy to use cached versions of my jars, as it takes ~20 seconds to check every time for updates.

Is this possible?

Thank you Misha

Upvotes: 1

Views: 1167

Answers (2)

Tom Eyckmans
Tom Eyckmans

Reputation: 51

Depending on the required speed it may be sufficient to setup a local repository proxy (you can do this for multiple repositories not only maven central) with Artifactory or Nexus. This way checking for updates should be much faster since it no longer goes over the internet but only over the local network. Only the first time you use a dependency will the proxy download it from the upstream repository.

Upvotes: 2

Миша Кошелев
Миша Кошелев

Reputation: 1513

Here, as always, is my hack-ey solution:

deps.sh

#!/bin/bash
if [ -d lib ]; then
   rm -rf lib
fi
mkdir lib

cd lib
NAMES=`find ~/.gradle/cache -name \*.jar`
for NAME in $NAMES; do
   ln -s $NAME .
done

and my build.gradle becomes

apply plugin: 'groovy'

/*
repositories {
   mavenCentral()
}
*/

dependencies {
  /*
  groovy group: 'org.codehaus.groovy', name: 'groovy', version: '1.7.0'
  groovy group: 'org.hibernate', name: 'hibernate-core', version: '3.3.2.GA'
  groovy group: 'org.hibernate', name: 'hibernate-annotations', version: '3.4.0.GA'
  groovy group: 'org.slf4j', name: 'slf4j-jdk14', version: '1.6.0'
  groovy group: 'org.jasypt', name: 'jasypt', version: '1.6'
  groovy group: 'org.codehaus.groovy.modules.http-builder', name: 'http-builder', version:     '0.5.0'
  groovy group: 'net.sourceforge.htmlunit', name: 'htmlunit', version: '2.7'
  testCompile group: 'junit', name: 'junit', version: '4.7'  
  */
  groovy fileTree(dir: 'lib', include: '*.jar')
}

Upvotes: 1

Related Questions