title: Download dependencies given only the build.gradle file
body: <p>Is it possible to download gradle dependencies using only <code>build.gradle</code> file?</p>
  
  <p>What I am trying to accomplish is the following:</p>
  
  <p>I have a set of unit tests and I want to execute them (as part of CI process) inside a docker container. Initially, I used the <a href="https://store.docker.com/images/openjdk" rel="nofollow noreferrer">openjdk:8-jdk</a> image from docker hub as base image for my tests. So, docker compose file contains the following:</p>
  
  <pre><code>version: '3.2'
  
  services:
  
    unit:
      image: openjdk:8-jdk
      volumes:
        - ..:/usr/test
      working_dir: /usr/test
      command: sh -c "exec ./gradlew junitPlatformTest -Punit -p moduleA/"
  </code></pre>
  
  <p>Whole project is mounted on <code>/usr/test</code> directory inside the container. When the container starts, it executes the <code>junitPlatformTest</code> task against <code>moduleA</code>. The problem with <code>openjdk:8-jdk</code> image is that gradle and its dependencies are downloaded every time I run the <code>unit</code> service.</p>
  
  <p>To solve this, I decided to create a new image which would have gradle and my project dependencies already downloaded. The <code>Dockerfile</code> is the following:</p>
  
  <pre><code>FROM openjdk:8-jdk
  COPY . /usr/test
  WORKDIR /usr/test
  RUN apt-get -y install wget unzip
  RUN wget https://services.gradle.org/distributions/gradle-4.1-bin.zip
  RUN mkdir /opt/gradle
  RUN unzip -d /opt/gradle gradle-4.1-bin.zip
  RUN /opt/gradle/gradle-4.1/bin/gradle dependencies
  </code></pre>
  
  <p>The <code>build.gradle</code> file is located in same folder as Dockerfile so the command <code>COPY . /usr/test</code> copies it in the working directory.</p>
  
  <p>However, executing the <code>gradle dependencies</code> command does not download the libraries. After built the image, ran a container and entered into it (with docker exec), it seems that <code>~/.gradle/caches/modules-2/files-2.1/</code> directory contains only pom files, not jars.</p>
  
  <p>I'm not use if <code>gradle dependencies</code> is the correct command. Any suggestions?</p>
  
  <p><strong>EDIT - Gradle file</strong></p>
  
  <pre><code>apply plugin: 'java'
  
  sourceCompatibility = 1.8
  
  repositories {
      jcenter()
  }
  
  ext.versions = new Properties()
  file("./versions.properties").withInputStream {
      stream -&gt; ext.versions.load(stream)
  }
  
  dependencies {
      testCompile("org.junit.jupiter:junit-jupiter-api:$versions.junitJupiterVersion")
      testCompile("org.junit.jupiter:junit-jupiter-engine:$versions.junitJupiterVersion")
      testCompile("org.junit.jupiter:junit-jupiter-params:$versions.junitJupiterVersion")
      testCompile("org.mockito:mockito-core:'$versions.mockitoCore")
      testCompile("org.junit.platform:junit-platform-launcher:1.0.0-RC3")
  
      compile("com.google.inject:guice:$versions.guice")
      ....
  }
  </code></pre>