Search code examples
javaeclipseeclipse-plugineclipse-jdtescript

How to run Eclipse Project using Escripts plugin?


I have installed Eclipse Escripts plugin, but it does not seem to have proper documentation and I am very new to Eclipse JDT API.

I am trying to write a script which can run Server and several Clients with just one click using Escripts. Server and Client are Run Configuration what I have in Eclipse.

This an example of a script which can open a new project wizard

<?xml version="1.0"?>
<escript>
 <action id="org.eclipse.jdt.ui.actions.OpenProjectWizard">
  <dialog title="New Java Project">
   <!-- Enter the project name in the dialog and finish the wizard: -->
   <enter text="Escripts Examples - Java Project"/>
   <click button="Finish"/>
  </dialog>
 </action>
</escript>

So my guess is that I need to change action to something like org.eclipse.jdt.launching and specify run configuration inside inner XML-tags. I have found this page for JDT, but cannot find proper action to Run a project.

Any one can help me to come up with script which can run existing Run Configuration?


Solution

  • Instead of searching into JDT documentation, just open the Escripts view:

    Windows
      > Show View
        > Other...
          > Escripts
            > Escripts Elements (drag and drop to a script file)
    

    You will see there all the available actions, commands and wizards.

    Create a empty .escript file, select an item in the Escripts view, and just drag and drop it to the .escript file.

    There are a lot of options, but I have found that the "Run Configurations" dialog can be opened with the following command:

    <command id="org.eclipse.debug.ui.commands.OpenRunConfigurations">
    </command>
    

    But the projects can also be launched as follow without opening the dialog:

    <command id="org.eclipse.jdt.debug.ui.localJavaShortcut.run">
      <selection>
        <resource name="<project>/src/<package>/Server.java"/>
      </selection>
    </command>
    
    <command id="org.eclipse.jdt.debug.ui.localJavaShortcut.run">
      <selection>
        <resource name="<project>/src/<package>/Client.java"/>
      </selection>
    </command>
    

    Be sure to take a look at the XML schema escript.xsd inside net.sf.escripts_<version>.jar (current 1.0.1.r85).

    By the way, people installing this plugin from http://escripts.sf.net/updates must uncheck the "Group items by category" checkbox in the Eclipse install wizard to avoid the "There are no categorized items" (as "Details" section message of the wizard says).