本番環境では MySQL を使用し、単体テストには Derby を使用しています。pom.xml は、テストの前に Derby バージョンの persistence.xml をコピーし、パッケージ準備段階で MySQL バージョンに置き換えます。
<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:run を実行すると、jetty を開始する前にテストの persistence.xml ファイル コピー タスクが実行されることです。展開バージョンを使用して実行したい。どうすればこれを修正できますか?