我正在使用 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
or -DskipTests
,我想跳过这个插件的运行。我怎么做?我尝试将执行阶段更改为“测试”,但随后我的单元测试在此插件之前运行,这不是我想要的。