javaeclipsegoogle-app-enginegradlegradle-eclipse

Eclipse Luna Gradle Plugin adds a dependency that is not referenced


I'm using Eclipse Luna and the Gradle Plugin for Eclipse Luna (Using the Gradle IDE Pack 3.6.x from Pivotal). I created a simple Java project with Gradle support. Below my build.gradle

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'artifactory'

buildscript {
  repositories {
    maven { url 'http://dl.bintray.com/jfrog/jfrog-jars' }
    mavenCentral()
  }

  dependencies {
    classpath(group: 'org.jfrog.buildinfo', name: 'build-info-extractor-gradle', version: '2.2.4')
  }
}

version = '1.0'

repositories {
  maven { url 'http://maven.restlet.com' }
  mavenCentral()
}

dependencies {
  compile group: 'com.cloudit4', name: 'cit4-util-lib', version: '1.0'
  compile group: 'org.restlet.gae', name: 'org.restlet', version: '2.3.2'
  compile group: 'org.restlet.gae', name: 'org.restlet.ext.servlet', version: '2.3.2'
}

// Artifactory...
artifactory {
  contextUrl = 'http://192.168.245.1:8081/artifactory'   //The base Artifactory URL if not overridden by the publisher/resolver
  publish {
    contextUrl = 'http://192.168.245.1:8081/artifactory'   //The base Artifactory URL for the publisher
    //A closure defining publishing information
    repository {
        repoKey = 'libs-release-local'   //The Artifactory repository key to publish to
        username = 'admin'          //The publisher user name
        password = 'mypass'       //The publisher password
    }
  }
  resolve {
    contextUrl = 'http://192.168.245.1:8081/artifactory'   //The base Artifactory URL for the resolver
    repository {
        repoKey = 'repo'  //The Artifactory (preferably virtual) repository key to resolve from
    }
  }
}

As you may notice, I'm using Artifactory to host my own artifacts (local libraries, cit4-util-lib). Normally I work with projects that uses the Google App Engine library, and many times I included it in Gradle using the appengine plugin for gradle. But as you may see, this is not the case this time. None of the dependencies has a dependency for Google App Engine libraries. But when I do execute a Gradle dependencies refresh, a Google App Engine library is included in my dependencies. Somebody has seen this kind of behaviour? Where does gradle looks for libraries to include in the project? Is it only the dependencies that are explicitly set in the build.gradle file or are there more?


Solution

  • When you put a dependency in the dependency closure, gradle will included all of those depedencies' dependencies. (look for "transitive dependencies" on https://docs.gradle.org/current/userguide/artifact_dependencies_tutorial.html)

    Taking a look at an old version of the pom for the org.restlet.gae dependency: https://mvnrepository.com/artifact/org.restlet.gae/org.restlet/2.3.1/pombroken link you can see the appengine dependency. I would think that's where it's coming from.