您可以在<target/>配置中指定属性以根据某些条件执行或不执行 Ant 任务。例如,要跳过 Ant 调用,您可以添加以下内容:
<project> ... <build> <plugins> ... <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <version>3.0.0</version> <executions> <execution> <phase> <!-- a lifecycle phase --> </phase> <configuration> <target unless="maven.test.skip"> <echo message="To skip me, just call mvn -Dmaven.test.skip=true"/> </target> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin> ... </plugins> </build> ... </project>