Affects Version/s: 3.0.3
Fix Version/s: None
Number of attachments :
Optional compile-time dependencies are being resolved (in WAR projects, at least) into the packaged artifact.
There has been a regression since Maven 2.2.1 in regards to resolving optional dependencies.
In the attached pom (which builds a WAR), there are two dependencies:
- org.springframework:spring-core:2.5.6 - at compile scope
- org.dbunit:dbunit:2.3.0 - at test scope.
The dependency tree looks like this:
| - commons-logging:commons-logging:jar:1.1.1:compile
| - xerces:xmlParserAPIs:jar:2.6.2:test
| - log4j:log4j:jar:1.2.13:test
Note that log4j:log4j:1.2.13 is a test dependency. However, when you do 'mvn package', and inspect the resulting WAR file, it includes log4j!
The problem appears to be that commons-logging (a compile dependency brought in by spring-core) declares log4j as an optional compile dependency. This is clashing with the test dependency brought in transitively by dbunit.
To make it worse, this is still brought in if you add an explicit exclusion of log4j to spring-core.
Maven 2.2.1 did not bring in the log4j JAR - this is a regression under Maven 3.0.3