Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. I describe it in a pluginManagement section:

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

like image 214
allprog Avatar asked Apr 14 '14 08:04

allprog


1 Answers

Generally, you can only disables executions with a trick:

Set the executions phase to non existant phase (dont-execute). Note however, that you have to use two different execution ids to allow both goals to be individually turned off:

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

<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>
like image 83
blackbuild Avatar answered Nov 14 '22 23:11

blackbuild