How do I skip a Maven plugin execution if "-DskipTests" or "-Dmaven.test.skip=true" is specified?
This worked for me:
<configuration>
<skip>${skipTests}</skip>
</configuration>
OR
<configuration>
<skip>${maven.test.skip}</skip>
</configuration>
You could use profiles that get activated when using one of the unit test skip properties to set a new property (e.g. skipLiquibaseRun
) that holds the flag if liquibase should run or not
<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<skipLiquibaseRun>false</skipLiquibaseRun>
</properties>
</profile>
<profile>
<id>skipTestCompileAndRun</id>
<activation>
<property>
<name>maven.test.skip</name>
<value>true</value>
</property>
</activation>
<properties>
<skipLiquibaseRun>true</skipLiquibaseRun>
</properties>
</profile>
<profile>
<id>skipTestRun</id>
<activation>
<property>
<name>skipTests</name>
</property>
</activation>
<properties>
<skipLiquibaseRun>true</skipLiquibaseRun>
</properties>
</profile>
</profiles>
Use the new property in the liquibase plugin section to decide if the run should be skipped, like this:
<configuration>
<skip>${skipLiquibaseRun}</skip>
<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>
Not tested, but hope it works ;-)
I think the most straight-forward way is to cascade the "skip" properties in your POM:
<properties>
<maven.test.skip>false</maven.test.skip>
<skipTests>${maven.test.skip}</skipTests>
<skipITs>${skipTests}</skipITs>
</properties>
Then you can use the last "skip" property set above in your plugin's configuration:
<configuration>
<skip>${skipITs}</skip>
</configuration>
See Maven Failsafe Plugin: Skipping Tests for more details on each of the different "skip" properties mentioned in this answer.