Hi Eugene,
on page 252 of Better Builds with Maven:
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.9</version>
<optional>true</optional>
</dependency>
Notice that log4j is marked as optional. Optional dependencies are
not included transitively, so
log4j will not be included in other projects that depend on this.
This is because in other projects,
you may decide to use another log implementation, and it is just for
the convenience of the users.
Using the optional tag does not affect the current project.
This is exactly the case I described with Commons Configuration and
servletapi artefact.
My project doesn't need servletapi for compilation, CC does. In my case
servletapi will end up in Maven 2 Dependencies library and therefore
will be copied by libcopy plugin to lib directory of my web application.
The consequence is that servlet api ends up deployed, but servletapi is
already provided by Tomcat container.
Cheers,
Borut
Eugene Kuleshov wrote:
Not necessary. Transitive dependencies will appear in classpath
container, as long as they are needed for compilation.
Borut Bolčina wrote:
Let's say my project depends on Commons Configuration 1.3. The CCs
POM file
(http://maven.sateh.com/repository/commons-configuration/commons-configuration/1.3/commons-configuration-1.3.pom)
has this entry
<dependency>
<groupId>servletapi</groupId>
<artifactId>servletapi</artifactId>
<version>2.4</version>
<optional>true</optional>
</dependency>
this jar should not end up in Maven 2 Dependecies Eclipse library,
should it? My project will provide its own servlet version or not any
at all.
Cheers,
Borut
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email