RHQ, the common services project for infrastructure management

  Dashboard > RHQ-Project > ... > Building RHQ > DevelopingRHQ-Eclipse
  RHQ-Project Log In | Sign Up   View a printable version of the current page.  
  DevelopingRHQ-Eclipse
Added by John Mazzitelli , last edited by John Mazzitelli on Feb 13, 2008  (view change)
Labels: 
(None)

Eclipse

Index

Initial Import

The RHQ codebase contains the necessary .classpath/.project files to import the project directly into Eclipse. To import the RHQ project into Eclipse, simple select File > New > Java Project from the main menu. Name the project "rhq" and select the radio button "Create project from existing source" and browse to the directory where you checked out the RHQ code. You can leave everything else alone and click the "Finish" button. This will load in the RHQ code under the project named "rhq".

Building

Eclipse builds the RHQ classpath from your local Maven repository. In order for Eclipse to successfully build the project, make sure you build RHQ via Maven first. You also must set a custom Eclipse Classpath Variable called M2_REPO in order for Eclipse to find the RHQ dependencies in your local Maven repository. To set this variable, select Window > Preferences from the Eclipse main menu. Traverse to Java > Build Path > Classpath Variables and press the "New..." button. Create a new variable entry with the name "M2_REPO" with its path pointing to your local Maven repository (which is, by default, located in your home directory under the name .m2/repository.

Code formatting

If you plan on developing on the RHQ code base, you should be aware that the RHQ Eclipse project defines the Java code style in project-specified settings. You do not have to explicitly import any settings in order for these to take effect. If you do wish to make the RHQ code styles your Eclipse default, you can import the different templates that are found under /etc/eclipse-tools/templates.

Java Standard Code Format

The RHQ codebase conforms to the basic Java conventions format. The RHQ format profile was based off the built-in Eclipse "Java Conventions" format profile with the following changes:

  • Maximum line length is 120 characters
  • No tabs whatsoever
  • Indentation is 4 spaces, with tab indentation being 8 spaces
  • Default indentation for both wrapped lines and array initializers is "1" (which translates to 4 spaces)

EOL Characters

Please keep in mind that most files should not contain tabs or CRLF end-of-line markers unless specifically applicable for the file (e.g. Windows .bat files should have CRLF end-of-line markers). The easiest way to do this is to tell SVN to handle the EOL characters. To do this, copy the RHQ subversion config file to your subversion home location (read the comments at the top of that config file to know where to put that file, which depends on what OS you are using).

If you are on Windows, you can make sure Eclipse stores files with the UNIX file line delimiter. You do this by going to the main menu Window > Preferences and traverse to the General > Workspace preferences section and change the "New text file line delimiter" to "Other - UNIX". While you are there, you might want to change the "Text File Encoding" to something like "UTF-8" to support some files that might contain international characters.

Reformat on Save Is Recommended

In order to keep the source code properly formatted, the RHQ project has a setting that forces your Java editor to reformat upon save. To set this up manually as your Eclipse default, from the main menu's Window > Preferences, traverse to Java > Editor > Save Actions and check "Perform the selected actions on save", "Format source code" and "Organize Imports". This is especially helpful if you prefer to work on source that is formatted in your own, custom format - when you are done editing the file, it will reformat itself when you save the file.

External Tools/Run/Debug Launch Configurations

The RHQ project contains some external tools, run and debug launch configurations that allow you to run the Maven builds and perform JPDA debugging directly from the Eclipse menu bar. Go to the main menu's Run option and you can select "External Tools", "Open Run Dialog" or "Open Debug Dialog" to see what is available if they do not show up in their drop-down buttons by default. Some example things that are available are:

  • "Remote Debugging 8797" (for debugging unit tests when using -Dtest.debug in your Maven build)
  • "DBSetup" (for cleaning your database and building a new schema)
  • "Dev Profile" (for performing a mvn build with the -Pdev profile enabled)
  • et. al.

XML Schema

RHQ contains several .xsd XML Schemas. If you are developing XML files that must conform to these XML Schemas, you can add the schemas to your Eclipse XML Catalog so you can get validation and auto-complete hints when writing those XML files. To do this, select Windows > Preferences from the main menu. Traverse to Web and XML > XML Catalog. Click the "Advanced..." button, and then click "Import...". Traverse the project files down to /etc/eclipse-tools/templates/schema.xmlcatalog and click "OK". You will notice that you now have some entries under "User Specified Entries" in your XML Catalog Entries. If you edit or create new XML files that need to conform to those schemas, Eclipse will now validate them and provide you with auto-completion hints.

Hibernate

The RHQ project contains EJB3/JPA entities, with Hibernate as the JPA implementation. Under /etc/eclipse-tools you will find the file hibernate.cfg.xml that you can use to load into the Hibernate Console to debug JPQL against the RHQ domain entities. If you want to do this, you must install the separate Hibernate Console plugin - see the hibernate.org for details.

SVN

If you wish to keep your code base updated with the latest changes, you can synchronize it with SVN. To do so, select the RHQ project from the Package Explorer view and from the right-mouse button popup menu, select Team > Share.... Eclipse should tell you the project already has SVN metadata, so tell Eclipse that you want to reuse that existing metadata found in the project. Follow the prompts to connect your project to the RHQ SVN repository. After this succeeds, you can use the Synchronize view to update the project with the latest-and-greatest code. If you are a committer, you can use this to commit your changes as well.

Powered by a free Atlassian Confluence Open Source Project License granted to Hyperic HQ. Evaluate Confluence today.
Powered by Atlassian Confluence 2.7.1, the Enterprise Wiki. Bug/feature request - Atlassian news - Contact administrators