使用<target/>属性

<target/>您可以根据某些条件在配置中指定执行或不执行 Ant 任务的属性。例如,要跳过 Ant 调用,您可以添加以下内容:

<project>
  ...
  <build>
    <plugins>
      ...
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
        <version>3.1.0-SNAPSHOT</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>