What is priority of parameters passed to maven plugin?

721 views Asked by At

I see that a parameter can be configured in pom.xml or passed in the CLI such as -Dxxxxx=...

My question is if the same parameter is both configured in file pom.xml and passed in the CLI, which will be used by the maven plugin? Is there any document about this priority?

Mostly I believe CLI will override, but this real case shows the opposite.

<plugin>
    <groupId>de.saumya.mojo</groupId>
    <artifactId>rspec-maven-plugin</artifactId>
    <version>1.0.0-beta</version>
    <configuration>
        <launchDirectory>${project.build.directory}/test-classes</launchDirectory>
        <summaryReport>${project.build.directory}/test-Ruby.xml</summaryReport>
        <specSourceDirectory>./new_test</specSourceDirectory>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>test</goal>
            </goals>
        </execution>
    </executions>
</plugin>

When I ran

mvn test -DspecSourceDirectory=./spec

The plugin still picked the specSourceDirectory in the pom.xml which is ./new_test

I'm using maven 3.0.5, java 7, jruby 1.7.5


Got it resolved: it should be a property instead of a hardcode

<specSourceDirectory>${specSourceDirectory}</specSourceDirectory>
1

There are 1 answers

0
Michał Kalinowski On

One thing is a plugin's configuration parameter and the other thing is Maven's invocation property (user property). For example, look at Surefire's skip configuration parameter. There is a skip parameter that can be set up by maven.test.skip property. In general these 2 names are independent, so can be either different or the same.

In your case, <specSourceDirectory>${specSourceDirectory}</specSourceDirectory> will be such a latter scenario and will work as you expect.