You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Robert Watkins (JIRA)" <ji...@codehaus.org> on 2011/08/01 07:05:42 UTC

[jira] Created: (MNG-5145) Optional compile dependencies being resolved by test dependencies

Optional compile dependencies being resolved by test dependencies
-----------------------------------------------------------------

                 Key: MNG-5145
                 URL: https://jira.codehaus.org/browse/MNG-5145
             Project: Maven 2 & 3
          Issue Type: Bug
          Components: Dependencies
    Affects Versions: 3.0.3
            Reporter: Robert Watkins
            Priority: Critical
         Attachments: pom.xml

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:


net.twasink:webapp:war:1.0
+- org.springframework:spring-core:jar:2.5.6:compile
|  \- commons-logging:commons-logging:jar:1.1.1:compile
\- org.dbunit:dbunit:jar:2.3.0:test
   +- junit:junit:jar:3.8.2:test
   +- junit-addons:junit-addons:jar:1.4:test
   |  +- xerces:xercesImpl:jar:2.6.2:test
   |  \- xerces:xmlParserAPIs:jar:2.6.2:test
   +- org.apache.poi:poi:jar:3.1-FINAL:test
   |  \- log4j:log4j:jar:1.2.13:test
   +- commons-collections:commons-collections:jar:3.1:test
   +- commons-lang:commons-lang:jar:2.1:test
   +- org.slf4j:slf4j-api:jar:1.4.3:test
   \- org.slf4j:slf4j-nop:jar:1.4.3: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

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (MNG-5145) Optional compile dependencies being resolved by test dependencies

Posted by "Benjamin Bentmann (JIRA)" <ji...@codehaus.org>.
    [ https://jira.codehaus.org/browse/MNG-5145?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=274733#comment-274733 ] 

Benjamin Bentmann commented on MNG-5145:
----------------------------------------

Part of the issue is {{commons-logging:1.1}}, declaring {{commons-logging:1.1.1}} in {{<dependencyManagement>}} can be used to workaround the bug.

> Optional compile dependencies being resolved by test dependencies
> -----------------------------------------------------------------
>
>                 Key: MNG-5145
>                 URL: https://jira.codehaus.org/browse/MNG-5145
>             Project: Maven 2 & 3
>          Issue Type: Bug
>          Components: Dependencies
>    Affects Versions: 3.0.3
>            Reporter: Robert Watkins
>            Priority: Critical
>         Attachments: pom.xml
>
>
> 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:
> net.twasink:webapp:war:1.0
> +- org.springframework:spring-core:jar:2.5.6:compile
> |  \- commons-logging:commons-logging:jar:1.1.1:compile
> \- org.dbunit:dbunit:jar:2.3.0:test
>    +- junit:junit:jar:3.8.2:test
>    +- junit-addons:junit-addons:jar:1.4:test
>    |  +- xerces:xercesImpl:jar:2.6.2:test
>    |  \- xerces:xmlParserAPIs:jar:2.6.2:test
>    +- org.apache.poi:poi:jar:3.1-FINAL:test
>    |  \- log4j:log4j:jar:1.2.13:test
>    +- commons-collections:commons-collections:jar:3.1:test
>    +- commons-lang:commons-lang:jar:2.1:test
>    +- org.slf4j:slf4j-api:jar:1.4.3:test
>    \- org.slf4j:slf4j-nop:jar:1.4.3: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

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (MNG-5145) Optional compile dependencies being resolved by test dependencies

Posted by "Robert Watkins (JIRA)" <ji...@codehaus.org>.
    [ https://jira.codehaus.org/browse/MNG-5145?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=274743#comment-274743 ] 

Robert Watkins commented on MNG-5145:
-------------------------------------

Ah - this appears to be related to http://jira.codehaus.org/browse/MNG-5056. Similar behaviour, anyway.

> Optional compile dependencies being resolved by test dependencies
> -----------------------------------------------------------------
>
>                 Key: MNG-5145
>                 URL: https://jira.codehaus.org/browse/MNG-5145
>             Project: Maven 2 & 3
>          Issue Type: Bug
>          Components: Dependencies
>    Affects Versions: 3.0.3
>            Reporter: Robert Watkins
>            Priority: Critical
>         Attachments: pom.xml
>
>
> 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:
> net.twasink:webapp:war:1.0
> +- org.springframework:spring-core:jar:2.5.6:compile
> |  \- commons-logging:commons-logging:jar:1.1.1:compile
> \- org.dbunit:dbunit:jar:2.3.0:test
>    +- junit:junit:jar:3.8.2:test
>    +- junit-addons:junit-addons:jar:1.4:test
>    |  +- xerces:xercesImpl:jar:2.6.2:test
>    |  \- xerces:xmlParserAPIs:jar:2.6.2:test
>    +- org.apache.poi:poi:jar:3.1-FINAL:test
>    |  \- log4j:log4j:jar:1.2.13:test
>    +- commons-collections:commons-collections:jar:3.1:test
>    +- commons-lang:commons-lang:jar:2.1:test
>    +- org.slf4j:slf4j-api:jar:1.4.3:test
>    \- org.slf4j:slf4j-nop:jar:1.4.3: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

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] Commented: (MNG-5145) Optional compile dependencies being resolved by test dependencies

Posted by "Robert Watkins (JIRA)" <ji...@codehaus.org>.
    [ https://jira.codehaus.org/browse/MNG-5145?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=274738#comment-274738 ] 

Robert Watkins commented on MNG-5145:
-------------------------------------

As shown in the dependency tree, this is already using commongs-logging:1.1.1

AFAIK, commons-logging:1.1.1 is doing the right thing by declaring the dependency on log4j optional. Certainly the attached pom worked correctly under Maven 2.2.

> Optional compile dependencies being resolved by test dependencies
> -----------------------------------------------------------------
>
>                 Key: MNG-5145
>                 URL: https://jira.codehaus.org/browse/MNG-5145
>             Project: Maven 2 & 3
>          Issue Type: Bug
>          Components: Dependencies
>    Affects Versions: 3.0.3
>            Reporter: Robert Watkins
>            Priority: Critical
>         Attachments: pom.xml
>
>
> 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:
> net.twasink:webapp:war:1.0
> +- org.springframework:spring-core:jar:2.5.6:compile
> |  \- commons-logging:commons-logging:jar:1.1.1:compile
> \- org.dbunit:dbunit:jar:2.3.0:test
>    +- junit:junit:jar:3.8.2:test
>    +- junit-addons:junit-addons:jar:1.4:test
>    |  +- xerces:xercesImpl:jar:2.6.2:test
>    |  \- xerces:xmlParserAPIs:jar:2.6.2:test
>    +- org.apache.poi:poi:jar:3.1-FINAL:test
>    |  \- log4j:log4j:jar:1.2.13:test
>    +- commons-collections:commons-collections:jar:3.1:test
>    +- commons-lang:commons-lang:jar:2.1:test
>    +- org.slf4j:slf4j-api:jar:1.4.3:test
>    \- org.slf4j:slf4j-nop:jar:1.4.3: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

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira