Skip to content

Importing into Eclipse

Ayk Borstelmann edited this page Apr 16, 2021 · 10 revisions

Eclipse IDE can be downloaded for free from here. Since openroberta-lab is a fronend- and backend project, we recommend installing Eclipse IDE for Enterprise Java and Web Developers.

Eclipse setup is fairly simple. Before we import the Open Roberta Lab project into the eclipse workspace first we have to modify some settings.

Add a custom code style formatter

We have designed our code style formatter for Java code.

Java

  • Go to Window -> Preferences -> Java -> Code Style-> Formatter and import openRobertaJava formatter from /Resources/formatter folder

Web

Javascript

Eclipse formatter in Window -> Preferences -> Web -> Client-side Javascript -> Formatter is ignored by the new Eclipse Web Development Plugin Wild Web Developer (more info). Instead WWD uses tsfmt und can be configured by a tsfmt.json file in the project root directory.

HTML

  • Go to Window -> Preferences -> Web -> HTML files -> Editor and
    • set Line width to 160
    • select Indent using spaces
    • make sure all other checkboxes are not activated
    • set Indentation size to 4
    • select "Lowercase" for "Tag names" and "Attribute names"

Setup 'save actions'

Another thing to configure in Eclipse is to setup 'save actions' in Window -> Preferences -> Java -> Editor. They should be all ticked with 'Format all lines selected'. Actions themselves should be the following:

  • Add 'this' qualifier to unqualified field accesses
  • Change non static accesses to static members using declaring type
  • Change indirect accesses to static members to direct accesses (accesses through subtypes)
  • Convert control statement bodies to block
  • Add final modifier to private fields
  • Use lambda where possible
  • Remove unnecessary parentheses
  • Remove unused imports
  • Add missing '@Override' annotations
  • Add missing '@Override' annotations to implementations of interface methods
  • Add missing '@Deprecated' annotations
  • Remove unnecessary casts
  • Remove unnecessary '$NON-NLS$' tags
  • Remove trailing white spaces on all lines
  • Correct indentation

Also enable the 'Format source code' 'save action' for JavaScript.

If you wish to counter long package names and provide somewhat clearer package explorer view, then go to Window -> Preferences -> Java -> Appearance and tick the "Abbreviate package names" checkbox. A suggested template for this is as follows:

  • de.fhg.iais.roberta={rob}
  • de.fhg.iais.roberta.syntax={syntax}
  • de.fhg.iais.roberta.mode={mode}
  • de.fhg.iais.roberta.factory={factory}

Importing the project

This assumes that you have read and followed the 'ReadMe' page in our git repository.

  • Open Eclipse and use 'File | Import' to import "Existing Maven Projects"
  • Set the 'openroberta-lab' directory that was cloned with git as the root directory
  • Check that all projects are selected, and finish
  • If a window pops up with m2e connectors, click "Resolve All Later" and finish
  • In the Project Explorer, select 'OpenRobertaServer' and hit Alt+Enter to open the properties
  • In the properties window, under 'Java Build Path', select the 'Projects' tab and add all robots as required projects (Not WedoInterpreter)

Start the server

  • Go to OpenRobertaServer project (de.fhg.iais.roberta.main) and locate 'ServerStarter.java'
  • Right-click on public static void main(String[] args) and select 'Run As | Java Application'
    • The server will start and immediately crash because there are program arguments missing
  • In the Menu bar, open 'Run | Run Configurations...'
    • in 'Arguments | Program arguments' add: -d server.staticresources.dir=./OpenRobertaServer/staticResources -d robot.crosscompiler.resourcebase=../ora-cc-rsc
    • in Working directory: Check 'Other' and add: /home/<username>/OpenRoberta/openroberta-lab/ (relative paths might not work)
  • Run the server and it will be accessible on localhost:1999

Possible errors

If you encounter an error with hibernate go to run configurations in Eclipse (drop-down arrow next to green run button), select ServerStarter and go to Arguments, add this argument as well: -d hibernate.connection.url=jdbc:hsqldb:file:<path to git repository>/OpenRobertaServer/db-embedded/openroberta-db

After updating certain resources or if something gets cached and does not change, right click on any project and go to Maven | Update Project, in the window that pops up, select all related projects and update. If this does not help, open Terminal (e.g. Git Bash) and type:
cd openroberta-lab
mvn clean install

If you encounter "name of robot" has invalid factory - class not found exception - this is due to the fact that your classpath is not updated. Right click OpenRobertaServer project, go to Properties -> Java Build Path -> Projects and add all robot plugin projects and click "Apply". Now all needed classes should be on the class path.

Clone this wiki locally