如果eclipse.properties不存在,我想将eclipse.properties.ref复制为eclipse.properties。我使用maven 3.2和Java 7。
我尝试了以下操作,但不确定如何将旧文件映射到新文件。
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>copy-resources</id>
<!-- here the phase you need -->
<phase>test</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>/src/test/resources</outputDirectory>
<resources>
<resource>
<directory>/src/test/resources</directory>
<includes>
<include>eclipse.properties.ref</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
答案 0 :(得分:2)
您可以使用maven-antrun-plugin
实现目标。似乎copy
完全符合您的需要。
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<property
name="resources"
value="${project.basedir}/src/test/resources" />
<copy
overwrite="false"
file="${resources}/eclipse.properties.ref"
toFile="${resources}/eclipse.properties" />
</target>
</configuration>
</execution>
</executions>
<强> 注 强>
另外,我建议您复制到${project.build.testOutputDirectory}
而不是${project.basedir}/src/test/resources
,这样就不会损害您的版本控制系统。