简体   繁体   English

在Maven插件执行中禁用目标

[英]Disabling goals in a maven plugin execution

I have a setup where most of my projects require the xtend plugin to be run both for the compile and testCompile goals. 我有一个安装程序,其中我的大多数项目都需要同时运行xtend插件才能实现compile和testCompile目标。 I describe it in a pluginManagement section: 我在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>

Now, there are some projects that don't need one goal or the other. 现在,有些项目不需要一个目标或另一个目标。 I've tried the inherited tag, played around with random attributes but none worked. 我尝试了继承标签,使用了随机属性,但是没有用。 How can I override the execution to contain only the desired goal? 如何覆盖执行以仅包含所需目标?

UPDATE : The conclusion of the story is that individial goals cannot be disabled. 更新 :故事的结论是,个人目标不能残废。 The smallest scope that can be managed is the execution . 可以管理的最小范围是execution

Generally, you can only disables executions with a trick: 通常,您只能使用技巧来禁用执行:

Set the executions phase to non existant phase ( dont-execute ). 将执行阶段设置为不存在阶段( dont-execute )。 Note however, that you have to use two different execution ids to allow both goals to be individually turned off: 但是请注意,您必须使用两个不同的执行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>

Submodule: 子模块:

<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>

In your specific case, you could, of course, also use the skipXtend configuration property in each execution to not skip the execution, but only prevent the plugin from doing anything: 当然,在您的特定情况下,您当然也可以在每次执行中使用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