Jersey + Gradle with maven dependencies not working

Hi, I'm following the jersey documentation. I unfolded 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 repository

  <url>https://maven.java.net/content/repositories/snapshots/</url> 

However, when I try to do this with gradle, it does not seem to work, it does not load the rest of the dependencies that are required, and obviously I have to explicitly put javax.ws.rs:jsr311-api:1.1.1 and even the 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 the correct gradle behavior? How can I do the same as with maven?

Edit

Just for the sake of this, and if someone is interested in seeing the gradle assembly file that works with gradle, you can go to

https://github.com/necronet/XTradeJerseyimpl/

Thanks!!

+4
source share
1 answer

It seems that the dependency on the jersey server to the jersey kernel is not being properly interpreted by Gradle. Looking at pom shows that the dependence on the jersey core depends on the profile, which, most likely, is not selected. And the jersey-core has a dependency on jsr311. It seems that Gradle should probably consider the profile marked as "activeByDefault" in such cases.

However, you have already pressed on a solution that should specify two jars directly - and even fewer lines to configure than maven xml :)

In addition, it looks like all the banks you need can be found in mavenCentral, so the snapshot repository does nothing.

This will not solve the need to explicitly mention these two additional jars, but I hope this explains why, and you can put the problem on Gradle Jira if you think it needs to be resolved.

+3
source

Source: https://habr.com/ru/post/1442661/


All Articles