wiki:UsingAsapRealizerInEclipse

Using AsapRealizer in an Eclipse project

STEP 1: Setting up project structure

First, you need to set up projects in Eclipse for the various modules that you want to compile. If you use the source releases from AsapRealizer, you need to set up git in Eclipse, check out the modules from the repository, and make them into an Eclipse project.

  1. Install  Python and make sure the python binary is on your path
  2. Install the  lombok plugin for eclipse (this is done by running a lombok.jar file)
  3. (Optional, if you'd like to use git within eclipse) Get the git plugin from  http://www.eclipse.org/egit/ and install it
  4. Clone your desired GitRepositories by hand (using commandline git SmartGit, TortoiseGit, or any tool of your choice). Typical directory setup when you have cloned them:
    <gitroot>/AsapDemo/AsapRealizerDemo
    ...
    <gitroot>/asapresource/
    ...
    <gitroot>/hmibuild/
    ...
    <gitroot>/HmiResource/
    ...
    ...etc
    ...etc
    

STEP 2: Set build paths to include dependent libraries

you need the right versions (for your machine and operating system) of all dependent libraries in the project classpath; HmiBuild contains ant scripts to take care of this.

  1. First, collect right versions of libraries using our ant scripts
    1. command prompt in HmiDemo/MyFirstProject
    2. now use resolve the libraries for your project, using ant resolve, ant compile list, etc (see also http://asap-project.ewi.utwente.nl/wiki/BuildSystem)
    3. Now, all required libraries, in the version for your OS and machine, are in HmiDemo/MyFirstProject/lib

STEP 3: Generate eclipse project files

  1. Second, create the eclipse project files, again using an ant script
    1. Sane people: ant eclipseproject
    2. Herwin: ant eclipsesourceproject

The first will create an independent eclipse project file with dependencies on the jar files that were resolved in the lib directory. The second will create an eclipse project file in which the rebuild.list is linked to other eclipse projects. This option is only useful if you are very deeply involved in the development of AsapRealizer.

STEP 4: Opening the project in eclipse

The generated project file can now be opened in eclipse, using "file->import->general->existing projects" into workspace. Alternatively, if you'd like to use git in eclipse, open the Git Repositories view, right-click on the working directory of the git repository of your project, select import project, select the directory of your project and click finish.

STEP 5: Adding/changing library dependencies, resources, etc.

It is strongly recommended that you do not manually edit your project configuration in eclipse, but instead regenerate the project using step 2 whenever library dependencies change and/or new resource dependencies are added. This way your project will also work compile and run in ant and others can easily reconstruct eclipse project files for it. After recreating the project file, you can simply refresh the project in eclipse. You can also easily switch between resolved alpha dependencies and release dependencies in this way. ant eclipseproject/eclipsesourceproject will automatically put resources specified in resource.path and test.resource.path in the project's build.properties on the project's classpath.

STEP 6: set a few virtual machine variables

For running your project, you need to set a few additional settings in "run configuration" dialog for your main class

  1. tab "arguments", VM arguments, add
    -Djava.library.path="lib"
    
  2. add -Dlogback.configurationFile=LogbackConfigs/warnlogstdout.xml or any other config file to specify your logging (see ProgrammingGuidelines)
  3. Add a relative path from you project directory to the proejct root: -Dshared.project.root="../.."

Code formatting

Herwin's eclipse code formatter is available in HmiBuild/eclipse/herwin_eclipse_style. You can set it up in window->preferences->java->code style->formatter. Press CTRL+SHIFT+F to auto-format your code. The formatter will enforce certain ProgrammingGuidelines (e.g. maximum line lenghts, spaces rather than tabs). To disable auto-formatting on a selected piece of code do:

//@formatter:off
Code that should not be auto-formatted...
//@formatter:on

Using Logback/SLF4J in eclipse

Use

-Dlogback.configurationFile=LogbackConfigs/desiredlogconfig.xml

As VM argument in your run configuration, with HmiResource/LogbackConfig/resource on your classpath.

 Beagle is a nice logback plugin for eclipse, a config file for beagle is provided in HmiResource/LogbackConfig/resource/LogbackConfigs/logback_beagle.xml, use that as above to enable logging in Beagle.

User contributions

Discussion

If you need more details, have additional suggestions or find any errors in this documentation: post a reply to this message.