繁体   English   中英

在Maven插件执行中禁用目标

[英]Disabling goals in a maven plugin execution

我有一个安装程序,其中我的大多数项目都需要同时运行xtend插件才能实现compile和testCompile目标。 我在pluginManagement部分中对其进行描述:

<plugin>
    <groupId>org.eclipse.xtend</groupId>
    <artifactId>xtend-maven-plugin</artifactId>
    <version>2.5.3</version>
    <executions>
        <execution>
            <goals>
                <goal>compile</goal>
                <goal>testCompile</goal>
            </goals>
        </execution>
    </executions>
</plugin>

现在,有些项目不需要一个目标或另一个目标。 我尝试了继承标签,使用了随机属性,但是没有用。 如何覆盖执行以仅包含所需目标?

更新 :故事的结论是,个人目标不能残废。 可以管理的最小范围是execution

通常,您只能使用技巧来禁用执行:

将执行阶段设置为不存在阶段( dont-execute )。 但是请注意,您必须使用两个不同的执行ID才能分别关闭两个目标:

<plugin>
    <groupId>org.eclipse.xtend</groupId>
    <artifactId>xtend-maven-plugin</artifactId>
    <version>2.5.3</version>
    <executions>
        <execution>
            <id>xtend-compile</id>
            <goals>
                <goal>compile</goal>
                <goal>testCompile</goal>
            </goals>
        </execution>
        <execution>
            <id>xtend-testCompile</id>
            <goals>
                <goal>testCompile</goal>
            </goals>
        </execution>
    </executions>
</plugin>

子模块:

<plugin>
    <groupId>org.eclipse.xtend</groupId>
    <artifactId>xtend-maven-plugin</artifactId>
    <version>2.5.3</version>
    <executions>
        <execution>
            <id>xtend-testCompile</id>
            <phase>dont-execute</phase>
        </execution>
    </executions>
</plugin>

当然,在您的特定情况下,您当然也可以在每次执行中使用skipXtend配置属性来不跳过执行,而只是阻止插件执行任何操作:

<plugin>
    <groupId>org.eclipse.xtend</groupId>
    <artifactId>xtend-maven-plugin</artifactId>
    <version>2.5.3</version>
    <executions>
        <execution>
            <id>xtend-testCompile</id>
            <configuration>
                <skipXtend>xtend-testCompile</skipXtend>
            </configuration>
        </execution>
    </executions>
</plugin>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM