I’m working at migrating a project to Gradle from Ant; mostly complete with a few “cleanup” type tasks left. Hoping for some advice/help.
The gist: the code baseline is poorly structured and we have EE projects which depend on SE projects. The SE projects use newer versions of libraries provided by the EE container (Wildfly). Ultimately, I’d like to be able to exclude/substitute some transitive dependencies and replace with the container variation of the library.
Using the resolutionStrategy substitute gets me close. The only shortcoming is the library is included in the WEB-INF/lib folder, which is unnecessary. (Using the war plugin)
Is there a more elegant alternative to (for all of the substituted jars):
war {
rootSpec.exclude('**/foo.jar')
...
}
Or a better alternative all together. Thanks in advance!
Have you tried to use that? I’m not sure if you have deeper dependency issues where something that is ‘provided’ is added to your dependency and you need to ‘rip it out’ later, this may not help you the way you want.
This is an on-the-side task so my work is sporadic - as are my responses. I was able to work around my problem.
For those interested, I ended up solving my problem through the combination of a few mechanisms.
apply plugin: 'war'
dependencies {
providedCompile "org.hibernate:hibernate-core:${providedWildfly.hibernate}"
...
}
configurations.all {
resolutionStrategy.dependencySubstitution {
substitute module("org.hibernate:hibernate-core:${versions.hibernate}") with module("org.hibernate:hibernate-core:${providedWildfly.hibernate}")
}
}
//Handle and exclude a few other pesky transitive dependencies
// Exclude these groups/modules entirely from this project's build
configurations.all*.exclude group: "com.mchange"
war {
//Finally, explicitly remove any file dependencies
rootSpec.exclude("**/local-jar-file-dependency.jar")
}