Table of Contents
- 3.1. Tools and plugins
- 3.2. Preparing eclipse
- 3.3. Working on PEtALS projects
This chapter talks about how to configure and use the eclipse IDE to develop PEtALS.
You can download the eclipse IDE on the eclipse website (http://www.eclipse.org). Additionaly you have to install these plugins (Please refer to the plugins web sites for installation):
Subclipse : Used for source code management under SVN
Checktyle : Used to check that your code is clean
PMD :
Findbugs :
The first thing you must know is getting work with multiple workspaces in Eclipse.
For developers a workspace is a collection of related projects. You can have more than one workspace for different sets of projects. In almost cases the best way to manage these multiple workspaces is configuring Eclipse to prompt which workspace to use every startup (otherwise, you should create various copies of Eclipse start icon/link on your desktop using the -data <workspace_dir> as an executable argument to specify your choice).
To configure this option in Eclipse you must access Window -> Preferences..., then select General -> Startup and Shutdown item in the navigable tree and check the box for Prompt for workspace on startup - if not set. You will be prompted to select a workspace in the next time you start Eclipse.
If the specified path does not exist Eclipse will try create the directory. You can change the workspace while Eclipse is already running (File - Switch Workspace... submenu).
Be aware that a workspace is more than a collection of projects. Eclipse internally uses the workspace directory to store your preferences for that set of projects - and other runtime files and views. In each workspace you can have specific configurations, for example: code formatting, code comments templates, JRE used, so on... Separating the workspace directory tree from project directory tree is a good approach for better management. That way you are able to share project among various workspaces. At least you can avoid unexpected projects removal when installing a new version of Eclipse.
When a Maven project is imported into Eclipse it expects a M2_REPO classpath variable entry.
This variable is used to reference project libraries within your local Maven repository. To setup this variable go to Window -> Preferences... and select Java -> Build Path -> Classpath Variables on the navigable tree.
Add a new M2_REPO entry pointing to the local Maven 2 repository (Under Linux, it is generally : M2_REPO=~/.m2/repository).
Eclipse allow a number of installed JRE/JDK configured in your environment. In this case, you can easily use other java runtime by accessing Window -> Preferences and then selecting the Java -> Installed JREs on the navigable tree.
For PEtALS, choose a ''Java(TM) 1.5'' compatible JDK.
The Maven Eclipse plugin is used to create eclipse projects from the PEtALS modules:
mvn eclipse:eclipse
This command will generate Eclipse project required files
(.project,.classpath,
.checkstyle...) wich will be used for project
imports. It will also dowload all the projects required sources from
Maven repositories.
![]() | Note |
|---|---|
Generating all projects from the root path takes a lot of time |
A part of the PEtALS source code formating rules are described in a file to used with Eclipse. To import the formatter, you have to :
go to Window -> Preferences , then select Java -> Code Style -> Formatter :

click on "Import", and select the file "
petals-formatter.xml" from the directory<PETALS_SRC_HOME>/petals-quality/src/main/resourcesof the PEtALS project :
click on "Apply" to save.
The import statements ordering rules are set from a file :
go to Window -> Preferences , then select Java -> Code Style -> Organize Imports :

click on "Import", and select the file "
eclipse.importorder" in the directory<PETALS_SRC_HOME>/petals-quality/src/main/resourcesof the PEtALS project :
click on "Apply" to save.
The class members ordering rules must be set manualy :
go to Window -> Preferences , then select Java -> Appearance -> Members Sort Order :

use buttons "Up" and "Down" to have the same ordering as the previous screenshot.
click on "OK" to save.
Now you can format all the code you write by doing a right click on the java file and selecting Source -> Format.
PEtALS provides configuration for Checkstyle, PMD, and use the default one for Findbugs. First, the associated Eclipse plugins must be installed.
The PMD configuration is generated during the Eclipse project creation when using the maven-eclipse-plugin from the command-line.
The plugin PMD is configured at Eclipse workbench level :
go to Window -> Preferences , then select PMD -> Rules configuration :

click on "Remove all" to remove all rules :

click on "Import" to import PEtALS rules :

Click on "Browse" and select the file "
pmd.xml" in the directory<PETALS_SRC_HOME>/petals-quality/src/main/resourcesof the PEtALS project:click on "OK" :

click on "OK" to save the PMD rules.
The Checkstyle configuration is generated during the Eclipse project creation when using the maven-eclipse-plugin from the command-line.
The plugin Checkstyle is configured at a Eclipse project level :
on a selected project, from the contextual menu, go to Properties -> Checkstyle, next select the tab "local checkstyle configuration" :

click on "New" :

Select an external configuration, set its name, and use the file "
checkstyle.xml" in the directory<PETALS_SRC_HOME>/petals-quality/src/main/resourcesof PEtALS.click on "OK" :

go on the tab "General" :

Select the previously created configuration, and activated Checkstyle on the project.
click on "OK" to save the Checkstyle configuration for the project.
The plugin Findbugs is configured at the Eclipse project level :
on a selected project, from the contextual menu, go to Properties -> Findbugs, next select the tab "General" :

Set the priority to "Low", and activated Findbugs.
go to the tab "Extended" :

Set the effort to "Maximal".
click on "OK" to save the Findbugs configuration for the project.
To import a generated Eclipse project in Eclipse, go to File -> Import -> Existing Projects into Workspace command. You can choose to import all PEtALS projects by selecting the root folder of the PEtALS project or just some of them by selecting a sub folder.
Once required projects selected, you should see them in your workspace :
The next configuration you need to create is a Server Launch
configuration that runs as a local application. From the menu, select
Run -> Run.... In the wizard,
select "Java Application" and hit
"New" to create a launch
configuration named Petals - Server. For project
choose: petals-standalone and for
main class enter:
org.objectweb.petals.system.launch.StandaloneLauncher
Select the Classpath tab.
Select "Add Jars..." to be added to
the User Entries list. Add the server library wich is located under
the target direcotry of your petals-standalone project
(/petals-standalone/target/petals-standalone-X.X-SNAPSHOT-dev.dir/petals-X.X-SNAPSHOT/bin).
You can also define the PEtALS standalone arguments. For example, if you want PEtALS starts in console mode, add the -console argument.


PEtALS 2.0 & pack (2007/09/28)





![[Note]](../resources/images/note.png)





