How do I specify excludes when defining dependencies in an array?

(henrik) #1

I am trying to define my dependencies in my root build.gradle, like this:

ext.libs = [
    jersey_common: "org.glassfish.jersey.core:jersey-common:${versions.jersey}",
    jersey_servlet: [ "org.glassfish.jersey.containers:jersey-container-servlet:${versions.jersey}", {
        exclude group: 'javax.validation'
    jersey_server: "org.glassfish.jersey.core:jersey-server:${versions.jersey}",

Then I use them in my subprojects, like this:

dependencies {

It doesn’t like the exclude syntax, though:

FAILURE: Build failed with an exception.
  * Where:
Build file '/path/to/build.gradle' line: 24
  * What went wrong:
A problem occurred evaluating project ':my-test'.
> Cannot convert the provided notation to an object of type Dependency: build_3lp20ohblpvfhdefqk7oi77ih6$_run_closure2@3c5614b2.
  The following types/formats are supported:

How do I specify the excludes properly?

( I was inspired by this post when I defined the excludes: )

(Peter Niederwieser) #2
ext.libs = [
    jersey_servlet: dependencies.create("org.glassfish.jersey.containers:jersey-container-servlet:${versions.jersey}") {
        exclude group: "javax.validation"

(henrik) #3

Thanks again! Impressively fast answer.