Java Maven资源过滤不';不复制未筛选的文件
我有一个xml文件,其中包含必须用特定值替换的属性。所以我使用资源过滤来实现这一点 以下是资源结构: pom.xml中的资源筛选使用情况:Java Maven资源过滤不';不复制未筛选的文件,java,maven,Java,Maven,我有一个xml文件,其中包含必须用特定值替换的属性。所以我使用资源过滤来实现这一点 以下是资源结构: pom.xml中的资源筛选使用情况: ${basedir}/src/main/resources 假的 **/瓦丁/主题/* **/UI.gwt.xml ${basedir}/src/main/resources 真的 **/UI.gwt.xml **/瓦丁/主题/* 由于clean install,我收到了带有UI.gwt.xml的.war文件,其中包含替换的属性,但没有VAADIN/th
${basedir}/src/main/resources
假的
**/瓦丁/主题/*
**/UI.gwt.xml
${basedir}/src/main/resources
真的
**/UI.gwt.xml
**/瓦丁/主题/*
由于clean install
,我收到了带有UI.gwt.xml的.war文件,其中包含替换的属性,但没有VAADIN/themes文件夹及其内容。如果我注释
,那么VAADIN/themes会出现在.war文件中,但UI.gwt.xml没有特定的值
我的筛选配置有什么问题?在同一
目录上定义资源时,可以在为true
的资源上使用包含指定要应用筛选的文件,而为false
的资源上使用排除指定不更改的文件。因此,您的示例将成为:
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
<filtering>true</filtering>
<includes>
<!-- whatever is defined here will have filters applied -->
<include>**/UI.gwt.xml</include>
</includes>
</resource>
<resource>
<directory>${basedir}/src/main/resources</directory>
<filtering>false</filtering>
<!-- everything in this directory remains the same (no filters) -->
<excludes>
<!-- the excludes found here will be altered by the filters in the first resource set -->
<!-- so we need to define them as excluded from the files that should not have filters applied -->
<exclude>**/UI.gwt.xml</exclude>
</excludes>
</resource>
</resources>
${basedir}/src/main/resources
真的
**/UI.gwt.xml
${basedir}/src/main/resources
假的
**/UI.gwt.xml
在显示的目录结构中,我看到了VAADIN.themes,但是在配置中,两个参考资料中都有VAADIN/themes。这是问题中的错别字吗?如果不是,这可能就是问题所在。@user944849,我使用的是VAADIN/themes还是VAADIN.themes并不重要。这是如何在我的IDE中显示中间没有内容的包链。但我还是重新检查了它。@user944849,用VAADIN.themes重新检查过-它仍然不起作用。所以我编辑了资源结构以避免混淆其他人。不管我使用什么顺序。它仍然没有复制VAADIN主题:(我正在阅读此链接上最后一个示例中的警告,似乎筛选适用于包含的文件,在第二条规则中,它告诉它如何处理未筛选的文件。尝试从筛选资源中删除排除项是的,我颠倒了筛选顺序(首先是过滤器,然后是w/o过滤器)并删除了VAADIN主题的包含。因此,一切都按我所希望的方式工作。但我仍然无法理解为什么它会以这种方式运行:(
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
<filtering>false</filtering>
<includes>
<include>**/VAADIN/themes/*</include>
</includes>
<excludes>
<exclude>**/UI.gwt.xml</exclude>
</excludes>
</resource>
<resource>
<directory>${basedir}/src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/UI.gwt.xml</include>
</includes>
<excludes>
<exclude>**/VAADIN/themes/*</exclude>
</excludes>
</resource>
</resources>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
<filtering>true</filtering>
<includes>
<!-- whatever is defined here will have filters applied -->
<include>**/UI.gwt.xml</include>
</includes>
</resource>
<resource>
<directory>${basedir}/src/main/resources</directory>
<filtering>false</filtering>
<!-- everything in this directory remains the same (no filters) -->
<excludes>
<!-- the excludes found here will be altered by the filters in the first resource set -->
<!-- so we need to define them as excluded from the files that should not have filters applied -->
<exclude>**/UI.gwt.xml</exclude>
</excludes>
</resource>
</resources>