Deal with basedir with file: prefix
authorMathieu Baudier <mbaudier@argeo.org>
Sun, 12 Feb 2012 12:58:08 +0000 (12:58 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Sun, 12 Feb 2012 12:58:08 +0000 (12:58 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk@5048 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

runtime/org.argeo.slc.support.maven/src/main/java/org/argeo/slc/maven/MavenCall.java

index d180d1e11ea26d4ad3432590d3be4e8b28df6271..39e57543b911d42d599e25673b94315a266d162c 100644 (file)
@@ -1,11 +1,13 @@
 package org.argeo.slc.maven;
 
+import java.io.File;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.argeo.slc.SlcException;
 import org.codehaus.plexus.PlexusContainer;
 
 /** A Maven execution. */
@@ -27,7 +29,7 @@ public class MavenCall implements Runnable {
                        args.add(settings);
                }
                args.add("-f");
-               args.add(basedir + "/pom.xml");
+               args.add(getBasedirFile().getPath() + "/pom.xml");
                if (goals != null)
                        args.addAll(goals);
                if (profiles != null)
@@ -47,8 +49,8 @@ public class MavenCall implements Runnable {
                // Launcher.main(goals);
 
                CustomCli mavenCli = new CustomCli();
-               mavenCli.doMain(args.toArray(new String[args.size()]), basedir,
-                               System.out, System.err);
+               mavenCli.doMain(args.toArray(new String[args.size()]), getBasedirFile()
+                               .getPath(), System.out, System.err);
 
                PlexusContainer plexusContainer = mavenCli.getContainer();
                if (log.isDebugEnabled())
@@ -56,6 +58,18 @@ public class MavenCall implements Runnable {
                plexusContainer.dispose();
        }
 
+       /** Removes 'file:' prefix if present */
+       protected File getBasedirFile() {
+               if (basedir == null)
+                       throw new SlcException("basedir not set");
+               File dir;
+               if (basedir.startsWith("file:"))
+                       dir = new File(basedir.substring("file:".length()));
+               else
+                       dir = new File(basedir);
+               return dir;
+       }
+
        public void setBasedir(String basedir) {
                this.basedir = basedir;
        }