1

Is there an automated way to find out which version of Jersey that Dropwizard depends on?

I'd like to add jersey-apache-connector as a dependency to my project. To make sure it's compatible with the Jersey version included through Dropwizard, I'd like to do something like

compile "org.glassfish.jersey.connectors:jersey-apache-connector:$dropwizardJacksonVersion"
                                                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^

dropwizardJacksonVersion obviously doesn't exist. Is there a simple way solve this programatically?

(I realize I could find out a good version number manually, but it would be nice to just depend on a specific version of Dropwizard, and just follow suit when it comes to Jersey versions.)

aioobe
  • 413,195
  • 112
  • 811
  • 826
  • You can make use of [finding dependency tree](https://stackoverflow.com/questions/21645071/using-gradle-to-find-dependency-tree) on your project that depends on dropwizard verion X, to see what dependencies (with their version number) is it bringing in. – Naman Nov 06 '17 at 16:45
  • That's what I referred to as the "manual" approach above. – aioobe Nov 06 '17 at 16:56
  • and why not specify jersey as a dependency in your project explicitly and use whatever version you need? – Naman Nov 06 '17 at 16:58
  • Because Dropwizard includes Jersey. I don't want to depend on more than 1 version of Jersey. – aioobe Nov 06 '17 at 17:49
  • If your project depends on jersey directly, use a specific version you desire and exclude from other libraries. Or else use it transitively from a specific library and exclude from all others that could bring a conflicting version in. – Naman Nov 07 '17 at 12:42
  • How do I know that the jersey version that I explicitly depend on (and force upon dropwizard) is compatible with dropwizard? I *want* to use the one provided by dropwizard, but I need to also depend on `jersey-apache-connector` and the version of `jersey-apache-connector` needs to agree with the version of Jersey that I use. – aioobe Nov 07 '17 at 15:19
  • Could you print the dependency tree of your project with both the dependencies and highlight which one is supposed to be used by you? Use the previously shared link for the same and tag me in your reply if you update the question. – Naman Nov 08 '17 at 01:18
  • Yes. I could try to "script" the manual process of printing the dependency tree and grep out what I'm looking for. It would be such an ugly hack that I wouldn't consider it a solution however. – aioobe Nov 08 '17 at 06:41

1 Answers1

1

For this purpose you can use Dropwizard BOM.

group 'teestBom'
version '1.0-SNAPSHOT'

buildscript {
    repositories {
        mavenCentral()

    }
    dependencies {
        classpath "io.spring.gradle:dependency-management-plugin:1.0.3.RELEASE"
    }
}


repositories {
    mavenCentral()

}

apply plugin: 'java'
apply plugin: 'io.spring.dependency-management'
sourceCompatibility = 1.8

dependencyManagement {
    imports {
        mavenBom 'io.dropwizard:dropwizard-bom:1.2.0'
    }
}


dependencies {
    compile "org.glassfish.jersey.connectors:jersey-apache-connector"
}

And you not need to define a version of jersey-apache-connector or other libraries, that define in dropwizard bom.