我有一堆绑定到pre-integration-test
阶段的SQL命令,其作用是创建一个“测试”数据库并将应用程序指向它。在命令行上运行目标的所有绑定实例
有时,我只想“重建”我的测试数据库,而没有生命周期中的所有其他东西。例如,如果我的测试是灾难性的失败并且搞砸了测试数据库,那么我可能需要重建几次,直到我找出问题所在。
这里是我的POM样子:
<profile>
<id>test-setup-teardown</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sql-maven-plugin</artifactId>
<version>1.3</version>
<dependencies>
<dependency>
<groupId>${database-dependency-groupId}</groupId>
<artifactId>${database-dependency-artifactId}</artifactId>
<version>${database-dependency-version}</version>
</dependency>
</dependencies>
<configuration>
<url>${test-database-admin-url}</url>
<username>${test-database-admin-username}</username>
<password>${test-database-admin-password}</password>
<driver>${database-driver}</driver>
<autocommit>true</autocommit>
</configuration>
<executions>
<execution>
<id>test-database-pre-setup</id>
<phase>pre-integration-test</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<sqlCommand>${test-database-teardown}</sqlCommand>
<onError>continue</onError>
</configuration>
</execution>
<execution>
<id>test-database-setup</id>
<phase>pre-integration-test</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<sqlCommand>${test-database-setup}</sqlCommand>
</configuration>
</execution>
<execution>
<id>test-database-schema</id>
<phase>pre-integration-test</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<url>${test-database-url}</url>
<username>${database-user}</username>
<password>${database-password}</password>
<srcFiles>
<srcFile>${basedir}/metadata/build/database/${database-engine}/appx.sql</srcFile>
</srcFiles>
</configuration>
</execution>
<execution>
<id>test-database-teardown</id>
<phase>post-integration-test</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<sqlCommand>${test-database-teardown}</sqlCommand>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
我怎样才能运行这个文件的所有执行?像mvn sql:execute
只能运行其中一个执行(我认为最后一个)。
我试图使绑定阶段是一个属性,然后允许用户指定其他配置文件其更改默认从pre-integration-test
到validate
,但为什么重建的执行正是如此解释给别人:
mvn validate -Pforce-rebuild,test-setup-teardown
只是强制实施非玩具项目在POM中有很多魔力的事实。请给我指路!
<ed>也许一个好的解决方案是从命令行通过id运行执行的一种方法? </ed >
良好的默认目标调用。我也不喜欢重复,但同意这可能是最差的解决方案。谢谢! – 2010-01-28 15:36:09