Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building .war file using maven. Missing files and directories

I try to build .war file by using maven plugin:

  <plugin>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.6</version>
    <configuration>
      <warSourceDirectory>WebContent</warSourceDirectory>
      <failOnMissingWebXml>false</failOnMissingWebXml>
    </configuration>
  </plugin>

My project structure looks like:

/main/webapp/WEB-INF/
/main/webapp/WEB-INF/spring/...
/main/webapp/WEB-INF/web.xml
/main/webapp/public/...
/main/webapp/resources/...
/main/webapp/views/...

After building, my war file contains only WEB-INF and META-INF. All other content of webapp directory is missing (public, resources and views). Furthermore the WEB-INF dir in .war file consists only /classes and /lib directories (/WEB-INF/spring and WEB-INF/web.xml are missig).

How to tell maven to pack all webapp and WEB-INF directory content into war file?

like image 499
Mariusz.v7 Avatar asked Oct 30 '22 18:10

Mariusz.v7


1 Answers

There is a mismatch between your configuration of the maven-war-plugin and the structure of your project. With <warSourceDirectory>WebContent</warSourceDirectory>, you are configuration the maven-war-plugin to look for your webapp sources inside the WebContent directory. However, your sources are in main/webapp.

I suggest you move all of your webapp sources inside src/main/webapp (instead of main/webapp) and update the maven-war-plugin configuration to:

<plugin>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.6</version>
    <configuration>
         <failOnMissingWebXml>false</failOnMissingWebXml>
    </configuration>
</plugin>

By default, the maven-war-plugin will be looking for your webapp sources inside src/main/webapp.

like image 194
Tunaki Avatar answered Nov 02 '22 09:11

Tunaki