1

I use Maven to create WAR of my JEE Application.

Here my pom.xml

<finalName>myproject</finalName>
<sourceDirectory>${basedir}/src</sourceDirectory>
<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.5</version>
    <configuration>
        <warSourceDirectory>WebContent</warSourceDirectory>
        <failOnMissingWebXml>false</failOnMissingWebXml>
        <outputDirectory>/var/www/myproject/webapp</outputDirectory>
    </configuration>    
  </plugin>

  <plugin>
     <inherited>true</inherited>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.2</version>
    <configuration>
      <source>1.8</source>
      <target>1.8</target>
    </configuration>
  </plugin>
</plugins> 

The generated WAR is copied in output folder defined in pom.xml (/var/www/myproject/webapp) but then i want to unpack it before launch my server (Tomcat).

How can i do?

Thanks, Lorenzo

JBerta93
  • 699
  • 3
  • 16
  • 27

2 Answers2

3

If you want to unpack the war, you can use maven assembly plugin for that. E.g.:

 <plugin>
     <groupId>org.apache.maven.plugins</groupId>
     <artifactId>maven-dependency-plugin</artifactId>
     <version>2.10</version>
     <executions>
       <execution>
         <id>unpack</id>
         <phase>package</phase>
         <goals>
           <goal>unpack</goal>
         </goals>
         <configuration>
           <artifactItems>
             <artifactItem>
               <groupId>your group id</groupId>
               <artifactId>your artifact id</artifactId>
               <version> your version</version>
               <type>war</type>
               <overWrite>false</overWrite>
               <outputDirectory>${project.build.directory}/alternateLocation</outputDirectory>
               <destFileName>some name</destFileName>
               <includes>**/*.class,**/*.xml</includes>
               <excludes>**/*test.class</excludes>
             </artifactItem>
       </artifactItems>
       <includes>**/*.java</includes>
       <excludes>**/*.properties</excludes>
       <outputDirectory>your location</outputDirectory>
       <overWriteReleases>false</overWriteReleases>
       <overWriteSnapshots>true</overWriteSnapshots>
     </configuration>
   </execution>
 </executions>

You can read on https://maven.apache.org/plugins/maven-dependency-plugin/examples/unpacking-artifacts.html for more details.

2

You can use maven goal war:exploded

You can see this question

Community
  • 1
  • 1
Dams
  • 997
  • 12
  • 28