Class EclipseApp

java.lang.Object
com.diffplug.gradle.eclipserunner.EclipseApp
Direct Known Subclasses:
CategoryPublisher, EclipseApp.AntRunner, FeaturesAndBundlesPublisher, P2Model.DirectorApp, Repo2Runnable

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. ```java EclipseApp p2director = new EclipseApp("org.eclipse.equinox.p2.director"); p2director.addArg("repository", "https://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 https://somerepo -destination file://somefile -installIU org.eclipse.jdt,org.eclipse.text ``` ## Staleness 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. ## State besides arguments 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.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Models the `org.eclipse.ant.core.antRunner` application, including its `build.xml`.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final com.diffplug.common.collect.ListMultimap<String,String>
     
  • Constructor Summary

    Constructors
    Constructor
    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`
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    `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
    Any cached data used by the OSGi framework and eclipse runtime will be wiped clean.
    Writes out the entire state of this argsbuilder to a string.
    void
    Any log output is also sent to Java's System.out (typically back to the command shell if any).
    void
    Runs this app using the given runner.
    protected List<String>
    Returns the args.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • args

      protected final com.diffplug.common.collect.ListMultimap<String,String> args
  • Constructor Details

    • EclipseApp

      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`
  • Method Details

    • runUsing

      public void runUsing(EclipseRunner runner) throws Exception
      Runs this app using the given runner.
      Throws:
      Exception
    • completeState

      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.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • addArg

      public void addArg(String key, String value)
      `addArg("flag", "value")` will add `-flag value` to command line. ```java addArg("flag", "A") addArg("flag", "B") ``` will add `-flag A,B` to the command line.
    • addArg

      public void addArg(String key)
      `addArg("flag")` will add "-flag" to command line.
    • toArgList

      protected List<String> toArgList()
      Returns the args.
    • clean

      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.
    • consolelog

      public void consolelog()
      Any log output is also sent to Java's System.out (typically back to the command shell if any).