SipX ConfigServer Eclipse
From SIPfoundry sipx, The Open Source SIP PBX for Linux - Calivia
work in progress
Tips on how to configure Eclipse to contribute to sipXconfig project.
Contents |
General Remarks
You should feel free to use whatever developement environment suits your needs. If you happen to use NetBeans, emacs or anything else please share your experience. Let us know if you would like to keep configuration files for your environment in sipXconfig subversion repository.
While I am pretty sure most modern IDEs have the following features, the major reasons why I am using Eclipse today are here:
- excellent code browser
- built-in refactoring support
- code formatter that can be configured to comply with sipX coding standards
- unit test support - writing and executing unit test from IDE
- good subversion plugin - commit, update, diff and graphical merge support
- other plugins for libraries and technologies used in sipXconfig: SQL Explorer, Spring, Tapestry, XML etc.
- decent remote debugging support
Installation
Get the latest stable build of Eclipse and install it on the system. Some Linux distributions (Fedora Core 4) include eclipse. However Eclipse install without any problems on Linux, Windows and Mac OS X.
Go to Eclipse Download Site, click on latest stable 3.1 build and download Eclipse SDK version appropriate for your platform.
Eclipse has a notion of workspaces and project. Workspace is a set of related projects that share common options (compilation, code formatting etc.). From my experience it's best to have one workspace per subversion branch (i.e. a separate workspaces for main, 2.8, 2.6 etc.)
Configuration
Set common configuration options.
Classpath
- Go to Windows->Preference screen
- Select Java->Build Path->Classpath Variables and add the following
SIPX_CONFIG=path to sipXconfig directory
SIPX_BUILD=path to sipXconfig build output, default is same as SIPX_CONFIG
The sipXconfig directory is located where you checked it out using Subversion. You need a separate Eclipse workspace for each Eclipse branch, since each branch will have a different SIPX_CONFIG setting.
JAVA_LIBDIR=path to the default jar installation directory
On most systems it will be: /usr/share/java. If your distribution is using jpackage-utils to install java packages you can probably find the proper value for this property by running:
grep JAVA_LIBDIR /etc/java/java.conf
If you have source code for Tapestry, Spring, and other modules, then set the LIB_SRC variable to point to the parent directory of the directory in which sources are kept, for example:
LIB_SRC=/opt/libsrc
Providing this variable makes it easy to step through the source in Eclipse.
Java Code Style Options
- Go to Windows->Preferences->Java->Code Style
- add m_ prefix for fields
- uncheck "qualify all generated field access with this."
- Go to Windows->Preferences->Java->Code Style->Code Formatter
- import sipXconfig/meta/eclipse.code-formatter.xml - this will make Eclipse format your code according to sipX project coding standards (press Esc Ctrl-F to format your code)
- Go to Windows->Preferences->Java->Code Style->Code Templates
- Import templates from: sipXconfig/meta/eclipse.code-templates.xml - this will make Eclipse generate SIPfoundry-compliant file headers
Java Compatibility Options
SipXconfig requires Java 1.5:
- Go to Windows->Preferences->Java->Compiler and check that the "compiler compliance level" is set to 1.5.
- Go to Windows->Preferences->Java->Installed JREs and select a 1.5 JRE. If there is no 1.5 JRE on your computer, then you will need to install one.
Other useful options
Plugins
Installing these plugins is optional, but they do have plenty of features that would simplify developement.
Some plugins have "update sites" - you can easily update them through Eclipse UI.
- Help->Software Updates->Search and Install
- press Import Sites and select sipXconfig/meta/eclipse.update-sites.xml
You can now get the following plugins:
- Subclipse
- If you use subversion you need to install this plugin. On top of nice repository browser and quite a few useful feature - such as history and graphical diff - the most important thing is that if your refactoring will change or move the files subversion will be aware of that (git tracks all the moves and renames automatically, so if you use git you do not need any special Eclipse plugin for refactoring).
The imported eclipse.update-sites.xml file contains two entries for Subclipse - one for Subclipse 1.0.x, and one for Subclipse 1.2.x. 1.2.x series of Subclipse requires Eclipse 3.2. If you are running an older version (3.0/3.1) of Eclipse, you should install the 1.0.x Subclipse. You can safely unselect Mylan and Buckmaster optional packages.
Subclipse is now distributed with JavaSVN which provides a platform independent bindings for subversion client. Alternatively you can install platform specific bindings but it is harder to configure and it does not seem to have significant performance benefits. If for some reason default JavaSVN bindings do not work for you, try this:
- Install platform specific bindings - on Fedora you can use yum:
yum install subversion-javahl
- Modify eclipse command line - add
-vmargs -Djava.library.path=/usr/lib
- You'll need to delete any workspaces you may have created or you'll get an error regarding duplicate resources found in "src/.svn/..."
- Restart Eclipse.
- Spring IDE
- Spring framework support (bean file verification)
Other plugins have to be downloaded and install manually (by copying the plugin to /path/to/eclipse/plugins directory).
- Jetty Launcher
- Support for launching and debugging JavaEE web projects from within Eclipse.
The JettyLauncher plugin allows you to launch and debug sipXconfig from within Eclipse. This is especially useful for working on UI changes as the changes appear immediately upon refreshing the app from within a browser. After installing the plugin you will need to configure it to work with sipXconfig using the following steps.
- Run web app once
- cp build/web/tests/war/WEB-INF/classes/sipxconfig.properties web/test/sipxconfig.properties (may have to refresh and/or clean web project from eclipse)
- Select "Run/Open Run Dialog..." from Eclipse menu and create a new Jetty Web configuration
- Set the following parameters:
- Main Tab
- Jetty home: [Location of your Jetty (full) installation]
- webroot: context
- Args Tab
- VM Arguments (add this argument): -Dorg.apache.tapestry.disable-caching=true
- Classpath Tab
- Add neoconf project
- Main Tab
The disable-caching VM argument forces tapestry to re-render pages for each request. This allows you to see your latest changes immediately, even if they are to a .html, .page, or .jwc file
Projects
The last step is opening sipXconfig projects. All necessary configuration files are kept in subversion repository (these are .project and .classpath file in sipXconfig subdirectories) - it's easy to open projects in Eclipse by importing them.
- go to File->Import...
- select Existing Project into Workspace
- browse for your sipXconfig directory (the same as set in SIPX_CONFIG property above)
- Eclipse 3.1 will find all sipXconfig projects (neoconf, web, profilegenerator etc.), older versions of Eclipse will prompt you for each project separately
- press Select All, and Finish
All projects are automatically compiled in background. You are ready to go.
Using Eclipse for C/C++ projects
Eclipse can be used as a C/C++ development environment. You need to install the C/C++ Development Toolkit (CDT) that can be found at http://www.eclipse.org/cdt/ . You will need to get Eclipse (version 3.3.0 at least) (http://www.eclipse.org/downloads/) and the Eclipse CDT (download.eclipse.org/tools/cdt/releases/europa).
Please see this document for more details.
Eclipse on Gentoo
- Read this page http://gentoo-wiki.com/Eclipse
- Install/select Sun's 1.4 JDK
- Get recent version of eclipse
echo "dev-util/eclipse-sdk ~x86" >> /etc/portage/package.keywords emerge dev-util/eclipse-sdk
