In order to use another logging package I need to ensure commons-logging and log4j jar files are not in the class path. I cannot get Maven to exclude them. I'm using Maven 2.0.9.

Here's the scenario: -

Following the Cocoon tutorial [1] I created a Cocoon block called 'myblock' (number 2 on the list of archetypes)

If I change into the 'myblock' folder and run 'mvn package' I notice the following lines in the output: -

 ...
 [INFO] [cocoon:prepare {execution: prepare}]
 [INFO] Preparing a Cocoon web application.
 [INFO] Deploying string-template to WEB-INF/log4j.xml
 [INFO] Adding lib to WEB-INF/lib: commons-logging:commons-logging:1.1:jar
[INFO] Adding lib to WEB-INF/lib: org.apache.commons:commons-jci-core:1.0:jar
 [INFO] Adding lib to WEB-INF/lib: commons-io:commons-io:1.3.1:jar
 [INFO] Adding lib to WEB-INF/lib: log4j:log4j:1.2.14:jar
 ...

That means those jar files will be in the classpath when the web app is run.

So, then I edit the myblock/pom.xml file and add '<exclusion>' tags to all the dependencies I can see like this: -

 <project>
   ...
   <dependencies>
     <dependency>
       <groupId>org.apache.cocoon</groupId>
       <artifactId>cocoon-core</artifactId>
       <version>2.2.0</version>
       <exclusions>
         <exclusion>
           <groupId>commons-logging</groupId>
           <artifactId>commons-logging</artifactId>
         </exclusion>
       </exclusions>
     </dependency>
      ...
   </dependencies>
   ...
 </project>

When I run 'mvn clean package' I get exactly the same results!

When I use the mvn -X parameter to see the debug output as maven runs I get the impression that the maven plugins seem to be adding dependencies to the dependency tree: -

 ...
[DEBUG] Retrieving parent-POM: org.apache.cocoon:cocoon::6 for project: null:cocoon-tools-modules:pom:6 from the repository.
 [DEBUG] Adding managed dependencies for unknown:cocoon-maven-plugin
 ...
 [DEBUG]   commons-logging:commons-logging:jar:1.1
 ...

I suppose I could start fiddling with plugin exclusions but this is getting silly. Do I really have to work this hard to try to make sure a jar file isn't included in the classpath?

Regards,
David Legg

[1] http://cocoon.apache.org/2.2/1159_1_1.html

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to