Hi,
For some reason I am struggling to
create a war and a jar from a maven war project. I want to create these two
artifacts from my maven war project with following requirements -
Jar
- This should contain all the class files and dependencies of war
project. However dependencies should be copied under lib folder of this
jar and should not be in unpacked form. This part is giving me problem.
War
- For war I simply want to have static artifacts and nothing which is
present under WEB-INF folder. I am able to achieve this using maven war
plugin.
Here is the code present under <build> tag of my pom.xml -
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
<appendAssemblyId>false</appendAssemblyId>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>jar-with-dependencies-in-lib</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<packagingExcludes>WEB-INF/</packagingExcludes>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
Here is content of assembly.xml file which is located directly under project
root directory -
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2
http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>jar-with-dependencies-in-lib</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>target/${project.artifactId}-${project.version}/WEB-INF/lib</directory>
<includes>
<include>target/${project.artifactId}-${project.version}/WEB-INF/classes</include>
</includes>
</fileSet>
</fileSets>
</assembly>
I
feel that I don't need maven-war-plugin at all and both the artifacts
can be created using maven assembly plugin only. However I am unable to
figure out how to achieve this.
- Shailendra