2

Our organization works in an isolated network so when we want to use libraries we need to retrieve them from maven-central and upload then to our own maven repository.

I am searching for way do download all the files of my required dependencies, I have used gradle gradle eclipseClasspath to do this but it is not downloading all the files. for example org.jacoco:jacoco:0.7.8 contains a zip file and when I look in the GRADLE_USER_HOME I can not find the zip.

build.gradle:

apply plugin: 'java'
apply plugin: 'eclipse'
repositories {
    mavenCentral()
}
dependencies {
    compile 'org.jacoco:jacoco:0.7.8'
}

What should I do?

Ido Sorozon
  • 272
  • 1
  • 12
  • Simply use a repository manager and let a build run and all of your needed artifacts have been downloaded into your repository manager. That's it? – khmarbaise Dec 16 '16 at 12:44
  • @khmarbaise what is this repository manager, can you give me an example? – Ido Sorozon Dec 17 '16 at 16:02
  • Take a look here: https://maven.apache.org/repository-management.html – khmarbaise Dec 17 '16 at 22:47
  • I don't understand, we need to download the artifacts so we could upload them to out isolated repository manager(nexus), Do you suggest I use a repository manager to download the artifacts or something else? – Ido Sorozon Dec 19 '16 at 10:13

2 Answers2

2

You could use this gradle task to download the dependencies to a local directory.

lance-java
  • 25,497
  • 4
  • 59
  • 101
  • See [here](http://stackoverflow.com/a/39981143/1089967) for downloading sources and javadocs (if available) for dependencies – lance-java Dec 19 '16 at 11:40
  • For my understanding `withArtifacts(JvmLibrary, SourcesArtifact)` is the way to download the sources, but how do I manage to download the zip which is not source nor javadoc, I have tried to use `withArtifacts(Component, Artifact)` but it does not seems to work – Ido Sorozon Dec 19 '16 at 12:32
0

I wanted a simple solution, for now I have made this ugly one https://github.com/idosu/scripts/blob/master/gradle/full-download-from-central.gradle

usage:

apply from: 'https://raw.githubusercontent.com/idosu/scripts/master/gradle/full-download-from-central.gradle'
dependencies {
    compile 'org.jacoco:jacoco:0.7.8'
}

windows: set GRADLE_USER_HOME=deps & gradle --no-daemon -b eclipseClasspath createRepo

shell: export GRADLE_USER_HOME=deps; gradle --no-daemon -b eclipseClasspath createRepo

The result will be in build/repo


A better way to do this is figuring out how eclipseClasspath resolves all the dependencies with all the parent poms. because using project.configurations.compile.resolvedConfiguration.lenientConfiguration.allModuleDependencies does not do the trick

Ido Sorozon
  • 272
  • 1
  • 12