Simple Gradle, Java, Jersey web service dependency issue


(claytonwohl) #1

I am trying a super simple web services test project with Gradle.

I have a trivial test class that does this:

import com.sun.jersey.test.framework.JerseyTest;

this import fails at testCompile time with the error:

package com.sun.jersey.test.framework does not exist

my build.gradle is very simple:

apply plugin: 'java'
  repositories {
 mavenCentral()
}
  dependencies {
 compile 'com.sun.jersey:jersey-core:1.12'
 compile 'com.sun.jersey:jersey-server:1.12'
 compile 'com.sun.jersey:jersey-grizzly2:1.12'
   testCompile 'com.sun.jersey:jersey-test-framework:1.12'
}

If enable info output (gradle --info --refresh-dependencies clean compileTest), I see:

Cached resource is up-to-date (lastModified: Wed Feb 15 10:55:30 CST 2012). [HTTP: http://repo1.maven.org/maven2/com/sun/jersey/jersey-test-framework/1.12/jersey-test-framework-1.12.pom]
Resource missing. [HTTP HEAD: http://repo1.maven.org/maven2/com/sun/jersey/jersey-test-framework/1.12/jersey-test-framework-1.12.jar]

There are no .jar files in http://repo1.maven.org/maven2/com/sun/jersey/jersey-test-framework/1.12/

If I look at http://repo1.maven.org/maven2/com/sun/jersey/jersey-test-framework/1.12/jersey-test-framework-1.12.pom, it just seems to refererence seven sub-projects. Those sub-projects, such as jersey-test-framework-core, have the jars. For example, I can see jar files in here: http://repo1.maven.org/maven2/com/sun/jersey/jersey-test-framework/jersey-test-framework-core/1.12/

First, that directory path looks suspicious. Shouldn’t the URL be

http://repo1.maven.org/maven2/com/sun/jersey/jersey-test-framework-core/1.12/ instead of http://repo1.maven.org/maven2/com/sun/jersey/jersey-test-framework/jersey-test-framework-core/1.12/

Secondly, shouldn’t Gradle try to get these dependencies and give me an error related to that?

Thanks for any help!


(Peter Niederwieser) #2

The modules element in a Maven POM is a compile-time construct. It has no effect on transitive dependency resolution, neither in Gradle nor in Maven. Unless Jersey provides an aggregate POM that lists those modules as dependencies, you’ll have to explicitly list the required modules in your Gradle build script.