Maven - exclude folder from build

Cheetah picture Cheetah · Aug 12, 2014 · Viewed 75.5k times · Source

Trying to exlcude a folder src/main/resources/scripts/ from my build but the following does not work:

<build>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <excludes>
                <exclude>src/main/resources/scripts/</exclude>
            </excludes>
        </resource>
    </resources>

    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <excludes>
                    <exclude>src/main/resources/scripts/</exclude>
                </excludes>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
    </plugins>
</build>

Any ideas?

Answer

Robert Scholte picture Robert Scholte · Aug 12, 2014

Instead try:

<exclude>scripts/**</exclude>

The exclude is based on directory, so your construction would exclude

src/main/resources/src/main/resources/scripts