Skip to main content

Eclipse

Prerequisites

Remember to check that you're on Ubuntu Xorg when you log in (it may cause Eclipse rachs if you're not).

Installing Git

Install Git

Generate a local ssh key with your e-mail address

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

Then copy the generated key

cat ~/.ssh/id_ed25519.pub

And add it to your git profile (and stash if used)

Installation

Download and install Eclipse for RCP and RAP developers.

Configuration

Launch Settings

Add a shortcut for Eclipse in your /home/USER/.local/share/applications/ as defined below. Remember to change USER with your username.

	cat /home/USER/.local/share/applications/_home_USER_eclipse_.desktop 
[Desktop Entry]
Encoding=UTF-8
Name=Eclipse
Comment=Eclipse IDE
Exec=/home/USER/bin/eclipse.sh %u
Icon=/home/USER/eclipse/icon.xpm
Categories=Application;Development;Java;IDE
Type=Application
StartupNotify=true
StartupWMClass=Eclipse
Terminal=0
MimeType=x-scheme-handler/eclipse+command;x-scheme-handler/eclipse+mpc;

Create a file eclipse.sh in your home as defined below. Remember to change USER with your username.

	cat /home/USER/bin/eclipse.sh 
#!/bin/sh
export WEBKIT_DISABLE_COMPOSITING_MODE=1

/home/USER/eclipse/eclipse -vm /usr/lib/jvm/java-1.21.0-openjdk-amd64/bin/java

In your local repository, create a .envrc that will contain the local configuration. You need to enter the paths to the jdk and to the maven you've installed. Remember to change USER with your username.

cat /home/USER/local/bluemind-all/.envrc 
branch=$(git rev-parse --abbrev-ref HEAD)
branch=$(echo $branch | sed 's,/,_,')
unset _JAVA_OPTIONS
#export MAVEN_OPTS="-Dmaven.repo.local=/home/USER/.m2/${branch}"
export MAVEN_OPTS="-Dmaven.repo.local=/home/USER/.m2/master"
export JAVA_HOME=/usr/lib/jvm/jdk-21.0.3
export PATH=/usr/local/apache-maven-3.9.7/bin:/usr/lib/jvm/jdk-21.0.3/bin:$PATH

To take this conf into account, we use direnv. Update your .bashrc to include this row:

	eval "$(direnv hook bash)

In your Eclipse :

  1. Open Window -> Preferences
  2. Search for Installed JREs
  3. In the list, select the jdk, click Edit...
  4. Add the following line in the Default VM arguments field
--add-modules java.se --illegal-access=permit --add-exports java.base/jdk.internal.ref=ALL-UNNAMED --add-exports java.base/jdk.internal.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.management/sun.management=ALL-UNNAMED --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED --add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED --add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac=ALL-UNNAMED --add-opens=java.base/java.lang.reflect=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang.invoke=ALL-UNNAMED -Djava.net.preferIPv4Stack=true -XX:+UnlockDiagnosticVMOptions -XX:+DebugNonSafepoints -XX:StartFlightRecording=delay=2s,settings=profile,dumponexit=true

Adding an execution platform

The Eclipse execution platform must be completed with BlueMind dependencies:

  1. start and initialize a workspace using the version of Eclipse you want to develop with (e.g. Eclipse Mars, previously installed)
  2. go to Window->Preferences, search for Target
  3. click Target Platform
  4. click Add, choose Nothing, click Next
  5. specify a name (e.g. BlueMind 5)
  6. click Add, choose Software Site, then click Next
  7. in the «Work with» field, specify http://forge.blue-mind.net/staging/p2/dependencies and point to the latest version
    1. at the bottom of the window uncheck "Group by category" and "Include required software"
    2. in the updated list, check Feature:
  8. click Finish
  9. make sure the new platform is selected and click on Apply then OK to exit:

Configuration

Formatting

To use uniform code formatting in Eclipse:

  1. go to Window, then Preference
  2. search for Save Actions, click Java->Editor->Save Actions
  3. check Perform the selected actions on save
  4. check Format source code, and select Format all lines
  5. check Organize imports
  6. click Apply, then OK

Headers

It is important that source file headers are compliant. In Eclipse:

  1. go to Window, then Preference
  2. search for Template, click Java->Code Style->Code Template
  3. open the Code menu and click New Java files
  4. click Edit
  5. in the Pattern section, add: New Java file pattern
    /\* BEGIN LICENSE
    \* Copyright © Blue Mind SAS, 2012-${year}
    \*
    \* This file is part of BlueMind. BlueMind is a messaging and collaborative
    \* solution.
    \*
    \* This program is free software; you can redistribute it and/or modify
    \* it under the terms of either the GNU Affero General Public License as
    \* published by the Free Software Foundation (version 3 of the License).
    \*
    \* This program is distributed in the hope that it will be useful,
    \* but WITHOUT ANY WARRANTY; without even the implied warranty of
    \* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    \*
    \* See LICENSE.txt
    \* END LICENSE
    \*/
    ${filecomment}
    ${package_declaration}

    ${typecomment}
    ${type_declaration}
  6. click OK
  7. click Apply, then OK

Initializing the Eclipse workspace

"Package explorer"

Before you import the plugins, you must make sure that you are using the "Package explorer" view to browse plugins (for performance reasons).

To open it:

  1. Go to Window / Show View
  2. If it doesn't appear here, click "Other" and you will find it in the "Java" category
  3. Close other plugin list views such as "Project Explorer" or "Plugins..."

Importing plugins

In Eclipse

  1. go to File, Import menu
  2. open General, select Existing projects into Workspace
  3. click Next
  4. check Select root directory, click Browse
  5. select the open folder in the BlueMind Git, and click OK
  6. if there is only one project in the Projects list, clean up the Git. Go to the BlueMind Git root directory and run: git clean -f -d -n -x, then start again from step 1
  7. otherwise, click Finish
  8. repeat this operation for the closed BlueMind Git directory

Build maven

You must add a Maven build:

  1. in a terminal, go to the open BlueMind Git directory
  2. run the command: mvn -Dmaven.test.skip=true clean install
  3. do the same in the directory open/ui/gwt-libs/
  4. in Eclipse, select all the packages and press F5 (Refresh)