Closed helgoboss closed 13 years ago
What do you mean exactly? do you want your mojo to be able to take parameters from the command line or do you want to pass parameters to the Mojo extractor? and if so which parameters?
For Maven plugins written in Java it's possible to configure the plugin execution (= fill the mojo attributes annotated as parameter) both in the POM ...
<configuration>
<param1>value1</param1>
<param2>value2</param2>
</configuration>
... and via command line parameters ...
mvn clean install -Dparam1=value1 -Dparam2=value2
... The latter doesn't seem to be possible for Scala-powered plugins. Maybe it's not a matter of the extractor but of "ScalaComponentConfigurator.scala".
Now I see, I will give it a go ... I do not remember seeing any code for reading properties. But that was a while ago. Short question are you on MVN 2 or 3?
Thanks! I tested it on Maven 3. The property reading may also be implemented in a special property component configurator. Some weeks ago I checked the Maven (or Plexus?) source to find where it's done. Unfortunately I cannot remember the class name.
Well I took some time to verify this, it works the same in Scala and Java mojos.
I created a branch cmd_line_props where I added a basic echo mojo (from the sonata type example) and did the equivalent in Scala. Then I created a echo-mojo-test project.
If you checkout that branch and install the mojos then you can use the echo-mojo-test for testing.
Do this:
mvn compile -Decho.message="The Eagle has Landed"
It will be ignored, but if you remove the configuration(s) from the execution in the test pom then you will see that the property is taken.
The thing is that Maven ignores command line property if it has been set via configuration in the POM
I hope this helps you.
Currently it doesn't seem to be possible to set mojo execution parameters from the command line (-Dparam1=value1 -Dparam2=value2).