1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
---
layout: default
class: Project
title: -runvm KEYS
summary: Additional arguments for the VM invocation. Arguments are added as-is.
---
public Collection<String> getRunVM() {
Parameters hdr = getParameters(RUNVM);
return hdr.keySet();
}
public int launch() throws Exception {
java = new Command();
java.add(project.getProperty("java", "java"));
java.add("-cp");
java.add(cp.toString());
java.addAll(project.getRunVM());
java.add(getMainTypeName());
java.addAll(fqns);
if (timeout != 0)
java.setTimeout(timeout + 1000, TimeUnit.MILLISECONDS);
project.trace("cmd line %s", java);
try {
int result = java.execute(System.in, System.err, System.err);
if (result == Integer.MIN_VALUE)
return TIMEDOUT;
reportResult(result);
return result;
}
finally {
cleanup();
}
}
protected void report(Map<String,Object> table, boolean isProject) throws Exception {
if (isProject) {
table.put("Target", getTarget());
table.put("Source", getSrc());
table.put("Output", getOutput());
File[] buildFiles = getBuildFiles();
if (buildFiles != null)
table.put("BuildFiles", Arrays.asList(buildFiles));
table.put("Classpath", getClasspath());
table.put("Actions", getActions());
table.put("AllSourcePath", getAllsourcepath());
table.put("BootClassPath", getBootclasspath());
table.put("BuildPath", getBuildpath());
table.put("Deliverables", getDeliverables());
table.put("DependsOn", getDependson());
table.put("SourcePath", getSourcePath());
}
table.put("RunPath", getRunpath());
table.put("TestPath", getTestpath());
table.put("RunProgramArgs", getRunProgramArgs());
table.put("RunVM", getRunVM());
table.put("Runfw", getRunFw());
table.put("Runbundles", getRunbundles());
}
public int launch() throws Exception {
prepare();
java = new Command();
//
// Handle the environment
//
Map<String,String> env = getRunEnv();
for ( Map.Entry<String,String> e:env.entrySet()) {
java.var(e.getKey(), e.getValue());
}
java.add(project.getProperty("java", "java"));
String javaagent = project.getProperty(Constants.JAVAAGENT);
if (Processor.isTrue(javaagent)) {
for (String agent : agents) {
java.add("-javaagent:" + agent);
}
}
String jdb = getRunJdb();
if (jdb != null) {
int port = 1044;
try {
port = Integer.parseInt(project.getProperty(Constants.RUNJDB));
}
catch (Exception e) {
// ok, value can also be ok, or on, or true
}
String suspend = port > 0 ? "y" : "n";
java.add("-Xrunjdwp:server=y,transport=dt_socket,address=" + Math.abs(port) + ",suspend=" + suspend);
}
java.add("-cp");
java.add(Processor.join(getClasspath(), File.pathSeparator));
java.addAll(getRunVM());
java.add(getMainTypeName());
java.addAll(getRunProgramArgs());
if (timeout != 0)
java.setTimeout(timeout + 1000, TimeUnit.MILLISECONDS);
File cwd = getCwd();
if (cwd != null)
java.setCwd(cwd);
project.trace("cmd line %s", java);
try {
int result = java.execute(System.in, System.err, System.err);
if (result == Integer.MIN_VALUE)
return TIMEDOUT;
reportResult(result);
return result;
}
finally {
cleanup();
listeners.clear();
}
}
public ProjectTester(Project project) throws Exception {
this.project = project;
launcher = project.getProjectLauncher();
launcher.addRunVM("-ea");
testbundles = project.getTestpath();
continuous = project.is(Constants.TESTCONTINUOUS);
for (Container c : testbundles) {
launcher.addClasspath(c);
}
reportDir = new File(project.getTarget(), project.getProperty("test-reports", "test-reports"));
}
public ProjectLauncherImpl(Project project) throws Exception {
super(project);
project.trace("created a aQute launcher plugin");
this.project = project;
propertiesFile = File.createTempFile("launch", ".properties", project.getTarget());
project.trace(MessageFormat.format("launcher plugin using temp launch file {0}",
propertiesFile.getAbsolutePath()));
addRunVM("-D" + LauncherConstants.LAUNCHER_PROPERTIES + "=\"" + propertiesFile.getAbsolutePath() + "\"");
if (project.getRunProperties().get("noframework") != null) {
setRunFramework(NONE);
project.warning("The noframework property in -runproperties is replaced by a project setting: '-runframework: none'");
}
super.addDefault(Constants.DEFAULT_LAUNCHER_BSN);
}
|