我有一个多模块Maven项目,其中一个模块的POM定义了几个配置文件,将一些配置文件复制到target/classes
目录:
<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>copy-resources</id>
<!-- Copy common resources that are shared in all environments -->
<phase>validate</phase>
<goals>
<goal>resources</goal>
<goal>testResources</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>conf/</exclude>
</excludes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<!-- Copy environment specific resources according to profile used -->
<profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<testResources>
<testResource>
<directory>src/main/resources/conf/dev</directory>
</testResource>
</testResources>
<resources>
<resource>
<directory>src/main/resources/conf/dev</directory>
</resource>
</resources>
</build>
</profile>
<profile>
<id>rct</id>
<build>
<testResources>
<testResource>
<directory>src/main/resources/conf/rct</directory>
</testResource>
</testResources>
<resources>
<resource>
<directory>src/main/resources/conf/rct</directory>
</resource>
</resources>
</build>
</profile>
<profile>
<id>prd</id>
<build>
<testResources>
<testResource>
<directory>src/main/resources/conf/prd</directory>
</testResource>
</testResources>
<resources>
<resource>
<directory>src/main/resources/conf/prd</directory>
</resource>
</resources>
</build>
</profile>
</profiles>
此模块中的目录src/main/resources
包含以下文件:
02/06/2016 11:15 <DIR> com
02/06/2016 11:07 <DIR> conf
02/06/2016 11:19 857 mybatis-config.xml
conf
目录包含一些环境分隔文件。奇怪的是,在Maven 3.3.9和Maven 3.2.5上执行命令mvn clean validate -Pdev
(从根项目执行)的结果是不同的:
使用Maven 3.3.9在本地计算机上执行后的结果:
02/06/2016 18:01 <DIR> com
02/06/2016 18:01 857 mybatis-config.xml
在Jenkins上执行后的结果(不要在本地安装其他版本的Maven,我相信这不会影响结果,因为Jenkins上的Maven 3.3.9工作得到与本地相同的结果)与Maven 3.2.5:
02/06/2016 11:08 144 database.properties
02/06/2016 12:38 1 062 log4j.xml
如您所见,使用Maven 3.3.9,validate
阶段的资源过滤工作和配置文件中的任务没有执行,而在Maven 3.2.5上它只是反过来。我想知道这会怎么样。 Maven是否有关于此问题的错误?