3

I have he following structure of a maven web application

enter image description here

When I execute mvn install command it's creating war file but if you will look in target directory/sureportal you can easily see that lots of sub folders inside webapps directory are missing. What is wrong?

pom.xml file

<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.nokia</groupId>
  <artifactId>sureportal</artifactId>
  <packaging>war</packaging>
  <version>1.0.0</version>
  <name>sureportal Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <finalName>sureportal</finalName>
  </build>
</project>
Subodh Joshi
  • 12,717
  • 29
  • 108
  • 202

3 Answers3

3

You can have a maven-war-plugin and configure to include empty folders.

<plugin>
  <artifactId>maven-war-plugin</artifactId>
  <version>2.4</version>
  <configuration>
    <includeEmptyDirectories>true</includeEmptyDirectories> 
  </configuration>
</plugin>
dileep H
  • 355
  • 1
  • 3
  • 9
  • exactly the same solution as mine. See the comments in my POM fragment ... but no problem – JimHawkins Aug 25 '16 at 10:22
  • @JimHawkins Sorry to say your code tag have plenty of thing which make little bit clumsy this answer specific to answer. Any how thanks for your time and support. – Subodh Joshi Aug 25 '16 at 10:25
2

In addition to the answer of sbaitmangalkar, insert the maven-war-plugin to the build section of your POM:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <!-  if you don't have a web.xml, otherwise "true" -->
                <failOnMissingWebXml>false</failOnMissingWebXml>
                <includeEmptyDirectories>true</includeEmptyDirectories>
                <includes>**/*</includes>

                <!-- if want your web files to be filterd -->
                <webResources>
                    <resource>
                        <directory>src/main/webapp</directory>
                        <includes>
                            <include>**/*</include>
                        </includes>
                        <filtering>true</filtering>
                    </resource>
                    <resource>
                        <directory>src/main/resources/META-INF</directory>

                        <!-- only if needed in your project -->
                        <targetPath>/META-INF</targetPath>
                        <includes>
                            <include>context.xml</include>
                        </includes>
                        <filtering>true</filtering>
                    </resource>
                </webResources>

            </configuration>
        </plugin>
    </plugins>
</build>

This tells the build process explicitly what to do.

JimHawkins
  • 4,843
  • 8
  • 35
  • 55
0

Try running mvn clean install. This will clear your compiled files first and ensures that all of it is compiled from scratch. Please check this thread for more details how-is-mvn-clean-install-different-from-mvn-install

Good luck.

Community
  • 1
  • 1
Shyam Baitmangalkar
  • 1,075
  • 12
  • 18