From 4c1da24913aba739e3b2b144b97336722f5f9e34 Mon Sep 17 00:00:00 2001 From: Stephen Carlyle-Smith Date: Fri, 29 Apr 2016 09:54:15 +0100 Subject: [PATCH] SHould now be able to handle spaces in filenames --- .../java/com/github/maven_nar/NarGnuConfigureMojo.java | 8 ++++---- src/main/java/com/github/maven_nar/NarUtil.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/github/maven_nar/NarGnuConfigureMojo.java b/src/main/java/com/github/maven_nar/NarGnuConfigureMojo.java index c4f09dd03..3028058d2 100644 --- a/src/main/java/com/github/maven_nar/NarGnuConfigureMojo.java +++ b/src/main/java/com/github/maven_nar/NarGnuConfigureMojo.java @@ -136,7 +136,7 @@ public final void narExecute() throws MojoExecutionException, MojoFailureExcepti getLog().info("Running GNU " + BUILDCONF); String gnuBuildconfArgsArray[] = null; if (this.gnuBuildconfArgs != null) { - gnuBuildconfArgsArray = this.gnuBuildconfArgs.split("\\s"); + gnuBuildconfArgsArray = this.gnuBuildconfArgs.split("[^\\s\"']+|\"([^\"]*)\"|'([^']*)'"); } runAutogen(buildconf, targetDir, gnuBuildconfArgsArray); } @@ -154,7 +154,7 @@ public final void narExecute() throws MojoExecutionException, MojoFailureExcepti // create the array to hold constant and additional args if (this.gnuConfigureArgs != null) { - final String[] a = this.gnuConfigureArgs.split(" "); + final String[] a = this.gnuConfigureArgs.split("[^\\s\"']+|\"([^\"]*)\"|'([^']*)'"); args = new String[a.length + 2]; System.arraycopy(a, 0, args, 2, a.length); @@ -164,7 +164,7 @@ public final void narExecute() throws MojoExecutionException, MojoFailureExcepti // first 2 args are constant args[0] = configure.getAbsolutePath(); - args[1] = "--prefix=" + getGnuAOLTargetDirectory().getAbsolutePath(); + args[1] = "--prefix=\"" + getGnuAOLTargetDirectory().getAbsolutePath() + "\""; final File buildDir = getGnuAOLSourceDirectory(); FileUtils.mkdir(buildDir.getPath()); @@ -196,7 +196,7 @@ private void runAutogen(final File autogen, final File targetDir, final String a } else { arguments = new String[1]; } - arguments[0] = "./" + autogen.getName(); + arguments[0] = "\"./" + autogen.getName() + "\""; getLog().info("args: " + arraysToString(arguments)); diff --git a/src/main/java/com/github/maven_nar/NarUtil.java b/src/main/java/com/github/maven_nar/NarUtil.java index e94bbfef3..a6f28f79a 100644 --- a/src/main/java/com/github/maven_nar/NarUtil.java +++ b/src/main/java/com/github/maven_nar/NarUtil.java @@ -386,7 +386,7 @@ public static void makeExecutable(final File file, final Log log) throws MojoExe if (file.isFile() && file.canRead() && file.canWrite() && !file.isHidden()) { // chmod +x file final int result = runCommand("chmod", new String[] { - "+x", file.getPath() + "+x", file.getPath().replaceAll(" ", "\\ ") }, null, null, log); if (result != 0) { throw new MojoExecutionException("Failed to execute 'chmod +x " + file.getPath() + "'" + " return code: \'"