You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by stug23 <pa...@gmail.com> on 2014/04/11 22:32:42 UTC

Better way to capture output from a Maven job

I have a script that needs to obtain the three-part numerical version from a
Maven pom.xml. I am using the Maven help plugin to the version number as
follows:

mvn help:evaluate -Dexpression=project.version

Of course when running the Maven job, you get a great deal of output lines
and towards the end the project.version number. In my script I use a grep to
snatch the three-part numerical version from the Maven output:

mvn help:evaluate -Dexpression=project.version | grep -o
'^[0-9]*\.[0-9]*\.[0-9]*'

So if I have a pom.xml with project/version = 1.2.3-SNAPSHOT, the command
above returns the result '1.2.3'

While this works okay, I would have hoped for a better way to return a value
from Maven. Is there a return/result parameter of some sort such that I
don't have to pick the result out of the entire text output of the Maven job
execution?



--
View this message in context: http://maven.40175.n5.nabble.com/Better-way-to-capture-output-from-a-Maven-job-tp5790942.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Better way to capture output from a Maven job

Posted by Wayne Fay <wa...@gmail.com>.
> While this works okay, I would have hoped for a better way to return a value
> from Maven. Is there a return/result parameter of some sort such that I
> don't have to pick the result out of the entire text output of the Maven job
> execution?

The versions-maven-plugin from Codehaus may be helpful - but no guarantee.

Wayne

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Better way to capture output from a Maven job

Posted by stug23 <pa...@gmail.com>.
I also noted that someone has requested that help:evaluate values be returned
in quiet mode:

https://github.com/apache/maven-plugins/pull/17



--
View this message in context: http://maven.40175.n5.nabble.com/Better-way-to-capture-output-from-a-Maven-job-tp5790942p5790951.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: Better way to capture output from a Maven job

Posted by Bernd Eckenfels <ec...@zusammenkunft.net>.
Am Fri, 11 Apr 2014 13:32:42 -0700 (PDT)
schrieb stug23 <pa...@gmail.com>:

> While this works okay, I would have hoped for a better way to return
> a value from Maven. Is there a return/result parameter of some sort
> such that I don't have to pick the result out of the entire text
> output of the Maven job execution?

You can either use maven to execute the steps which you would do in
your script (for example using a ant or script plugin). In that case
you can access properties directly or you can have maven write the
result to a file (for example a property file) and then open that one.

Gruss
Bernd

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org