You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 11 Next »

Project Development in Eclipse

An Integrated Development Environment (IDE) should be used to develop source code.  Eclipse is a good choice, as it is free, widely used, and well supported.

You will also want to install the m2eclipse plugin for Maven support and Subversive which provides a Subversion client interface.

Before You Start

Before you start to setup Eclipse, you should follow the instructions at Installing HPS Java to install locally the HPS Java trunk, which contains the various modules that will be loaded as projects.

Installing Eclipse

The "Eclipse Standard" distribution can be downloaded from the Eclipse downloads area.

The Subversive plugin provides SVN access through the IDE and can be installed through this URL:

http://download.eclipse.org/technology/subversive/1.1/update-site/

When Eclipse reboots select and install an appropriate SVN connector for your system, which should be the pure Java version matching the version of the SVN client that you have installed on your operating system (either 1.6, 1.7 or 1.8).

After this, install the m2e plugin for Maven support using this update site URL:

http://download.eclipse.org/technology/m2e/releases

Configuring Plugins

Subversive

The Subversive Plugin provides a graphical Subversion client within Eclipse, implementing commands like commit, update, etc.

  1. In Eclipse, open Help > Install New Software.
  2. Under work with put the appropriate URL for your release, e.g. for Luna this would be the following.

    http://download.eclipse.org/releases/luna
  3. Find the Collaboration item under the Name column, expand it, and select the checkbox for Subversive Team Provider.
  4. Click Next two times.
  5. Accept the license terms, and finally click on Finish.
  6. Restart Eclipse.

When you go to use this plugin, a window will appear with the title Install Connectors.

In order to pick the right connector which provides the Subversion client, you will need to find out what version you already have installed on the command line.

For instance, this is the Subversion information on my Linux system.

[$] svn --version
svn, version 1.8.10 (r1615264)

So I checked SVN Kit 1.8.6 for my connector and then Finish.

Subversion Versions

Subversion client versions are unfortunately not forward or backward compatible between minor releases.  In other words, you cannot checkout a project using a 1.6 client and then switch to using a 1.7 or 1.8 client.  For this reason, it is strongly recommended that the Subversive Connector you install matches the version which is installed already on your system.

Creating a Project for a Module

To create a new project in Eclipse, you can select File > New > Java Project from the menu.  This will start a wizard for creating the new project.

We will create a project for the users module where miscellaneous user analysis code is located.

In the New Java Project window, you need to do the following.

  1. Type the name of the project in the Project name text box, e.g. "hps-users".
  2. Uncheck Use default location and navigate to the root directory of the module for the project using Browse.
  3. Add the project to a working set (optional).

Then click on the Finish button and the project should now show up in the Package Explorer within the Java View.

Building a Project

It is useful to create a custom build configuration for executing Maven on the project.

Open the window Run > Run Configurations.

Right click on Maven Build and select New.

Setup the new configuration to look like this.

In order to use this, automatic builds must be turned off, which can be done from the menus by deselecting Project > Build Automatically.

To execute this, select the project by left clicking on it, and then go to Run > Run Configurations, click on your configuration, and then click the Run button.

The build log should show up in the console window.

Resolving Dependencies in Eclipse

Should Eclipse be unable to resolve a project's dependencies, try right-clicking on the project in the "Project Explorer" pane and selecting Maven > Update Project OR hitting Alt + F5 while the project is selected.  This should force Eclipse to update its index against your local repository of jar files, and hopefully this will make all the red errors in your editor go away.

Building HPS Java

It will also be useful to setup a Run Configuration for building the entire trunk of HPS Java and not just a single module at a time.

This can be accomplished by creating a new Run Configuration which looks similar to this.

Notice that instead of an Eclipse variable pointing at the current project directory, the actual path to your HPS Java trunk is put under Base directory instead. 

The above is just an example from my machine.  The actual location will depend on wherever you checked it out in the first place.

When you click Run on this configuration, all of the modules will be installed and not just a single one.  This is useful for creating a new distribution jar with all your local changes included in it.

Creating a Single Project for All Modules

As an alternative to creating individual projects for each module in HPS Java, you may also create a single Eclipse project for the entire trunk.

To do this, you can follow the usual procedure of going to File > New > Java Project in the Eclipse menu.

Then instead of using the location of a module, the Location should be the base directory of the trunk.

In my local setup, this looks something like the following.

Now you can click Next and Finish and the new project should show in the Package Explorer.

Next you should make sure Eclipse knows this is a Maven project by right clicking on the project and selecting Configure > Convert to Maven Project.

The instructions under "Building a Project" should also work for building all of the modules with Maven.

  • No labels