Eclipse Configuration

The official Eclipse version "2019-03" is already installed (including some of the most used plug-ins).

On the RedHat 7 Cluster (asl740 - asl744), a Java Development Kit (OpenJDK 11) is already installed. During development keep in mind that the cluster is configured for 64bit (OS, Java, etc.). Typing "echo $JAVA_HOME" in a console on the cluster should reveal the location of the java installation.

Launching Eclipse

To start Eclipse with the default plugin customization / preferences provided by AP, you can:
  • Start Eclipse with the command line option
    -pluginCustomization /common/usr/cscoap/opt/eclipse/2019-03/plugin_customization.ini
or
  • Use our startup script:
    • for members of groups cscoap or lsa: simply
      eclipse-app-2019-03
    • for non-members of cscoap/lsa:
      • /common/usr/cscoap/opt/eclipse/2019-03/eclipse-app-2019-03
      • Optional: If you want to be able to use the short command, create a sym link to our startup script in your personal bin folder:
        ln -s /common/usr/cscoap/opt/eclipse/2019-03/eclipse-app-2019-03 ~/bin/eclipse-app-2019-03
If you already have a workspace (e.g. created with one of the mkws scripts), you can provide the workspace to the script (as a full path or the name of the workspace if it is placed in $HOME/workspaces/). Otherwise, you will be prompted to choose a workspace by the Eclipse launcher.
  • open your workspace at the specified path: [script command] /path/to/your/workspace/workspace_name
  • open your workspace at $HOME/workspaces/workspace_name: [script command] workspace_name
  • prompt to choose a workspace: [script command]
You can adapt the preferences loaded by the startup script by changing the preferences in Eclipse. Any changes you make will be stored for you by Eclipse and will override the default customization provided by the startup script.

General Eclipse configuration

Only when you do not use the startup script or plugin customization command line option

It is recommended, to install all needed plugins first, see Recommended Plugins.

The most common configuration can be imported from here (right click -> save as) as follows:
  • File -> Import -> General -> Preferences
    • Choose the preference file
    • ensure "Import all" is checked

Always needed

  • Go to Window -> Preferences -> Java -> Installed JREs
    • Select JRE "java-11-openjdk..." , choose "Edit...."
    • Under "Default VM arguments", add: -Ddependencies.set.direct=true
  • Go to Window -> Preferences -> Maven -> Archetypes

  • Disable index files for Maven:
    • Go to Window -> Show View -> Other -> Maven repositories
    • In the Maven repository view right mouse click below the repositories and check "Disable Index Details"
      • maybe this view is a bit buggy, in my tests I was only able to check anything after opening the view without having any repository selected

  • Go to Window -> Preferences -> Java -> Code Style -> Code Templates
    • choose Comments -> Types -> Edit -> change ${user} to your full name (e.g. Max Mustermann)

  • Go to Window -> Preferences -> Java -> Editor -> Templates
    • choose "@author" -> Edit -> change ${user} to your full name (e.g. Max Mustermann)

(See also Maven and Eclipse)

During development you might have a lot of error and problem reports in the "Problems" view. You should group them by the problem type:
  • In "Problems" view open "view menu" (the down arrow button on the upper right of the view)
    • Group by -> Java Type Problem
    • Show -> Errors/Warnings on Selection (or Project, whatever you prefer)

Common LSA projects

