Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filtering in maven-war-plugin does not exclude directory

This is a followup of my yesterday question Conditionally exclude some resources in maven from war. I was able to rearrange both development and production wars but filtering copies a directory properties to the war though it shall be excluded according to documentation. I could use packagingExcludes option, but I wonder why excludes does not work. Thank you for explanation.

<plugin>
    <artifactId>maven-war-plugin</artifactId>
    <configuration>
        <classifier>dev</classifier>
        <webappDirectory>${project.build.directory}/${project.build.finalName}-dev</webappDirectory>
        <filters>
            <filter>${project.basedir}/configurations/properties/config_dev.prop</filter>
        </filters>
        <webResources>
            <resource>
                <directory>configurations</directory>
                <filtering>true</filtering>
                <targetPath>WEB-INF/classes</targetPath>
                <excludes>
                    <exclude>**/properties</exclude>
                </excludes>
            </resource>
        </webResources>
    </configuration>
    <executions>
        <execution>
            <id>package-prod</id>
            <phase>package</phase>
            <configuration>
                <classifier>prod</classifier>
                <webappDirectory>${project.build.directory}/${project.build.finalName}-prod</webappDirectory>
                <packagingExcludes>WEB-INF/classes/*.jks,WEB-INF/classes/acquirer.properties</packagingExcludes>
                <filters>
                    <filter>${project.basedir}/configurations/properties/config_prod.prop</filter>
                </filters>
                <webResources>
                    <resource>
                        <directory>configurations</directory>
                        <filtering>true</filtering>
                        <targetPath>WEB-INF/classes</targetPath>
                        <excludes>
                            <exclude>**/properties</exclude>
                        </excludes>
                    </resource>
                </webResources>
            </configuration>
            <goals>
                <goal>war</goal>
            </goals>
        </execution>
    </executions>
</plugin>
like image 724
Leos Literak Avatar asked Jan 22 '26 23:01

Leos Literak


1 Answers

The exclusions for resources are on file base, i.e. they ignore folders. This is because of potential filtering done for webResources.

So, the globs in excludes are applied to all files in the directory, any file matching an exclude glob is excluded.

However, you only excluded a directory.

Change to **/properties/* or **/properties/** and it will work.

like image 177
blackbuild Avatar answered Jan 24 '26 14:01

blackbuild