*/
protected String[] jvmArgs;
- protected String[] defaultJvmArgs = { "-Xmx256m" };
+ /**
+ * JVM arguments to append
+ *
+ * @parameter alias="${jvmArgsToAppend}"
+ */
+ protected String[] jvmArgsToAppend;
+
+ protected String[] defaultJvmArgs = { "-Xmx128m" };
+
+ /**
+ * Debug port (0 deactivate)
+ *
+ * @parameter expression="${debug}" default-value="0"
+ * @required
+ */
+ protected String debug;
/**
* Equinox args
*/
protected String[] args;
- protected String[] defaultArgs = { "-clean", "-console", "-configuration",
- "conf" };
+ /**
+ * Equinox args to append
+ *
+ * @parameter alias="${argsToAppend}"
+ */
+ protected String[] argsToAppend;
+
+ protected String[] defaultArgs = { "-console", "-configuration", "conf",
+ "-data", "data" };
/**
* JVM system properties
* 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;
if (systemProperties == null)
systemProperties = new HashMap();
+ if (!execDir.exists())
+ execDir.mkdirs();
+
// Build command
List cmdList = new ArrayList();
+ // JVM
cmdList.add(jvm);
+ // JVM arguments
cmdList.addAll(Arrays.asList(jvmArgs));
+
+ if (!"0".equals(debug))
+ cmdList
+ .add("-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address="
+ + debug);
+
+ if (jvmArgsToAppend != null)
+ cmdList.addAll(Arrays.asList(jvmArgsToAppend));
+
+ // System properties
if (!systemProperties.containsKey("osgi.bundles"))
cmdList.add("-Dosgi.bundles="
+ osgiBootArtifact.getFile().getCanonicalPath()
if (value != null) {
strValue = value.toString().trim();
strValue = strValue.replaceAll("\n", "");
+ strValue = strValue.replaceAll("\t", "");
}
cmdList.add("-D" + key + "=" + strValue);
}
+
+ // Equinox jar
cmdList.add("-jar");
cmdList.add(equinoxArtifact.getFile().getCanonicalPath());
+
+ // Program arguments
cmdList.addAll(Arrays.asList(args));
+ if (argsToAppend != null)
+ cmdList.addAll(Arrays.asList(argsToAppend));
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);
}
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() + ")";
}
}