cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Reinhard Pötz <reinh...@apache.org>
Subject Re: C2.2 - Cannot remove jar files from classpath using Maven
Date Sun, 20 Jul 2008 15:02:07 GMT
David Legg wrote:
> 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?

Use the Maven dependency plugin (the 'tree' goal) to find out what 
dependencies have a dependency on the libraries that you want to remove. 
Then you have to remove them from ALL occurrences by adding <exclusions> 
sections.

-- 
Reinhard Pötz                           Managing Director, {Indoqa} GmbH
                          http://www.indoqa.com/en/people/reinhard.poetz/

Member of the Apache Software Foundation
Apache Cocoon Committer, PMC member                  reinhard@apache.org
________________________________________________________________________

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message