gpt4 book ai didi

maven - 如果指定了 "-DskipTests"或 "-Dmaven.test.skip=true",如何跳过 Maven 插件执行?

转载 作者:行者123 更新时间:2023-11-28 19:38:39 25 4
gpt4 key购买 nike

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

最佳答案

这对我有用:

<configuration>
<skip>${skipTests}</skip>
</configuration>

<configuration>
<skip>${maven.test.skip}</skip>
</configuration>

关于maven - 如果指定了 "-DskipTests"或 "-Dmaven.test.skip=true",如何跳过 Maven 插件执行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15767132/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com