From 4ba318d57ce48513d9e1d2501d4adbb4cb25de83 Mon Sep 17 00:00:00 2001 From: Mark Donszelmann Date: Tue, 20 Oct 2009 10:11:49 +0200 Subject: Fixed NAR-75 --- .../maven/plugin/nar/NarGnuConfigureMojo.java | 46 +++++++++++++++++----- .../apache/maven/plugin/nar/NarGnuMakeMojo.java | 13 +++++- 2 files changed, 47 insertions(+), 12 deletions(-) (limited to 'src/main/java/org/apache/maven/plugin') 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 2f32094..082a9f5 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarGnuConfigureMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarGnuConfigureMojo.java @@ -43,10 +43,18 @@ public class NarGnuConfigureMojo * @parameter expression="${nar.gnu.autogen.skip}" default-value="false" */ private boolean gnuAutogenSkip; - - private static String autogen = "autogen.sh"; - private static String configure = "configure"; - + + /** + * Skip running of configure and therefore also autogen.sh + * + * @parameter expression="${nar.gnu.configure.skip}" default-value="false" + */ + private boolean gnuConfigureSkip; + + private static final String AUTOGEN = "autogen.sh"; + + private static final String CONFIGURE = "configure"; + public void execute() throws MojoExecutionException, MojoFailureException { @@ -68,14 +76,32 @@ public class NarGnuConfigureMojo throw new MojoExecutionException( "Failed to copy GNU sources", e ); } - if ((!gnuAutogenSkip) && new File(targetDir, "autogen.sh").exists()) { - getLog().info( "Running GNU "+autogen ); - NarUtil.runCommand( "sh ./"+autogen, null, targetDir, null, getLog() ); + File autogen = new File( targetDir, AUTOGEN ); + if ( !gnuConfigureSkip && !gnuAutogenSkip && autogen.exists() ) + { + getLog().info( "Running GNU " + AUTOGEN ); + NarUtil.makeExecutable( autogen, getLog() ); + int result = NarUtil.runCommand( "./" + autogen.getName(), null, targetDir, null, getLog() ); + if ( result != 0 ) + { + System.err.println( targetDir ); + throw new MojoExecutionException( "'"+AUTOGEN+"' errorcode: " + result ); + } } - getLog().info( "Running GNU "+configure ); - NarUtil.runCommand( "sh ./"+configure, new String[] { "--disable-ccache", "--prefix=" - + getGnuAOLTargetDirectory().getAbsolutePath() }, targetDir, null, getLog() ); + File configure = new File( targetDir, CONFIGURE ); + if ( !gnuConfigureSkip && configure.exists() ) + { + getLog().info( "Running GNU " + CONFIGURE ); + NarUtil.makeExecutable( configure, getLog() ); + int result = + NarUtil.runCommand( "./" + configure.getName(), new String[] { "--disable-ccache", + "--prefix=" + getGnuAOLTargetDirectory().getAbsolutePath() }, targetDir, null, getLog() ); + if ( result != 0 ) + { + throw new MojoExecutionException( "'"+CONFIGURE+"' errorcode: " + result ); + } + } } } } diff --git a/src/main/java/org/apache/maven/plugin/nar/NarGnuMakeMojo.java b/src/main/java/org/apache/maven/plugin/nar/NarGnuMakeMojo.java index e04e3a9..f7b2f48 100644 --- a/src/main/java/org/apache/maven/plugin/nar/NarGnuMakeMojo.java +++ b/src/main/java/org/apache/maven/plugin/nar/NarGnuMakeMojo.java @@ -45,8 +45,17 @@ public class NarGnuMakeMojo if ( srcDir.exists() ) { getLog().info( "Running GNU make" ); - NarUtil.runCommand( "make", null, srcDir, null, getLog() ); - NarUtil.runCommand( "make", new String[] { "install" }, srcDir, null, getLog() ); + int result = NarUtil.runCommand( "make", null, srcDir, null, getLog() ); + if ( result != 0 ) + { + throw new MojoExecutionException( "'make' errorcode: " + result ); + } + + result = NarUtil.runCommand( "make", new String[] { "install" }, srcDir, null, getLog() ); + if ( result != 0 ) + { + throw new MojoExecutionException( "'make install' errorcode: " + result ); + } } } } -- cgit v1.2.3