Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Override Maven Plugin Parameters [duplicate]

Tags:

maven

I have a Maven plugin and it is configured in the POM file as

<build>
    <plugins>
        <plugin>
            <groupId>com.example</groupId>
            <artifactId>example-maven-plugin</artifactId>
            <configuration>
                <scriptsPath>scripts</scriptsPath>
            </configuration>
        </plugin>
    </plugins>
</build>

Now I want to override that scriptsPath from from command line so I run

mvn -X example-maven-plugin:goal -DscriptsPath=scripts1

I can see that value of the scriptsPath is still scripts and not scripts1. Could the configuration parameter be overriden from the command line ?

like image 666
EvgeniySharapov Avatar asked Oct 15 '25 03:10

EvgeniySharapov


1 Answers

Unfortunately, there is no general way to override maven plugin configuration by using properties. If the plugin documentation does not explicitly allow you to use a property to set the configuration value you can use following pattern:

<properties>
    <scripts.path>scripts</scripts.path>
</properties>
<build>
    <plugins>
        <plugin>
            <groupId>com.example</groupId>
            <artifactId>example-maven-plugin</artifactId>
            <configuration>
                <scriptsPath>${scripts.path}</scriptsPath>
            </configuration>
        </plugin>
    </plugins>
</build>

and then execute maven as

mvn -X example-maven-plugin:goal -Dscripts.path=scripts1
like image 113
Stepan Vavra Avatar answered Oct 17 '25 02:10

Stepan Vavra