Hi I am following the jersey sun documentation. I have deployed before this simple pom.xml before
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.14</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-grizzly2</artifactId>
<version>1.14</version>
</dependency>
and Add the repository
<url>https://maven.java.net/content/repositories/snapshots/</url>
Nevertheless when I try to do this with gradle, it does not seem to be working, is not downloading the rest of dependencies that requires and aparently I have to explicitly put javax.ws.rs:jsr311-api:1.1.1 and even jersey-core. This is my build.gradle.
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'jetty'
sourceCompatibility = 1.6
repositories {
mavenCentral()
maven {
url 'https://maven.java.net/content/repositories/snapshots/'
}
}
List compileLibraries =['com.sun.jersey:jersey-server:1.14',
'com.sun.jersey:jersey-grizzly2:1.14',
'com.sun.jersey:jersey-core:1.14',
'javax.ws.rs:jsr311-api:1.1.1']
dependencies {
compile (compileLibraries )
testCompile group: 'junit', name: 'junit', version: '4.+'
}
httpPort = 8888
stopPort = 9451
stopKey = 'foo'
Is this proper gradle behaviour? How can I do as same as with maven?
Edit
Just for the sake of this and if somebody is interesting in seeing a gradle build file that work with gradle you can go to
https://github.com/necronet/XTradeJerseyimpl/
Thanks!!
Seems that the dependency from jersey-server to jersey-core isn’t being properly interpreted by Gradle. Looking at the pom shows that the jersey-core dependency is in a profile, which is likely why it’s not being picked up. And jersey-core has the dependency on jsr311. Sounds like Gradle should probably account for the profile marked ‘activeByDefault’ in cases like these.
That said, you’ve already hit upon the solution, which is to specify the two jars directly – and it’s still less lines to configure than the maven xml 🙂
Also, it looks like all the jars you need can be found in mavenCentral, so the snapshot repository isn’t contributing anything.
This doesn’t solve the need to explicitly mention those two extra jars, but I hope this explains why, and you might want to raise an issue on Gradle Jira if you think this should be addressed.