Setting up Your Development Environment
To ensure a good productivity when building Lenya applications, it is essential that you have a well-configured development environment.
The following steps guide you through the process of setting up the Eclipse IDE for Lenya. The paths apply to a Unix-like operating system, for Windows you have to change the paths accordingly and replace all shell script names with the names of the corresponding batch files.
-
Check out the Lenya trunk and the Cocoon branch 2.1 from the Subversion repository (see Installation Instructions). I suggest to use the following directory layout:
src/ apache/ lenya/ trunk/ -> LENYA_HOME cocoon/ branches/ BRANCH_2_1_X/ -> COCOON_HOME
You don't need to set these environment variables, I only use them in this tutorial.
Note that we don't use the Cocoon version which ships with Lenya, but a separate working copy of Cocoon. This is necessary because Eclipse doesn't support nested projects.
The
apache
directory will come in handy when you start serious development, because you're likely to peek into the source code of other ASF projects like Excalibur or Xalan. -
Edit
$LENYA_HOME/local.build.properties
and set the propertycocoon.src.dir
to the path of your$COCOON_HOME
directory. When you use the suggested directory structure, this would be../../cocoon/branches/BRANCH_2_1_X
. -
Go to the
$COCOON_HOME
directory and execute./build.sh eclipse-project
This creates the Cocoon project files for Eclipse. -
Go to the
$LENYA_HOME
directory and execute./build.sh eclipse-project
This creates the Lenya project files for Eclipse. - You can now import both projects in Eclipse.
- If your Lenya project complains that various packages are not found, it is probably necessary to edit the Java Build Path properties of your Cocoon project and select all libraries on the Order and Export tab.
- In the Preferences pane, you have to configure the Java compiler to use the 1.4 compliance level.
-
Eclipse stores the class files in
$LENYA_HOME/build/eclipse
by default. Whenever you execute./build.sh clean
, it gets confused. To avoid this, set the default output folder in Project properties > Build path > Source to a different directory (e.g.$LENYA_HOME/eclipse
). - A decent XML and XSLT editor is recommended, you can for instance install the web tools platform from the Eclipse project.
- Have fun!
Debugging Lenya
There are two options to easily debug Lenya with the Eclipse debugger:
- the servlet-debug target when starting with Jetty, and
- the Tomcat plug-in for Eclipse.
To debug Lenya in Jetty,
-
Start the application using the following command:
./lenya.sh servlet-debug
- In Eclipse, choose the menu item Run > Open Debug Dialog.
- Add a Remote Java Application entry. The default connection properties (localhost at port 8000) are OK.
- If you have custom projects, add them in the Source tab.
- Click the Debug button to connect the Eclipse debugger to your Lenya application.