Maven exec bash script and save output as property

Posted by djechlin on Stack Overflow See other posts from Stack Overflow or by djechlin
Published on 2012-12-14T23:01:28Z Indexed on 2012/12/14 23:03 UTC
Read the original article Hit count: 150

Filed under:
|

I'm wondering if there exists a Maven plugin that runs a bash script and saves the results of it into a property.

My actual use case is to get the git source version. I found one plugin available online but it didn't look well tested, and it occurred to me that a plugin as simple as the one in the title of this post is all I need. Plugin would look something like:

<plugin>maven-run-script-plugin>
    <phase>process-resources</phase> <!-- not sure where most intelligent -->
    <configuration>
        <script>"git rev-parse HEAD"</script> <!-- must run from build directory -->
        <targetProperty>"properties.gitVersion"</targetProperty>
    </configuration>
</plugin>

Of course necessary to make sure this happens before the property will be needed, and in my case I want to use this property to process a source file.

© Stack Overflow or respective owner

Related posts about maven

Related posts about maven-plugin