我正在使用Maven 3.0.3。我有这个插件,通常我希望在我的JUnit测试执行之前运行:
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<test.mysql.db.user>sbjunituser</test.mysql.db.user>
<test.mysql.db.password></test.mysql.db.password>
<test.mysql.db.prefix>sbjunit</test.mysql.db.prefix>
<test.mysql.db.sid>${test.mysql.db.prefix}_${project.artifactId}</test.mysql.db.sid>
<test.mysql.db.host>localhost</test.mysql.db.host>
<test.mysql.db.port>3306</test.mysql.db.port>
<test.mysql.dataSource.url>jdbc:mysql://${test.mysql.db.host}:${test.mysql.db.port}/${test.mysql.db.sid}</test.mysql.dataSource.url>
<test.mysql.dataSource.driverClassName>com.mysql.jdbc.Driver</test.mysql.dataSource.driverClassName>
</properties>
<build>
<plugins>
<!-- Run the liquibase scripts -->
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>2.0.1</version>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.18</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>build-database</id>
<phase>process-test-classes</phase>
<configuration>
<driver>com.mysql.jdbc.Driver</driver>
<url>jdbc:mysql://${test.mysql.db.host}:${test.mysql.db.port}/${test.mysql.db.sid}</url>
<username>${test.mysql.db.user}</username>
<password>${test.mysql.db.password}</password>
<changeLogFile>${project.build.directory}/db.changelog-master.xml</changeLogFile>
<promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
</configuration>
<goals>
<goal>update</goal>
</goals>
</execution>
</executions>
</plugin>
然而,如果有人指定-Dmaven.test.skip=true
或-DskipTests
,我希望跳过这个插件的运行。我该如何做呢?我尝试将执行阶段更改为"test",但是这会导致我的单元测试在此插件之前运行,这不是我想要的。