Maven war plugin copy src/main/webapp to classes

eclipse, maven, war

Solution

I had this problem too. It was solved by overriding the maven-war-plugin config by adding it to my pom and including a `<packagingExcludes>` element:

<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.1.1</version>
        <configuration>
           <packagingExcludes>**/webapp</packagingExcludes>
           ...
        </configuration>
    </plugin>
</plugin>

This precluded, as in the OP's case, the copying of the contents of `${basedir}/src/main/webapp`, including `META-INF` and `WEB-INF`, to `target/classes/main/webapp` and subsequently to `target/${finalName}/WEB-INF`.

In effect, maven then behaved as desired, putting the contents of `${basedir}/src/main/webapp` only into `target/${finalName}` and subsequently into the `${finalName}.war`

Problem

Dear stackoverflow members, I am facing a strange issue with Maven war plugin. I have comfigurted my eclipse project directory structure as: ``` Project |-- pom.xml -- src -- main |-- java -- resources -- webapp |-- WEB-INF -- web.xml ``` When I run the maven build command, all the files present within the webapp directory are copied to the classes folder which is strange to me. The resultant directory structure in the generate war file is: ``` |-- META-INF -- WEB-INF -- classes -- -- META-INF -- WEB-INF ``` I didn't expect the META-INF and WEB-INF folders within the classes folder. It's duplicating the data which is not required for the classes folder and these folders are already there at the root of the war file. Please let me know how to restrict the maven war builder to exclude META-INF and WEB-INF going to classes folder ?

Original source