Update equinox execution
authorMathieu Baudier <mbaudier@argeo.org>
Sat, 25 Apr 2009 13:15:25 +0000 (13:15 +0000)
committerMathieu Baudier <mbaudier@argeo.org>
Sat, 25 Apr 2009 13:15:25 +0000 (13:15 +0000)
git-svn-id: https://svn.argeo.org/slc/trunk/maven@2357 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

maven-argeo-osgi-plugin/pom.xml
maven-argeo-osgi-plugin/src/main/java/org/argeo/slc/maven/plugins/osgi/EquinoxExecMojo.java

index 0b75524835a7623d542b4a77890468562428558d..b7f2b6699a7ce0a61fde4846f0065649a9037411 100644 (file)
@@ -7,7 +7,7 @@
                <relativePath>..</relativePath>\r
        </parent>\r
        <artifactId>maven-argeo-osgi-plugin</artifactId>\r
-       <version>0.1.6</version>\r
+       <version>0.1.7</version>\r
        <packaging>maven-plugin</packaging>\r
        <name>Argeo OSGi Plugin</name>\r
 \r
index 7f54edd3de87b0fac91c60d8f431baf3f99e6bfb..c483c5250a3fd412845d4a5c3881ee1d668925c4 100644 (file)
@@ -55,7 +55,7 @@ public class EquinoxExecMojo extends AbstractOsgiMojo {
         */
        protected String[] jvmArgs;
 
-       protected String[] defaultJvmArgs = { "-Xmx256m" };
+       protected String[] defaultJvmArgs = { "-Xmx128m" };
 
        /**
         * Equinox args
@@ -64,8 +64,8 @@ public class EquinoxExecMojo extends AbstractOsgiMojo {
         */
        protected String[] args;
 
-       protected String[] defaultArgs = { "-clean", "-console", "-configuration",
-                       "conf" };
+       protected String[] defaultArgs = { "-console", "-configuration", "conf",
+                       "-data", "data" };
 
        /**
         * JVM system properties
@@ -78,11 +78,18 @@ public class EquinoxExecMojo extends AbstractOsgiMojo {
         * Execution directory
         * 
         * @parameter expression="${execDir}"
+        *            default-value="${project.build.directory}/exec"
         * @required
         */
        protected File execDir;
 
        public void execute() throws MojoExecutionException, MojoFailureException {
+               if ("bundles".equals(project.getArtifact().getType())) {
+                       System.out.println("Skip artifact of type bundles "
+                                       + artifactToString(project.getArtifact()));
+                       return;
+               }
+
                try {
                        Artifact equinoxArtifact = null;
                        Artifact osgiBootArtifact = null;
@@ -128,6 +135,9 @@ public class EquinoxExecMojo extends AbstractOsgiMojo {
                        if (systemProperties == null)
                                systemProperties = new HashMap();
 
+                       if (!execDir.exists())
+                               execDir.mkdirs();
+
                        // Build command
                        List cmdList = new ArrayList();
                        cmdList.add(jvm);
@@ -146,6 +156,7 @@ public class EquinoxExecMojo extends AbstractOsgiMojo {
                                if (value != null) {
                                        strValue = value.toString().trim();
                                        strValue = strValue.replaceAll("\n", "");
+                                       strValue = strValue.replaceAll("\t", "");
                                }
                                cmdList.add("-D" + key + "=" + strValue);
                        }
@@ -155,9 +166,18 @@ public class EquinoxExecMojo extends AbstractOsgiMojo {
 
                        String[] cmd = (String[]) cmdList.toArray(new String[0]);
 
-                       for (int i = 0; i < cmd.length; i++)
+                       System.out.println("\nExecute command:\n");
+                       for (int i = 0; i < cmd.length; i++) {
+                               boolean containsSpace = (cmd[i].indexOf(' ') >= 0)
+                                               || (cmd[i].indexOf('\t') >= 0);
+                               if (containsSpace)
+                                       System.out.print('\"');
                                System.out.print(cmd[i]);
-                       System.out.print('\n');
+                               if (containsSpace)
+                                       System.out.print('\"');
+                               System.out.print(' ');
+                       }
+                       System.out.println("\n");
 
                        SystemCall systemCall = new SystemCall(execDir.getCanonicalPath(),
                                        cmd, true);
@@ -170,10 +190,13 @@ public class EquinoxExecMojo extends AbstractOsgiMojo {
        }
 
        protected static void printArtifact(Artifact artifact) {
-               System.out.println(artifact.getGroupId() + ":"
-                               + artifact.getArtifactId() + ":" + artifact.getType() + ":"
-                               + artifact.getClassifier() + ":" + artifact.getVersion() + " ("
-                               + artifact.getFile() + ")");
+               System.out.println(artifactToString(artifact));
+       }
+
+       protected static String artifactToString(Artifact artifact) {
+               return artifact.getGroupId() + ":" + artifact.getArtifactId() + ":"
+                               + artifact.getType() + ":" + artifact.getClassifier() + ":"
+                               + artifact.getVersion() + " (" + artifact.getFile() + ")";
        }
 
 }