Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven share configuration between multiple plugin executions

Tags:

maven

If I have multiple executions of a Maven plugin and they share at least one of the same configuration values, is there a way for me to share this configuration between all executions of the plugin.

Consider the trivial case of a build plugin with two executions:

<plugin>
    <!-- ID, version... -->
    <executions>
        <execution>
            <id>ID1</id>
            <configuration>
                <myConfig>foo</myConfig>
                ...
            </configuration>
        </execution>
        <execution>
            <id>ID2</id>
            <configuration>
                <myConfig>foo</myConfig>
                ...
            </configuration>
        </execution>
    </executions>
</plugin>

How can I rewrite this so that both the ID1 and the ID2 executions use the same value for the myConfig configuration?

like image 544
ecbrodie Avatar asked Mar 23 '23 19:03

ecbrodie


1 Answers

Why not move common configuration outside concrete executions?

<plugin>
    <!-- ID, version... -->
    <configuration>
        <commonConfig>foo</commonConfig>
    </configuration>
    <executions>
        <execution>
            <id>ID1</id>
            <configuration>
                <specificConfig>bar</specificConfig>
            </configuration>
        </execution>
        <execution>
            <id>ID1</id>
            <configuration>
                <specificConfig>baz</specificConfig>
            </configuration>
        </execution>
    </executions>
</plugin>

It works for some plugins I use (e.g. gmaven-plugin) and in Maven documentation I haven't found any evidence it shouldn't work.

like image 162
Dmitry Avatar answered Apr 25 '23 01:04

Dmitry