Maven maven-antrun-plugin跳过父任务

时间:2017-07-10 12:18:02

标签: maven ant maven-ant-tasks

我的父母pom包含需要由所有孩子执行的maven ant任务:



<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-antrun-plugin</artifactId>
  <executions>
    <execution>
      <id>set-scripts-rights</id>
      <phase>initialize</phase>
      <configuration>
        <tasks>
         <!-- The tasks that needs to be exacuted-->
        </tasks>
      </configuration>
      <goals>
        <goal>run</goal>
      </goals>
    </execution>
  </executions>
</plugin>
&#13;
&#13;
&#13;

在其中一个孩子中,我不希望脚本被执行,然后我将其添加到构建/插件部分:

&#13;
&#13;
<plugin>
  <artifactId>maven-antrun-plugin</artifactId>
  <configuration>
    <skip>true</skip>
  </configuration>
</plugin>
&#13;
&#13;
&#13;

但是尽管有这一部分,任务总是被执行。 知道如何在这个孩子身上有效地摧毁这个任务吗?

1 个答案:

答案 0 :(得分:0)

这就是我在自己的工作父母pom中实现它的方式:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>
    <executions>
        <execution>
            <id>set-scripts-rights</id>
            <phase>initialize</phase>
            <goals>
                <goal>run</goal>
            </goals>
            <configuration>
                <skip>${skip.property.name}</skip>
                <tasks> <!-- NOTE: tasks is deprecated, consider using target instead -->
                    <!-- The tasks that needs to be executed-->
                </tasks> <!-- NOTE: tasks is deprecated, consider using target instead -->
            </configuration>
        </execution>
    </executions>
</plugin>

触发孩子时,设置属性$ {skip.property.name},父pom应该选择它。