We have been using M3 since it was released. Recently, I’ve spent some time trying to get us moved to M8 (more recently M9). One of the things I’ve encounted is, whereas I used to to this to exclude Log4j’s optional dependencies:
I tried removing the “module” portion, but that does not work either. As I do not have a repo containing those JARs, Gradle fails with this:
:dm-ctt:compileJava
Download http://nexus01.ad.rds.lexmark.com/content/repositories/thirdparty/javax/jms/jms/1.1/jms-1.1.pom
> Building > :dm-ctt:compileJava > Resolving dependencies ':dm-ctt:compile' > 67Download http://nexus01.ad.rds.lexmark.com/content/repositories/central/com/sun/jdmk/jmxtools/1.2.1/jmxtools-1.2.1.pom
> Building > :dm-ctt:compileJava > Resolving dependencies ':dm-ctt:compile' > 40Download http://nexus01.ad.rds.lexmark.com/content/repositories/central/com/sun/jmx/jmxri/1.2.1/jmxri-1.2.1.pom
> Building > :dm-ctt:compileJava > Resolving dependencies ':dm-ctt:compile' > 15
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all dependencies for configuration ':dm-ctt:compile'.
> Artifact 'javax.jms:jms:1.1@jar' not found.
Hello Jamie, your original snippet looks correct for me and I am not able to reproduce your problem, as the exclusions work for me as expected. Can you provide an small example build file, that points us to the problem. BTW, I’ve tested your snippet with mavenCentral and log4j Version 1.2.15.
In the process, I discovered that if the Cobertura ‘testRuntime’ dependency is commented out, things seem to build just fine. However, with that dependency (though it doesn’t seem to have anything to do with JMS, etc.) the build fails with the message in my previous post.
in your example the transitive dependencies are resolved in the test task when the runtime (more precisely testRuntime) configuration is resolved. Though the testRuntime configuration is composed of different other configurations, the exclude definitions are not inherited from them and must be set per configuration explicitly. That’s the reason why your second snippet works.