You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "Fuke, Amol" <Am...@nielsen.com> on 2011/03/01 06:29:01 UTC
RE: Unwanted jars getting copied
Thanks Hilco for the reply.
We are using war plugin also;
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webXml>conf/web.xml</webXml>
<webappDirectory>target/work/outbound</webappDirectory>
</configuration>
</plugin>
But it does not copy all the required jars into war so additionally we are using below dependency.
Thanks,
Amol
-----Original Message-----
From: Hilco Wijbenga [mailto:hilco.wijbenga@gmail.com]
Sent: Monday, February 28, 2011 10:39 PM
To: Maven Users List
Cc: Fuke, Amol
Subject: Re: Unwanted jars getting copied
On 28 February 2011 06:53, Fuke, Amol <Am...@nielsen.com> wrote:
> I am using below snippet to copy dependant jars from lib to war. But this
> also copying some unwanted jars like rt.jar and tools.jar.
>
> Is there any way I exclude them from getting copied into my war.
>
> <plugin>
> <artifactId>maven-dependency-plugin</artifactId>
> <executions>
> <execution>
> <phase>install</phase>
> <goals>
> <goal>copy-dependencies</goal>
> </goals>
> <configuration>
> <outputDirectory>${project.build.directory}/lib</outputDirectory>
> </configuration>
> </execution>
> </executions>
> </plugin>
Why don't you simply use the Maven WAR Plugin?
Re: Unwanted jars getting copied
Posted by Kalpak Gadre <ka...@gmail.com>.
Hi Amol,
The rt.jar and tools.jar maybe be transitively referenced in your project.
Try mvn dependency:tree on your project. This will list all the
dependencies in a hierarchy. You can find which exact dependency is
referencing the rt.jar and tools.jar libraries.
It is questionable why rt.jar would referenced by some project. I have
seen tools.jar being referenced in some open source projects.
If I was writing a pom which needs rt.jar or tools.jar, I would define
the scope as "provided", so if you can control the pom of a dependency
referencing these jars, change the dependencies to have scope "provided".
In case these are a being referenced by some of the third party
libraries and you cannot change the pom.xml, use dependency exclusion.
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>2.4.0</version>
<exclusions>
<exclusion>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
</exclusion>
</exclusions>
</dependency>
> Hi Hilco ,
>
> Sorry for the late reply.
>
> Here is the complete pom.xml. The problem is rt.jar and tools.jar are getting added in war file which we don’t want.
>
> <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/xsd/maven-4.0.0.xsd">
> <modelVersion>4.0.0</modelVersion>
>
> <groupId>com.nielsen.outbound</groupId>
> <artifactId>outbound</artifactId>
> <version>1.0-SNAPSHOT</version>
> <packaging>war</packaging>
> <name>outbound</name>
> <url>http://maven.apache.org</url>
>
> <properties>
> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
> <server.dir>/Tomcat6/webapps/</server.dir>
> <war.name>outbound</war.name>
> <webapp.dir>${project.build.directory}/work/outbound</webapp.dir>
> </properties>
>
> <dependencies>
> <dependency>
> <groupId>com.nielsen.online.iat</groupId>
> <artifactId>infrastructure</artifactId>
> <version>1.1</version>
> </dependency>
> <dependency>
> <groupId>junit</groupId>
> <artifactId>junit</artifactId>
> <version>4.4</version>
> <scope>test</scope>
> </dependency>
> <dependency>
> <groupId>log4j</groupId>
> <artifactId>log4j</artifactId>
> <version>1.2.14</version>
> <scope>provided</scope>
> </dependency>
> <dependency>
> <groupId>javax.ws</groupId>
> <artifactId>jersey-core</artifactId>
> <version>1.1.5</version>
> <scope>provided</scope>
> </dependency>
> <dependency>
> <groupId>javax.ws</groupId>
> <artifactId>jersey-client</artifactId>
> <version>1.1.5</version>
> <scope>provided</scope>
> </dependency>
> <dependency>
> <groupId>com.sun.jsr</groupId>
> <artifactId>jsr311-api</artifactId>
> <version>1.0</version>
> <scope>provided</scope>
> </dependency>
> <dependency>
> <groupId>com.sun.jsr</groupId>
> <artifactId>jsr311-api</artifactId>
> <version>1.1</version>
> <scope>provided</scope>
> </dependency>
> <dependency>
> <groupId>org.google</groupId>
> <artifactId>core4j</artifactId>
> <version>0.3</version>
> </dependency>
> <dependency>
> <groupId>org.google</groupId>
> <artifactId>odata4j</artifactId>
> <version>1.0</version>
> </dependency>
> <dependency>
> <groupId>commons-lang</groupId>
> <artifactId>commons-lang</artifactId>
> <version>2.4</version>
> <scope>provided</scope>
> </dependency>
> <dependency>
> <groupId>commons-discovery</groupId>
> <artifactId>commons-discovery</artifactId>
> <version>0.2</version>
> </dependency>
> <dependency>
> <groupId>net.sf.ehcache</groupId>
> <artifactId>ehcache</artifactId>
> <version>1.5.0</version>
> <scope>provided</scope>
> </dependency>
> <dependency>
> <groupId>com.sun.jersey.api</groupId>
> <artifactId>core</artifactId>
> <version>1.1.5</version>
> <scope>provided</scope>
> </dependency>
> <dependency>
> <groupId>org</groupId>
> <artifactId>json</artifactId>
> <version>1.0</version>
> <scope>provided</scope>
> </dependency>
> <dependency>
> <groupId>com.sun.jersey</groupId>
> <artifactId>server</artifactId>
> <version>1.1.5</version>
> <scope>provided</scope>
> </dependency>
> <dependency>
> <groupId>backport-util-concurrent</groupId>
> <artifactId>backport-util-concurrent</artifactId>
> <version>3.0</version>
> <scope>provided</scope>
> </dependency>
> <dependency>
> <groupId>org.apache.axis</groupId>
> <artifactId>axis-jaxrpc</artifactId>
> <version>1.4</version>
> </dependency>
> <dependency>
> <groupId>org.apache.axis</groupId>
> <artifactId>axis</artifactId>
> <version>1.4</version>
> </dependency>
> <dependency>
> <groupId>com.nielsen.online.iat</groupId>
> <artifactId>nbm-utils</artifactId>
> <version>1.0-SNAPSHOT</version>
> <scope>provided</scope>
> </dependency>
> <dependency>
> <groupId>asm</groupId>
> <artifactId>asm</artifactId>
> <version>3.1</version>
> <scope>provided</scope>
> </dependency>
> <dependency>
> <groupId>wsdl4j</groupId>
> <artifactId>wsdl4j</artifactId>
> <version>1.6.2</version>
> <scope>provided</scope>
> </dependency>
> <!--<dependency>
> <groupId>org.joda</groupId>
> <artifactId>joda-time</artifactId>
> <version>1.6</version>
> <scope>provided</scope>
> </dependency> -->
> <dependency>
> <groupId>org.mockito</groupId>
> <artifactId>mockito-all</artifactId>
> <version>1.8.5</version>
> <scope>test</scope>
> </dependency>
> </dependencies>
> <build>
> <plugins>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-compiler-plugin</artifactId>
> <configuration>
> <source>1.6</source>
> <target>1.6</target>
> </configuration>
> </plugin>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-war-plugin</artifactId>
> <configuration>
> <webXml>conf/web.xml</webXml>
> <webappDirectory>${webapp.dir}</webappDirectory>
> </configuration>
> </plugin>
> <plugin>
> <artifactId>maven-dependency-plugin</artifactId>
> <executions>
> <execution>
> <goals>
> <goal>copy-dependencies</goal>
> </goals>
> <configuration>
> <outputDirectory>${webapp.dir}/WEB-INF/lib</outputDirectory>
> </configuration>
> </execution>
> </executions>
> </plugin>
> <plugin>
> <artifactId>maven-antrun-plugin</artifactId>
> <version>1.6</version>
> <executions>
> <execution>
> <phase>install</phase>
> <configuration>
> <target>
> <delete includeEmptyDirs="true" dir="${server.dir}/${war.name}" />
> <copy file="${project.build.directory}/outbound-1.0-SNAPSHOT.war"
> tofile="${server.dir}/${war.name}.war" />
> </target>
> </configuration>
> <goals>
> <goal>run</goal>
> </goals>
> </execution>
> </executions>
> </plugin>
> <plugin>
> <groupId>org.codehaus.mojo</groupId>
> <artifactId>sonar-maven-plugin</artifactId>
> <version>1.0-beta-2</version>
> </plugin>
> </plugins>
> </build>
> </project>
>
> -----Original Message-----
> From: Hilco Wijbenga [mailto:hilco.wijbenga@gmail.com]
> Sent: Tuesday, March 01, 2011 10:58 PM
> To: Fuke, Amol
> Cc: Maven Users List
> Subject: Re: Unwanted jars getting copied
>
> On 1 March 2011 10:24, Fuke, Amol<Am...@nielsen.com> wrote:
>> Also is there any way we can replace hard coding with variable names?
>>
>> I have below code and I want server path with variables.
>>
>> <target>
>> <delete includeEmptyDirs="true" dir="C:/Tomcat6/webapps/outbound" />
>> <copy file="${project.build.directory}/outbound-1.0-SNAPSHOT.war"
>> tofile="C:/Tomcat6/webapps/outbound.war" />
>> </target>
> Use properties? I'm not sure this is the right approach, you're
> showing us only tiny snippets of your environment. It might help if
> you could describe (at a high level) what you're trying to accomplish.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
RE: Unwanted jars getting copied
Posted by "Fuke, Amol" <Am...@nielsen.com>.
Hi Hilco ,
Sorry for the late reply.
Here is the complete pom.xml. The problem is rt.jar and tools.jar are getting added in war file which we don’t want.
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.nielsen.outbound</groupId>
<artifactId>outbound</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>outbound</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<server.dir>/Tomcat6/webapps/</server.dir>
<war.name>outbound</war.name>
<webapp.dir>${project.build.directory}/work/outbound</webapp.dir>
</properties>
<dependencies>
<dependency>
<groupId>com.nielsen.online.iat</groupId>
<artifactId>infrastructure</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.ws</groupId>
<artifactId>jersey-core</artifactId>
<version>1.1.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.ws</groupId>
<artifactId>jersey-client</artifactId>
<version>1.1.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.jsr</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.jsr</groupId>
<artifactId>jsr311-api</artifactId>
<version>1.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.google</groupId>
<artifactId>core4j</artifactId>
<version>0.3</version>
</dependency>
<dependency>
<groupId>org.google</groupId>
<artifactId>odata4j</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-discovery</groupId>
<artifactId>commons-discovery</artifactId>
<version>0.2</version>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
<version>1.5.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey.api</groupId>
<artifactId>core</artifactId>
<version>1.1.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org</groupId>
<artifactId>json</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>server</artifactId>
<version>1.1.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>backport-util-concurrent</groupId>
<artifactId>backport-util-concurrent</artifactId>
<version>3.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.axis</groupId>
<artifactId>axis-jaxrpc</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.axis</groupId>
<artifactId>axis</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>com.nielsen.online.iat</groupId>
<artifactId>nbm-utils</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
<version>3.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
<version>1.6.2</version>
<scope>provided</scope>
</dependency>
<!-- <dependency>
<groupId>org.joda</groupId>
<artifactId>joda-time</artifactId>
<version>1.6</version>
<scope>provided</scope>
</dependency> -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<version>1.8.5</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webXml>conf/web.xml</webXml>
<webappDirectory>${webapp.dir}</webappDirectory>
</configuration>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${webapp.dir}/WEB-INF/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<phase>install</phase>
<configuration>
<target>
<delete includeEmptyDirs="true" dir="${server.dir}/${war.name}" />
<copy file="${project.build.directory}/outbound-1.0-SNAPSHOT.war"
tofile="${server.dir}/${war.name}.war" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>1.0-beta-2</version>
</plugin>
</plugins>
</build>
</project>
-----Original Message-----
From: Hilco Wijbenga [mailto:hilco.wijbenga@gmail.com]
Sent: Tuesday, March 01, 2011 10:58 PM
To: Fuke, Amol
Cc: Maven Users List
Subject: Re: Unwanted jars getting copied
On 1 March 2011 10:24, Fuke, Amol <Am...@nielsen.com> wrote:
> Also is there any way we can replace hard coding with variable names?
>
> I have below code and I want server path with variables.
>
> <target>
> <delete includeEmptyDirs="true" dir="C:/Tomcat6/webapps/outbound" />
> <copy file="${project.build.directory}/outbound-1.0-SNAPSHOT.war"
> tofile="C:/Tomcat6/webapps/outbound.war" />
> </target>
Use properties? I'm not sure this is the right approach, you're
showing us only tiny snippets of your environment. It might help if
you could describe (at a high level) what you're trying to accomplish.
Re: Unwanted jars getting copied
Posted by Hilco Wijbenga <hi...@gmail.com>.
On 1 March 2011 10:24, Fuke, Amol <Am...@nielsen.com> wrote:
> Also is there any way we can replace hard coding with variable names?
>
> I have below code and I want server path with variables.
>
> <target>
> <delete includeEmptyDirs="true" dir="C:/Tomcat6/webapps/outbound" />
> <copy file="${project.build.directory}/outbound-1.0-SNAPSHOT.war"
> tofile="C:/Tomcat6/webapps/outbound.war" />
> </target>
Use properties? I'm not sure this is the right approach, you're
showing us only tiny snippets of your environment. It might help if
you could describe (at a high level) what you're trying to accomplish.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
RE: Unwanted jars getting copied
Posted by "Fuke, Amol" <Am...@nielsen.com>.
Hi Hilco ,
Removed the target/work/outbound. Thanks for that.
Also is there any way we can replace hard coding with variable names?
I have below code and I want server path with variables.
<target>
<delete includeEmptyDirs="true" dir="C:/Tomcat6/webapps/outbound" />
<copy file="${project.build.directory}/outbound-1.0-SNAPSHOT.war"
tofile="C:/Tomcat6/webapps/outbound.war" />
</target>
Thanks,
Amol
-----Original Message-----
From: Hilco Wijbenga [mailto:hilco.wijbenga@gmail.com]
Sent: Tuesday, March 01, 2011 11:12 AM
To: Fuke, Amol
Cc: Maven Users List
Subject: Re: Unwanted jars getting copied
On 1 March 2011 05:29, Fuke, Amol <Am...@nielsen.com> wrote:
> Thanks Hilco for the reply.
>
> We are using war plugin also;
>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-war-plugin</artifactId>
> <configuration>
> <webXml>conf/web.xml</webXml>
> <webappDirectory>target/work/outbound</webappDirectory>
> </configuration>
> </plugin>
>
> But it does not copy all the required jars into war so additionally we are using below dependency.
That seems highly unlikely unless you're not listing those "required"
JARs as dependencies?
P.S. Unless you have a specific reason to use target/work/outbound, I
would suggest you go with the default. Less to maintain means less
work. :-)
Re: Unwanted jars getting copied
Posted by Hilco Wijbenga <hi...@gmail.com>.
On 1 March 2011 05:29, Fuke, Amol <Am...@nielsen.com> wrote:
> Thanks Hilco for the reply.
>
> We are using war plugin also;
>
> <plugin>
> <groupId>org.apache.maven.plugins</groupId>
> <artifactId>maven-war-plugin</artifactId>
> <configuration>
> <webXml>conf/web.xml</webXml>
> <webappDirectory>target/work/outbound</webappDirectory>
> </configuration>
> </plugin>
>
> But it does not copy all the required jars into war so additionally we are using below dependency.
That seems highly unlikely unless you're not listing those "required"
JARs as dependencies?
P.S. Unless you have a specific reason to use target/work/outbound, I
would suggest you go with the default. Less to maintain means less
work. :-)