wiki:Doc/SCDB/Eclipse

Version 27 (modified by /C=FR/O=CNRS/OU=UMR8607/CN=Michel Jouvin/emailAddress=jouvin@…, 12 years ago) (diff)

--

Using Eclipse with SCDB

Eclipse is an open source, multi-platform IDE (Integrated Development Environment) written in Java that provides a file browser, an editor, a SVN client, access to compilers and lot of other tools. It is neither part of SCDB, nor a requirement to use SCDB.

When used with SCDB, it brings a graphical interface for administering SCDB and editing templates. With very few customizations, Eclipse can be used to edit templates, compile them, and deploy machine profiles while taking advantage of all the advanced features you find in Eclipse: local history, file browsing and searching, ability to open a template directly at the line causing an error, and others.

Instructions in this page explain how to customize Eclipse for SCDB. This is not an introduction to Eclipse usage itself. Refer to online documentation in Eclipse. Configuration described here has already been tested on Linux, MacOS, and Windows but should work on any other platforms as all components used are pure Java.

Installation

Installing Eclipse

Eclipse can be downloaded from http://www.eclipse.org. The site provides pre-built distributions for Windows, Linux, and MacOSX making installation trivial. Recent versions of Eclipse offer several different pre-configured versions. For SCDB, the "Eclipse Classic" is the most appropriate.

Before being able to run Eclipse, you need to install Java JRE or JDK on your machine. SCDB requires Java 1.5 or later. You need to check on Eclipse site minimum Java version required by Eclipse.

If you have several Java JREs or JDKs installed on your machine, run Eclipse, goto Preferences->Java (in Window menu) and check the version used by Eclipse matches both Eclipse and SCDB requirements.

Note : Java JDK is required only for some advanced operations like generating new OS templates. Java JRE is enough for daily administration with SCDB.

Installating Eclipse plugins

For Eclipse to work with SCDB, some additional software, called plugins, needs to be installed. To do this, run Eclipse and use Install New Software...' in Help menu. In field Work with`, enter the URL mentionned below to install the plugins.

Note: in Eclipse prior to 3.5, the menu to use is Software Updates in Help menu (the exact dialog depends on the version). To install the plugin, it was first necessary to add the following URLs as new remote site`.

  • SVN plug-in : the plug-in used to interact with SVN. Plug-in to install depends on Eclipse version.
  • Sunshade : used for error linking between console and editor (useful for opening templates where an error occurred)
  • SVNKit : pure Java SVN client, providing both Java classes and a set of command line utilities compatible with SVN line mode client (command jsvn). This is not necessary when you use Subversive as SVN plug-in as it is provided with the SVN connector.
  • Pan editor: 2 editors are currently available
    • Eclipse Colorer editor: it can be download from http://colorer.sf.net/eclipsecolorer/ and requires some customizations for PAN language support.
    • PAN editor: it is still preliminary. The jar file must be downloaded from http://www.desy.de/~pfix/PAN_Colorer/ and dropped into your Eclipse plugins directory.

Configuration

File Encoding

You are encouraged to change the default encoding for the files that eclipse creates.

  • To do so, go to Window -> Preferences -> General -> Workspace, and change the Text file encoding to something that's supported on the nodes managed by quattor (iso8859-1 ?).
  • Also, you'll probably want to use UNIX newline styles, which you can choose in New text file line delimiter

Subclipse

If you use Sublipse, the default SVN interface chosen is JavaHL (JNI). This needs to be changed to SVNKit.

  • To do so goto Window -> Preferences -> Team -> SVN and select SVNKit (Pure Java) (or whatever SVNKit version is appropriate for you) in SVN Interface. Then press Apply and OK.
    • This might prompt an error message saying Failed to load JavaHL library. This can be ignored by pressing OK.

Pan language editor

Add an association between .tpl file extension and the editor. To do this, go to Window->Preferences->General->Editors->File Associations, check if an association for .tpl already exists (it should be added by the plugin) and check if the Pan editor is the default to open .tpl files.

Sunshade

If you have Sunshade installed inside eclipse, then you can hyperlink between errors generated by the pan compiler and the file. To do this you need to add some regular expressions to the Sunshade "Error Link" configuration. Open the Eclipse options panel (using Window->Preferences) and then navigate to the "Sunshade" and then "Error Link" pages. On this page add the following regular expressions:

\[panc\]\s*DEPRECATED:\s+(.*)\s+\[(\d+):(\d+)\]
\[([^\[\]]+\.tpl)(?::(\d+)\.(\d+)-\d+\.\d+)\]

The links identified with these expressions will take you to the start of the expression causing the error. Note that the error messages give you the full range of the expression in the format "beginLine.beginChar-endLine.endChar".

Note : The regexp above are intended for panc v7 and later. If you are still using panc v6 or before, you need to use a different set of regular expressions. Both can coexist.

\[pan-syntax\]\s*(.*\.tpl):(\d+):
\[pan-compile\]\s*(.*\.tpl):(\d+)
\[pan-syntax\].*[\s\(](.*\.tpl)

Colorer

If you choose to use the Colorer rather than the Pan editor, you need to do the following configuration. Else you can just ignore it.

Colorer is used to do syntax coloring when editing PAN templates.

Syntax coloring rules are defined in a file pan.hrc that can be downloaded from Quattor core sources (in util/eclipse/pan.hrc). This file must be placed in /path/to/eclipse/plugins/net.sf.colorer_VERSION/colorer/hrc/auto.

Note: in Colorer versions previous to 0.9, it was necessary to add an entry for these syntax colouring rules to /path/to/eclipse/plugins/net.sf.colorer_VERSION/colorer/catalog.xml. To achieve this, edit this this file and add the following line to the hrc-sets: <location link="hrc/auto/pan.hrc"/>.

Last, add an association between .tpl file extension and Colorer Editor. To do this, go to Window->Preferences->General->Editors->File Associations, add .tpl and associate the Colorer Editor with it.

For the new Colorer configuration to be taken into account, you need to restart Eclipse.

If you run into an error message like Error in initialization of native part of the Colorer library, this might mean 2 things

  • colorer can't find the catalog.xml file
  • it can't load the libnet_sf_colorer library
    • it can't find it
      • this shouldn't happen by default setup
    • the library is built against code that is not on your system
      • linux
        • locate the file (typically in $ECLIPSE_HOME/plugins/net.sf.colorer_x.y.z/os/linux/x86/
        • runn ldd $PATH_TO_DIR/libnet_sf_colorer.so
        • see if you have everything
          • eg on FC8, you need to install an additional rpm called compat-libstdc++-33

JavaSVN and certificates

When using JavaSVN in combination with certificates, you must add the password in the ~/.subversion/servers file. Make sure that this file has correct access rights (as it contains cleartext password, it must have mode 400).

A full example looks like :

[groups]
somegroup = some.full.host, *.some.domain
[somegroup]
ssl-client-cert-file = /bla/bla/bla.p12
ssl-client-cert-password=hahahahaha
[global]
ssl-authority-files = /bla/bla/bla/ca_local.crt

Configuring Java VM for Ant

Be sure to read instructions about running PAN compiler if you experiment any strange behaviour or slowness. Itis recommended to run SCDB Ant tasks in the same Java VM as Eclipse workspace, especially if your machine doesn't have a lot of memory (1 GB or more). You can check the current setting by right-clicking on the build.xml file in ant pane and choosing Run As...->External Tools and then clicking on JRE tab.

Note : it is not possible to use the same Java VM as the workspace if you need to adjust some VM parameters like maximum memory.

Known Problems

Look at page dedicated to SCDB FAQ.