From d070a872d4a8e38caae516da5247208be2fd74ef Mon Sep 17 00:00:00 2001 From: Ernesto Novillo Date: Mon, 15 Mar 2010 10:24:36 -0400 Subject: Added support for buildconf arguments. --- .../maven/plugin/nar/NarGnuConfigureMojo.java | 49 ++++++++++++++++++---- 1 file changed, 41 insertions(+), 8 deletions(-) (limited to 'src/main') diff --git a/src/main/java/org/apache/maven/plugin/nar/NarGnuConfigureMojo.java b/src/main/java/org/apache/maven/plugin/nar/NarGnuConfigureMojo.java index ad4a875..1389a4d 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarGnuConfigureMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarGnuConfigureMojo.java @@ -53,12 +53,19 @@ public class NarGnuConfigureMojo private boolean gnuConfigureSkip; /** - * Skip running of configure and therefore also autogen.sh + * Arguments to pass to GNU configure. * * @parameter expression="${nar.gnu.configure.args}" default-value="" */ private String gnuConfigureArgs; + /** + * Arguments to pass to GNU buildconf. + * + * @parameter expression="${nar.gnu.buildconf.args}" default-value="" + */ + private String gnuBuildconfArgs; + private static final String AUTOGEN = "autogen.sh"; private static final String BUILDCONF = "buildconf"; @@ -96,10 +103,15 @@ public class NarGnuConfigureMojo if ( autogen.exists() ) { getLog().info( "Running GNU " + AUTOGEN ); - runAutogen(autogen, targetDir); + runAutogen(autogen, targetDir, null); } else if ( buildconf.exists() ) { getLog().info( "Running GNU " + BUILDCONF ); - runAutogen(buildconf, targetDir); + String gnuBuildconfArgsArray[] = null; + if (gnuBuildconfArgs != null) + { + gnuBuildconfArgsArray = gnuBuildconfArgs.split("\\s"); + } + runAutogen(buildconf, targetDir, gnuBuildconfArgsArray); } } @@ -111,11 +123,12 @@ public class NarGnuConfigureMojo NarUtil.makeExecutable( configure, getLog() ); String[] args = null; - // create the array to hold constant and additional args + // create the array to hold constant and additional args if ( gnuConfigureArgs != null ) { String[] a = gnuConfigureArgs.split( " " ); args = new String[a.length + 2]; + for ( int i = 0; i < a.length; i++ ) { args[i+2] = a[i]; @@ -140,17 +153,37 @@ public class NarGnuConfigureMojo } } - private void runAutogen(File autogen, File targetDir) + private void runAutogen(final File autogen, final File targetDir, final String args[]) throws MojoExecutionException, MojoFailureException { // fix missing config directory - File configDir = new File(targetDir, "config"); + final File configDir = new File(targetDir, "config"); if (!configDir.exists()) { configDir.mkdirs(); } - + NarUtil.makeExecutable( autogen, getLog() ); - int result = NarUtil.runCommand( "./" + autogen.getName(), null, targetDir, null, getLog() ); + getLog().debug("running sh ./" + autogen.getName()); + + String arguments[] = null; + if (args != null) + { + arguments = new String[2 + args.length]; + for (int i = 0; i < args.length; ++i) + { + arguments[i+2] = args[i]; + } + } + else + { + arguments = new String[2]; + } + arguments[0] = "./"; + arguments[1] = autogen.getName(); + + getLog().info( "args: " + Arrays.toString(arguments) ); + + final int result = NarUtil.runCommand( "sh", arguments, targetDir, null, getLog() ); if ( result != 0 ) { throw new MojoExecutionException( "'" + autogen.getName() + "' errorcode: " + result ); -- cgit v1.2.3