Java – filter directories in Maven war plugin
•
Java
This is a follow-up to my question yesterday conditionally exclude some resources in Maven from war I can rearrange the development and production war, but the filter copies the directory attribute into the war, although it is excluded according to the documentation I can use the packaging excludes option, but I want to know why exclusion is not possible Thank you for your 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>
Solution
The exclusion of resources is based on files, that is, they ignore folders This is because web resources are potentially filtered
Therefore, the excluded globs apply to all files in the directory and exclude any files that match the excluded globs
However, you have excluded only one directory
Change to * * / properties / * or * * / properties / * *, it will work
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码