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>
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.