public class EclipseApp extends Object
Models an eclipse utility application and all of its input state.
Specifically targets utilities which are only available as eclipse applications, such as org.eclipse.ant.core.antRunner
or org.eclipse.equinox.p2.director
.
To run an EclipseApp
, call runUsing(EclipseRunner)
and pass an EclipseRunner
instance.
EclipseApp p2director = new EclipseApp("org.eclipse.equinox.p2.director");
p2director.addArg("repository", "http://somerepo");
p2director.addArg("destination", "file://somefile");
p2director.addArg("installIU", "org.eclipse.jdt");
p2director.addArg("installIU", "org.eclipse.text");
p2director.runUsing(new NativeRunner(eclipseLauncherExe));
will turn into
eclipsec.exe -application org.eclipse.equinox.p2.director
-repository http://somerepo
-destination file://somefile
-installIU org.eclipse.jdt,org.eclipse.text
Many of these applications are deterministic - if you pass them the same inputs, they generate the same outputs.
To build fast staleness checking, use completeState()
to get a String which contains the full state of the application.
Sometimes, running an eclipse utility application includes state besides its console arguments, such as the input build.xml
for org.eclipse.ant.core.antRunner
.
Ideally, this state should be included within the EclipseApp
instance. This can be accomplished by overriding EclipseApp.AntRunner.runUsing(EclipseRunner)
, setting up any state that the application requires, and cleaning up the state after it has completed.
See EclipseApp.AntRunner
for an example.
Modifier and Type | Class and Description |
---|---|
static class |
EclipseApp.AntRunner
Models the
org.eclipse.ant.core.antRunner application, including its build.xml . |
Modifier and Type | Field and Description |
---|---|
protected com.diffplug.common.collect.ListMultimap<String,String> |
args |
Constructor and Description |
---|
EclipseApp(String application)
Creates an EclipseApp which will call the given application, such as
org.eclipse.ant.core.antRunner or org.eclipse.equinox.p2.director |
Modifier and Type | Method and Description |
---|---|
void |
addArg(String key)
addArg("flag") will add “-flag” to command line. |
void |
addArg(String key,
String value)
addArg("flag", "value") will add -flag value to command line. |
void |
clean()
Any cached data used by the OSGi framework and eclipse runtime will be wiped clean.
|
String |
completeState()
Writes out the entire state of this argsbuilder to a string.
|
void |
consolelog()
Any log output is also sent to Java’s System.out (typically back to the command shell if any).
|
void |
runUsing(EclipseRunner runner)
Runs this app using the given runner.
|
protected List<String> |
toArgList()
Returns the args.
|
String |
toString() |
public EclipseApp(String application)
Creates an EclipseApp which will call the given application, such as org.eclipse.ant.core.antRunner
or org.eclipse.equinox.p2.director
public void runUsing(EclipseRunner runner) throws Exception
Runs this app using the given runner.
Exception
public String completeState()
Writes out the entire state of this argsbuilder to a string. This can be used to determine if the arguments have changed at all, to aid in staleness checking.
If you extend EclipseArgsBuilder and add any kinds of new state (e.g. EclipseAntArgsBuilder), then you must override this method and embed all internal state within it.
public void addArg(String key, String value)
addArg("flag", "value")
will add -flag value
to command line.
addArg("flag", "A")
addArg("flag", "B")
will add -flag A,B
to the command line.
public void addArg(String key)
addArg("flag")
will add “-flag” to command line.
public void clean()
Any cached data used by the OSGi framework and eclipse runtime will be wiped clean. This will clean the caches used to store bundle dependency resolution and eclipse extension registry data. Using this option will force eclipse to reinitialize these caches.
public void consolelog()
Any log output is also sent to Java’s System.out (typically back to the command shell if any).