tags:

views:

8

answers:

1

I want to specify the expression to evaluate on the command line, so the plugin does not go into interactive mode.

According to the docs, the expression parameter should do the trick.

I tried:

mvn help:evaluate -Dexpression=project.groupId

and

mvn help:evaluate -Dexpression=xxx

but the expression is ignored, and the plugin enters interactive mode, as undesired.

Curiously, the following works just fine:

mvn help:describe -Dplugin=help

("Curiously" because it is the same plugin, and I'm following the same convention for specifying parameters, but one time it works, and the other time it does not.)

+1  A: 

The version 2.1 of the plugin does not support batch mode as reported in MPH-71:

The help:evaluate goal is designed to be called in interactive mode. I would like to call this goal in batch mode, passing the expression to evaluate in a property (on the command line).

But the issue is fixed and the feature is available in the version 2.1.1 of the plugin:

$ mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Demo - Child
[INFO]    task-segment: [org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate] (aggregator-style)
[INFO] ------------------------------------------------------------------------
[INFO] [help:evaluate {execution: default-cli}]
[INFO] No artifact parameter specified, using 'my.group.id:child:jar:1.0-SNAPSHOT' as project.
[INFO] 
1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
...
Pascal Thivent
Cool - works like a charm. I should have checked the Maven bug tracker. Thanks for the tip!
@mlauritse: You're welcome.
Pascal Thivent