For existing code in projects that are shared between CERN and GSI (i.e. all projects that are not GSI-specific), only a agreed-upon subset of formatting rules may be applied. Practically, this means that save actions in Eclipse currently have to be manually deactivated and formatting must be triggered manually and only on edited sections. The steps to configure this are as follows:
  • For all projects that are shared between CERN and GSI please do the following (See the cern-repo repository https://git.acc.gsi.de/lsa/cern-repo for a list for projects)
    • Right click the project in "Package Explorer" and select "Properties".
    • Navigate to "Java Editor" -> "Save Actions"
    • Activate "Enable project specific settings".
    • Deactivate "Perform the selected actions on save".
(An option to automatically deactivate save options for common projects is currently being investigated by Raphael and Andreas.)

When adding new classes to projects shared between CERN and GSI on the other hand, it's perfectly fine to format that code only according to GSI standards. To do this with save actions off, the Eclipse "Clean up" feature is configured to behave accordingly. What you can do is:
  • To apply GSI's formatting standard to the whole class you added, right click in the Java editor window and choose "Source" -> "Clean Up".
    • in the next dialog choose the CSCOAP Profile
For your convenience, you can assign a hotkey to the "Clean Up" feature. To do this
  • Go to Window -> Preferences -> "General" -> "Keys"
    • filter by "clean up" (mind the space) (Be aware that there are two commands called "Clean Up". One of them seems to be JavaScript-specific. So the second line that says "Clean Up" as command name should be the right one.)
    • assign a hotkey of your choice by pressing the desired key combination in the "Binding" input field (one valid option should be SHIFT + CTRL+ D (as there seem to be no other commands assigned to this hotkey), but that's up to your personal preferences)

Git

We use Git with the pre installed EGit plugin.

See AppHowToGitConfigure to set up Git on the development cluster.

See AppHowToGitInEclipseForBeginners on how to get started with the plugin in eclipse.

Code Formatting

If you have any "ascii-art" comments in your code and the formatter would make them unreadable you can add the "// @formatter:off" comment at the beginning of your comment and the "// @formatter:on" tag at the end of your comment. This will deactivate the formatter between the two tags. BUT: Avoid excessively use of this feature!

If you have line breaks in your code that help understanding what is going on (for example when building java stream chains). You can use an empty comment start "//" at the end of the line to prevent the line break from being deleted.

Speed up Eclipse (Optional)

If you know, how your projects depend on each other, you can provide the "Build Order" so that eclipse can speed up the build process
  • Go to Window -> Preferences -> General -> Workspace -> Build Order
    • rearrange you projects so that for each project there is no dependent project below in the list

Eclipse might be very slow on startup, therefore you can choose a more simple theme instead of the default one.
  • Go to Window -> Preferences -> General -> Appearance ->
    • choose "Classic" as the Theme
    • uncheck "Enable animations"
You can also remove some plug-ins from the eclipse default startup pipeline.
  • Go to Window -> Preferences -> General -> Startup and Shutdown ->
    • uncheck all plug-ins except "Equinox Provisioning Platform Automatic Update Support" and "Subversion Core Startup".
    • You may want some other plug-ins to be loaded on startup, depending on your work (e.g. Code Analysis UI for C/C++).
    • Note that all the plug-ins are also loaded when you need them just in time.

On larger files it will also help to deactivate the Eclipse spell checking
  • Go to Window -> Preferences -> General -> Editors -> Text Editors -> Spelling
    • uncheck "Enable spell checking"

Further Eclipse Configuration (Optional)

  • Go to Window -> Preferences -> General -> Appearance -> Label Decoration
    • deactivate all decorators that you do not use (e.g. you are a java developer you don't need all the c/c++ decorators)
    • activate all Maven decorators (this will show the maven artifact version next to the project)
  • Go to Window -> Preferences -> General -> Editors -> Text Editors
    • activate "Show print margin" and set "Print margin column" to 120
    • activate "Show whitespace characters"
  • Go to Window -> Preferences -> General -> Workspace
    • Set Workspace name to show in title bar to easily identify which workspace is currently opened if you have multiple workspaces
  • Hierarchical view of source code: Package Explorer -> small drop down arrow on the upper right corner -> package presentation -> hierarchical
Package presentation in the Eclipse Package Explorer
  • Structuring of projects using working sets: same small drop down arrow as shown above -> configure working sets. Example configuration:
Eclipse: Grouping projects in working sets
  • Shorten displayed names of long package names:
(This will only effect the view in the "Package Explorer" (and all derived views) - other views and the file system won't be affected!)
  • Go to Window -> Preferences -> Java -> Appearance
    • activate "Abbreviate package names" and write each package name you want to be displayed with a shorter name in a single line
For example:

Example for shortening long package names

will lead to:

original package name -> shortened package name

How eclipse works

Perspectives

Eclipse works with different Perspectives. Each perspective has its own specific task. The most used perspectives are "Java" or "Debug". Within this perspectives you can work on a specific task in your workflow, e.g. in the Java-Perspective you work on your code, whereas the Debug-Perspective provides additional information about the running applications, like Stacktrace, breakpoints and the current variable content. In the upper right corner of eclipse you have an icon for each perspective after the generic perspective switcher icon.

Views

Each perspective contains at least one View. Views can be arranged next to each other or be tabbed at the same location. In the default Java perspective for example you have a "Package Explorer" View on the left, die "File Editor" View in the middle and the "Outline" View on the right. At the Bottom there are some Views like "Problems" or "Console" and so on.

Recommended Plugins

The following plugins are recommended for our application development:
  • JavaFX SceneBuilder support
    • e(fx)clipse (actual working version: 3.5.0.201902220600)
  • Static code analyses
    • Spotbugs (actual working version: 3.1.5.r201806132012-cbbf0a5) -> use Marketplace
    • PMD (actual working version: 4.4.0.v20190526-1012) -> install manually (see below)
  • Code style conventions
    • Eclipse Checkstyle Plugin (actual working version: 8.18.0.201903231603) -> use Marketplace
  • JUnit test coverage
    • EclEmma (actual working version: 2.3.3.201602231923)
  • UML Diagrams
    • ObjectAid (version: 1.1.11) => Installation currently does not work in eclipse-neon! 24.Oct.2016 JF
  • Path tools (actual working version 1.0.67)
    • Allows you to open folders or files in external Applications like terminal or file browser or a text editor

Please note that the following sections assumes that you have imported the Eclipse Preference File.

Installation

To install these plugins after importing the Eclipse Preferences just go to Help -> Install New Software... -> select the update site of the plugin you want to install.

To install them without the imported Eclipse preferences go to Help -> Eclipse Marketplace... and search for the plugins by name.
However the PMD and ObjectAid plugins are not available in Eclipse Marketplace, so you need to install them manually:

Configuration

e(fx)clipse

Goto Window - Preferences - JavaFX and enter the following path to the SceneBuilder for Java 11:
/common/usr/cscoap/bin/SceneBuilder

(The old Java 8 SceneBuilder is still available under /common/usr/cscoap/bin/javafxscenebuilder, but does not work anymore under Java 11.)

If not already installed or update site missing see: https://marketplace.eclipse.org/content/efxclipse (Click on the question mark icon for update site)

Spotbugs (Findbugs)

The Spotbugs configuration can be imported from here (right click -> save as) as follow:
  • File -> Import -> General -> Preferences
    • Choose the preference file
    • ensure "Import all" is checked

(Findbugs was renamed to Spotbugs, see https://marketplace.eclipse.org/content/spotbugs-eclipse-plugin)

Checkstyle

For the checksytle plugin please use the maven configuration. Sadly there is no way to configure the plugin from maven so you have to configure it by yourself. Go to Window -> Preferences -> Checkstyle Please note that all classes within the folders "src/test/*" and "*/generated-sources/*" are ignored from Checkstyle, because many tests break a lot of rules to be functional.

PMD

For the PMD plugin please use the maven configuration. Sadly there is no way to configure the plugin from maven so you have to configure it by yourself. Go to Window -> Preferences -> PMD -> Rule Configuration
  • activate "Use global rule management"
    • if you are asked to do a full rebuild answer with "No"
  • confirm with OK
  • close eclipse
  • in a terminal navigate to your workspace directory and run the following commands:
    • cd .metadata/.plugins/net.sourceforge.pmd.eclipse.plugin/
    • rm ruleset.xml
    • ln -s /common/usr/cscoap/etc/pmd.xml ruleset.xml
  • start eclipse
To run PMD on a project right click on the project and choose PMD -> "Check Code", you also can check for duplicated code by choosing "Find Suspect Cut And Paste...".

To ignore PMD warnings on classes or methods you cann add the @SuppressWarnings("PMD") annotation, on single lines of codes you can add the //NOPMD comment at the end of the line (see here).

Please note that all classes ending with "Test" are ignored from PMD, because many tests break a lot of rules to be functional.

Obsolete

Subversive

SVN is now obsolete as we migrated to git. The plugin should normally not be required anymore. For smaller infos you could have a look at the old repos using http: https://www-acc.gsi.de/viewvc/view

For Eclipse 2019-03 and Java 11 please have a look at this Link: https://www-acc.gsi.de/wiki/Applications/AppRelease13DevelopmentClusterUpdateApril19#A_6.3_SVN_Connector

For Eclipse Neon and older this is relevant:

WARNING: SVNKit behaves different than JavaHL and the command line SVN client. If you need for example the possiblitiy to use symlinks in your project you have to use JavaHL or command line, this is also the officially supported client by our IN group. However, since for pure Java/Maven projects SVNKit has proven more reliable, a lot of AP member use SVNKit so here is a setup guide:

To be able to connect properly to the svn repositories you should check if SVNKit 1.7.x is selected as svn connector.
  • Go to Window -> Preferences -> Team -> SVN
    • select "SVN Connector" tab
    • Choose "SVNKit 1.7.x" as SVN Connector
If there is only the "Native JavaHL" Connector you can install the SVNKit.

Therefore go to Help -> Install New Software...

If you have imported the Eclipse preferences just select the SVNKit entry, otherwise select "Add..." and add the SVNKit repository with the url Choose under "Subversive SVN Connectors" the entry "SVNKit 1.7.x Implementation". After the installation the SVNKit conenctor is available as described above.

See also:

How to set up own projects
Maven and Eclipse
Topic attachments
I Attachment Action Size Date Who Comment
Eclipse2019-03Preferences.epfepf Eclipse2019-03Preferences.epf manage 205 K 10 May 2019 - 10:16 AnnekeWalter Eclipse 2019-03 Preferences (updated by AW)
EclipseMarsPreferences.epfepf EclipseMarsPreferences.epf manage 138 K 26 Apr 2016 - 07:51 AndreasSchaller The eclipse mars preferences to import.
EclipseMarsPreferences_findbugs.epfepf EclipseMarsPreferences_findbugs.epf manage 14 K 07 Apr 2016 - 08:44 AndreasSchaller The Findbugs preferences to import for eclipse mars.
EclipseNeonPreferences.epfepf EclipseNeonPreferences.epf manage 165 K 19 Oct 2016 - 06:47 AndreasSchaller Eclipse Neon Preferences
EclipseNeonPreferences_findbugs.epfepf EclipseNeonPreferences_findbugs.epf manage 14 K 19 Oct 2016 - 06:49 AndreasSchaller The Findbugs preferences to import for eclipse Neon
longDisplayedPackageName.jpgjpg longDisplayedPackageName.jpg manage 15 K 15 Apr 2014 - 10:28 AndreasSchaller  
shortenDisplayedPackageNames.jpgjpg shortenDisplayedPackageNames.jpg manage 16 K 15 Apr 2014 - 10:28 AndreasSchaller  
shortenedDisplayedPackageName.jpgjpg shortenedDisplayedPackageName.jpg manage 13 K 15 Apr 2014 - 10:28 AndreasSchaller  
Topic revision: r101 - 28 Aug 2020, BenjaminPeter
This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback