【发布时间】:2014-01-21 19:24:48
【问题描述】:
此处的文档 (http://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html) 告诉我,我应该在 target/classes 目录中看到过滤后的文件。当我运行compile 或package 时,在这两种情况下都没有在target 目录中生成classes 目录,因此在那个不存在的目录中也没有文件。 (我认为它们可能是在 compile 期间创建的,但随后作为 package 的副产品被删除。)
这是我的目录结构。我有一个用于父模块的主 pom.xml 和几个带有自己 pom.xml 文件的子模块,每个模块下都有 src 目录。
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,IntelliJ 11.1.5。
我正在尝试调试过滤,所以我真的很想查看那些生成的文件。任何帮助,将不胜感激。谢谢。
已编辑:我将此添加到我的 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 特定问题,我建议您使用命令行。
-
查看更多内容;我一直在使用两者,但我添加了在命令行上运行它的输出。
-
已解决。显然,intelliJ 隐藏了目标/类目录及其所有内容。当我从命令行查看时,我可以看到我所有的属性文件,按照承诺完美过滤和复制。但更重要的是,我什至不需要专门使用 maven-resources-plugin,只要存在
<build><resources><resource>...<filtering>true</filtering></resource></resources>...,maven 本身就能够很好地插入值。 HTH 别人。
标签: java maven intellij-idea maven-3