You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Davis Ford <da...@zenoconsulting.biz> on 2009/03/06 01:27:09 UTC
mvn package exclude transitive deps from war archive
Hi, so I have a <packaging>war</packaging> project, with some
dependencies, and I made all the deps be <scope>provided</scope>, but
when I run:
$ mvn package
It still creates a war file with all the deps and transitive deps
under WEB-INF/lib/ - what am I doing wrong? Do I need to use the
maven war plugin?
Thanks in advance,
Davis
--
Zeno Consulting, Inc.
home: http://www.zenoconsulting.biz
blog: http://zenoconsulting.wikidot.com
p: 248.894.4922
f: 313.884.2977
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: mvn package exclude transitive deps from war archive
Posted by Davis Ford <da...@zenoconsulting.biz>.
Hi Wayne, here's a more concrete example. I'm sure I'm just doing
something stupid, but I hope this makes it easier to see the
stupid-ness.
Create a new jar project:
mvn archetype:create -DgroupId=com.example -DartifactId=foo-bar
Make the pom.xml look like this:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>foo-bar</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>foo-bar</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</project>
Create a new war project:
mvn archetype:create -DgroupId=com.example -DartifactId=webapp
-DarchetypeArtifactId=maven-archetype-webapp
Make the pom.xml look like this:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>webapp</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>webapp Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>foo-bar</artifactId>
<version>1.0-SNAPSHOT</version>
<optional>true</optional>
</dependency>
</dependencies>
<build>
<finalName>webapp</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
Do mvn install on the foo-bar project.
Do mvn package on the webapp project. See that all the commons-cli
dependencies are included inside the war WEB-INF/lib directory? How
to only add this to the manifest classpath and not include in
WEB-INF/lib ?
Regards,
Davis
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: mvn package exclude transitive deps from war archive
Posted by Davis Ford <da...@zenoconsulting.biz>.
Hi Wayne, thanks for the reply -- no luck on the clean. I still get
all the jars. See my reply to my post. I configured the war plugin
as per the webpage, but still no luck.
On Thu, Mar 5, 2009 at 8:58 PM, Wayne Fay <wa...@gmail.com> wrote:
>> $ mvn package
>>
>> It still creates a war file with all the deps and transitive deps
>> under WEB-INF/lib/ - what am I doing wrong? Do I need to use the
>> maven war plugin?
>
> Try "mvn clean package". The jars are still sitting in /target, and
> therefore landing in your war.
>
> Wayne
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>
--
Zeno Consulting, Inc.
home: http://www.zenoconsulting.biz
blog: http://zenoconsulting.wikidot.com
p: 248.894.4922
f: 313.884.2977
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: mvn package exclude transitive deps from war archive
Posted by Wayne Fay <wa...@gmail.com>.
> $ mvn package
>
> It still creates a war file with all the deps and transitive deps
> under WEB-INF/lib/ - what am I doing wrong? Do I need to use the
> maven war plugin?
Try "mvn clean package". The jars are still sitting in /target, and
therefore landing in your war.
Wayne
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: mvn package exclude transitive deps from war archive
Posted by Davis Ford <da...@zenoconsulting.biz>.
I managed to exclude direct dependencies and add them to the manifest
classpath as per
http://maven.apache.org/plugins/maven-war-plugin/examples/war-manifest-guide.html
--but it still puts all transitive dependencies in WEB-INF/lib.
For example. Project A is <packaging>jar</packaging>
Project A artifact is jar, and it has a bunch of dependencies.
Project B is <packaging>war</packaging> and depends on project A like this:
<dependency>
<groupId>blah</groupId>
<artifactId>A</artifactId>
<version>blah</version>
<optional>true</optional>
</dependency>
Then I configure maven war plugin like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.0</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>
What I want is that project A and all its transitive dependencies end
up in the Manifest classpath, but are not included in WEB-INF/lib.
What ends up happening with this configuration is that project-A.jar
is excluded from WEB-INF/lib, but it is in the Manifest classpath.
However, all project A's transitive dependencies are included in
WEB-INF/lib and they are in the Manifest classpath. I want the latter
but not the former. What am I missing?
Thanks in advance,
Davis
On Thu, Mar 5, 2009 at 7:27 PM, Davis Ford <da...@zenoconsulting.biz> wrote:
> Hi, so I have a <packaging>war</packaging> project, with some
> dependencies, and I made all the deps be <scope>provided</scope>, but
> when I run:
>
> $ mvn package
>
> It still creates a war file with all the deps and transitive deps
> under WEB-INF/lib/ - what am I doing wrong? Do I need to use the
> maven war plugin?
>
> Thanks in advance,
> Davis
>
> --
> Zeno Consulting, Inc.
> home: http://www.zenoconsulting.biz
> blog: http://zenoconsulting.wikidot.com
> p: 248.894.4922
> f: 313.884.2977
>
--
Zeno Consulting, Inc.
home: http://www.zenoconsulting.biz
blog: http://zenoconsulting.wikidot.com
p: 248.894.4922
f: 313.884.2977
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org