我们在生产中使用MySQL,单元测试使用Derby。我们的pom.xml的副本德比版测试之前的persistence.xml,并与MySQL的版本替代它,准备封装阶段:如何防止mvn码头:从执行测试阶段运行?
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<id>copy-test-persistence</id>
<phase>process-test-resources</phase>
<configuration>
<tasks>
<!--replace the "proper" persistence.xml with the "test" version-->
<copy
file="${project.build.testOutputDirectory}/META-INF/persistence.xml.test"
tofile="${project.build.outputDirectory}/META-INF/persistence.xml"
overwrite="true" verbose="true" failonerror="true" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
<execution>
<id>restore-persistence</id>
<phase>prepare-package</phase>
<configuration>
<tasks>
<!--restore the "proper" persistence.xml-->
<copy
file="${project.build.outputDirectory}/META-INF/persistence.xml.production"
tofile="${project.build.outputDirectory}/META-INF/persistence.xml"
overwrite="true" verbose="true" failonerror="true" />
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
的问题是,如果我执行命令mvn码头:运行它将执行在启动jetty之前测试persistence.xml文件复制任务。我希望它使用部署版本运行。我怎样才能解决这个问题?
如果忘了提,我测试了一下了,但它并不能帮助。 – tputkonen 2010-06-15 12:29:03