Removing a jar dependency from ear


(george.maggessy) #1

All,

I have a the following gradle project structure

project-ear
      project-a
      project-b

Project-a - generates a jar as final artifact - has dependencies on some local files.

compile files('lib/filea.jar')
    compile files('lib/fileb.jar')
    compile files('lib/filec.jar')
    compile files('lib/filed.jar')
    compile files('lib/filee.jar')

On the ear project - where I assemble the final ear - I have the project-a referenced as a earlib dependency.

earlib project(':project-a')

As you all might know, all compile dependencies from project-a, get automatically inserted into the APP-INF/lib directory. However, I’d like to exclude only “filea.jar” from this list, which means that having “transitive=false” in the earlib entry is not an option. Any idea how I could exclude filea.jar from my final artifact?

Cheers,


#2

Did you solve this? I’m having the same issue. I can not use ‘exclude’ method because that only works on module dependencies.


(george.maggessy) #3

I made all my projects transitive, and at the ear level I explicitly add each jar. That is, I haven’t solved it. :slight_smile:


(Peter Niederwieser) #4

If you use a ‘flatDir’ repository instead of file dependencies, excludes will work. For example:

repositories {
 flatDir(dirs: "libs") // contains foo-1.0.jar and bar-1.0.jar
}
  configurations {
 earlib
}
  dependencies {
 earlib ":foo:1.0"
 earlib ":bar:1.0"
}
  configurations.earlib.exclude module: "bar"
  task debug << {
  configurations.earlib.each { println it }
}

Output:

:debug
libs/foo-1.0.jar

For more information on ‘flatDir’ repositories, see the Gradle User Guide.


#5

great answer. thanks