此处的文档(http://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html)告诉我应该在target/classes
目录中看到文件后过滤。当我运行compile
或package
时,在任何情况下都不会有在target
目录中生成的classes
目录,因此在那个不存在的目录中没有文件。 (我认为它们可能在compile
期间被创建,但随后作为package
的副产品被删除。)Maven不保存目标/类目录中的任何文件
这是我的目录结构。我有一个主pom.xml为父母和几个子模块与他们自己的pom.xml文件,每个模块下的src dirs。
mexp/
mexp-model/
src/main/java/com/pronto/…
pom.xml
mexp-services/
src/main/java/com/pronto/…
pom.xml
mexp-webapp/
src/
main/
java/
com/
pronto/
mexp/
action/
LoginFormAction.java
pom.xml
pom.xml
这里是我的根pom.xml中build
部分:
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<filters>
<filter>${profile.directory}/${env}/tokens.properties</filter>
</filters>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgument>-g</compilerArgument>
</configuration>
</plugin>
</plugins>
</build>
FWIW,我使用Maven 3.1.1和Java 1.6.0_65,11.1.5的IntelliJ。
我想调试过滤,所以我真的想看到这些结果文件。任何帮助,将不胜感激。谢谢。
编辑:我已将此添加到我的mexp-的webapp/pom.xml中:
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
</plugin>
...
</plugins>
当我与调试命令行中运行它,这就是它说。但是在它声称它正在过滤文件的目录中找不到文件(请原谅我的结尾介词)。
[INFO] Copying 8 resources
[DEBUG] file apsmonitoring.properties has a filtered file extension
[DEBUG] filtering /Volumes/xyz/mexp-removeDAL/mexp-webapp/src/main/resources/apsmonitoring.properties to /Volumes/xyz/mexp-removeDAL/mexp-webapp/target/classes/apsmonitoring.properties
[DEBUG] file config.xml has a filtered file extension
[DEBUG] filtering /Volumes/xyz/mexp-removeDAL/mexp-webapp/src/main/resources/config.xml to /Volumes/xyz/mexp-removeDAL/mexp-webapp/target/classes/config.xml
[DEBUG] file email-configuration.properties has a filtered file extension
[DEBUG] filtering /Volumes/xyz/mexp-removeDAL/mexp-webapp/src/main/resources/email-configuration.properties to /Volumes/xyz/mexp-removeDAL/mexp-webapp/target/classes/email-configuration.properties
[DEBUG] file log4j.real.xml has a filtered file extension
[DEBUG] filtering /Volumes/xyz/mexp-removeDAL/mexp-webapp/src/main/resources/log4j.real.xml to /Volumes/xyz/mexp-removeDAL/mexp-webapp/target/classes/log4j.real.xml
[DEBUG] file log4j.xml has a filtered file extension
[DEBUG] filtering /Volumes/xyz/mexp-removeDAL/mexp-webapp/src/main/resources/log4j.xml to /Volumes/xyz/mexp-removeDAL/mexp-webapp/target/classes/log4j.xml
[DEBUG] file mexp.properties has a filtered file extension
[DEBUG] filtering /Volumes/xyz/mexp-removeDAL/mexp-webapp/src/main/resources/mexp.properties to /Volumes/xyz/mexp-removeDAL/mexp-webapp/target/classes/mexp.properties
[DEBUG] file mexp_globals.properties has a filtered file extension
[DEBUG] filtering /Volumes/xyz/mexp-removeDAL/mexp-webapp/src/main/resources/mexp_globals.properties to /Volumes/xyz/mexp-removeDAL/mexp-webapp/target/classes/mexp_globals.properties
[DEBUG] file mexp_messages.properties has a filtered file extension
[DEBUG] filtering /Volumes/xyz/mexp-removeDAL/mexp-webapp/src/main/resources/mexp_messages.properties to /Volumes/xyz/mexp-removeDAL/mexp-webapp/target/classes/mexp_messages.properties
[DEBUG] no use filter components
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.509s
[INFO] Finished at: Tue Jan 21 15:10:28 EST 2014
[INFO] Final Memory: 4M/81M
[INFO] ------------------------------------------------------------------------
您是否使用IDE生成输出或命令行?为了解决Maven特定的问题,我建议你使用命令行。 –
查看更多内容;我一直在使用它们,但是我在命令行上添加了运行它的输出。 – barclay
解决。显然intelliJ隐藏目标/类目录及其所有内容。当我从命令行查看时,我可以看到我的所有属性文件,按照承诺完美过滤和复制。但更重要的是,我甚至不需要专门使用maven-resources-plugin,只要' ... true ...'存在,maven本身就能够很好地插值。 HTH别人。 –
barclay