Search code examples
javaeclipsemaven

Maven: Change deploy directory of /src/main/resources


In a dynamic project in Eclipse I would like the files under /src/main/resource to be deployed in a directory other than WEB-INF/classes (specifically I would like to deploy them in WEB-INF/cfg).

I tried to change, in Java Build Path, the "Output folder" with target/cfg and the "Deploy Path" under Deploy Assembly but when I run Maven clean + Maven Install, the files under /src/main/resource continue to be deployed under WEB-INF/classes

enter image description here

enter image description here

enter image description here

enter image description here

Update

This is my pom.xml

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.test</groupId>
    <artifactId>WebAppTest</artifactId>
    <version>01</version>
    <name>WebAppTest</name>
    <packaging>war</packaging>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.2.3</version>
                <configuration>
                    <packagingExcludes></packagingExcludes>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <!-- dependencies -->
</project>

Solution

  • Use src/main/webapp/WEB-INF/cfg instead. The Maven WAR plugin knows all about the src/main/webapp folder, and uses it as the root of the WAR. But you probably already know that, sine you already have a src/main/webapp folder.