views:

154

answers:

3

I want to automate the execution of Maven release:prepare with Perl so that the user doesn't have to answer the prompts for version names etc. Are there a -D arguments that can be supplied so that no prompting is done? I tried the obvious solution which is to feed the prompt answers to mvn via perl code like this:

my $cmd = qq(mvn release:prepare -DautoVersionSubmodules=true-DpreparationGoals="clean install"); 
open MVN, "| $cmd";

print MVN "\n"; # default
print MVN "$cur_version";
print MVN "\n";
print MVN "$next_version";
print MVN "\n";

close MVN;

but mvn ignores such input and winds up using the defaults (and doesn't prompt either).

So, are there -D args for the release:prepare plugin:goal?

Thanks.

+2  A: 

For the Maven part, see Performing a Non-interactive Release.

Pascal Thivent
+1  A: 

If it is a Perl solution you seek, command-line arguments are usually executed through the system command.

Try system $cmd;

As far as I can tell, there's no need to open and close filehandles.

Zaid
I think the OP was trying to send commands in via STDIN. A false assumption, but valid approach given the user is typing in responses to maven.
harschware
+2  A: 

You can use the following maven command to do that...

mvn --batch-mode release:prepare

This will assume defaults for anything that you would normally be prompted for; it would be like running a release and simply hitting enter every time it asked you a question. For instance, if your current development version of your project was 1.2.3-SNAPSHOT, it would release version 1.2.3 and move your development version up to 1.2.4-SNAPSHOT. It is usually best to let Maven work this things out for you anyway since the goal of maven is to use convention over configuration. However, is you need to specify non-default properties, the maven-release-plugin allow command line property override as well as using a 'release.properties' file for overriding these settings.

Gweebz