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 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
|
---
layout: default
class: Launcher
title: -runtrace BOOLEAN
summary: Trace the launched process in detail
---
public void run() throws Exception {
ProjectLauncher pl = getProjectLauncher();
pl.setTrace(isTrace() || isTrue(getProperty(RUNTRACE)));
pl.launch();
}
public void runLocal() throws Exception {
ProjectLauncher pl = getProjectLauncher();
pl.setTrace(isTrace() || isTrue(getProperty(RUNTRACE)));
pl.start(null);
}
/**
* Collect all the aspect from the project and set the local fields from
* them. Should be called
*
* @throws Exception
*/
protected void updateFromProject() throws Exception {
// pkr: could not use this because this is killing the runtests.
// project.refresh();
runbundles.clear();
Collection<Container> run = project.getRunbundles();
for (Container container : run) {
File file = container.getFile();
if (file != null && (file.isFile() || file.isDirectory())) {
runbundles.add(file.getAbsolutePath());
} else {
error("Bundle file \"%s\" does not exist, given error is %s", file, container.getError());
}
}
if (project.getRunBuilds()) {
File[] builds = project.build();
if (builds != null)
for (File file : builds)
runbundles.add(file.getAbsolutePath());
}
Collection<Container> runpath = project.getRunpath();
runsystempackages = new Parameters( project.mergeProperties(Constants.RUNSYSTEMPACKAGES));
runsystemcapabilities = project.mergeProperties(Constants.RUNSYSTEMCAPABILITIES);
framework = getRunframework(project.getProperty(Constants.RUNFRAMEWORK));
timeout = Processor.getDuration(project.getProperty(Constants.RUNTIMEOUT), 0);
trace = Processor.isTrue(project.getProperty(Constants.RUNTRACE));
runpath.addAll(project.getRunFw());
for (Container c : runpath) {
addClasspath(c);
}
runvm.addAll(project.getRunVM());
runprogramargs.addAll(project.getRunProgramArgs());
runproperties = project.getRunProperties();
storageDir = project.getRunStorage();
if (storageDir == null) {
storageDir = new File(project.getTarget(), "fw");
}
}
@Override
public boolean prepare() throws Exception {
if (!prepared) {
prepared = true;
super.prepare();
ProjectLauncher launcher = getProjectLauncher();
if (port > 0) {
launcher.getRunProperties().put(TESTER_PORT, "" + port);
if (host != null)
launcher.getRunProperties().put(TESTER_HOST, "" + host);
}
launcher.getRunProperties().put(TESTER_UNRESOLVED, project.getProperty(Constants.TESTUNRESOLVED, "true"));
launcher.getRunProperties().put(TESTER_DIR, getReportDir().getAbsolutePath());
launcher.getRunProperties().put(TESTER_CONTINUOUS, "" + getContinuous());
if (Processor.isTrue(project.getProperty(Constants.RUNTRACE)))
launcher.getRunProperties().put(TESTER_TRACE, "true");
try {
// use reflection to avoid NoSuchMethodError due to change in
// API
File cwd = (File) getClass().getMethod("getCwd").invoke(this);
if (cwd != null)
launcher.setCwd(cwd);
}
catch (NoSuchMethodException e) {
// ignore
}
Collection<String> testnames = getTests();
if (testnames.size() > 0) {
launcher.getRunProperties().put(TESTER_NAMES, Processor.join(testnames));
}
// This is only necessary because we might be picked
// as default and that implies we're not on the -testpath
launcher.addDefault(Constants.DEFAULT_TESTER_BSN);
launcher.prepare();
}
return true;
}
@SuppressWarnings("deprecation")
public int activate() throws Exception {
active.set(true);
Policy.setPolicy(new AllPolicy());
systemBundle = createFramework();
if (systemBundle == null)
return LauncherConstants.ERROR;
doTimeoutHandler();
doSecurity();
// Initialize this framework so it becomes STARTING
systemBundle.start();
trace("system bundle started ok");
BundleContext systemContext = systemBundle.getBundleContext();
ServiceReference<PackageAdmin> ref = systemContext.getServiceReference(PackageAdmin.class);
if (ref != null) {
padmin = systemContext.getService(ref);
} else
trace("could not get package admin");
systemContext.addServiceListener(this, "(&(|(objectclass=" + Runnable.class.getName() + ")(objectclass="
+ Callable.class.getName() + "))(main.thread=true))");
// Start embedded activators
trace("start embedded activators");
if (parms.activators != null) {
ClassLoader loader = getClass().getClassLoader();
for (Object token : parms.activators) {
try {
Class< ? > clazz = loader.loadClass((String) token);
BundleActivator activator = (BundleActivator) clazz.newInstance();
embedded.add(activator);
trace("adding activator %s", activator);
}
catch (Exception e) {
throw new IllegalArgumentException("Embedded Bundle Activator incorrect: " + token + ", " + e);
}
}
}
update(System.currentTimeMillis() + 100);
if (parms.trace) {
report(out);
}
int result = LauncherConstants.OK;
for (BundleActivator activator : embedded)
try {
trace("starting activator %s", activator);
activator.start(systemContext);
}
catch (Exception e) {
error("Starting activator %s : %s", activator, e);
result = LauncherConstants.ERROR;
}
return result;
}
|