Wednesday, November 14, 2007

Getting started with the development environment.

Well the first step for this project is setting up the development environment. I did this once before for this project, but I had to re-do it a bit because of a bug in Tapestry 5.0.6 (the latest version as of writing this). Tapestry can't find resources if the work folder for the servlet container (I'm using Tomcat - I don't know if it's Tomcat specific) has spaces in the path. It throws up an ugly error message. Given that I want Tapestry to work with the Tomcat shipped with OpenLaszlo I had to take that into consideration.

Ok, so the first thing I did was install the latest JDK. In installed by default to C:\Program Files\Java\jdk1.6.0_03 and as I would like to use ANT, I set the JAVA_HOME environment variable to that path as seen in the screenshot below.

You can get to the environment variable system properties by pressing the Windows key and the Pause button (or alternatively right click on my computer and select properties). From there navigate to the advanced tab and then environment variables. Click New to create a new System variable or double click on an existing one to edit its value.



With that done I downloaded the latest version of Apache Ant (1.7.0 as of this writing) I could find and extracted that to C:\Program Files\Apache Software Foundation\apache-ant-1.7.0 and added the bin folder to the System path. You can see a screenshot of the path modification below.

The path was placed in quotes and appended after a semi-colon. So the path would have ended in ;"C:\Program Files\Apache Software Foundation\apache-ant-1.7.0\bin". A test of typing ant from the command prompt should result in a message "Buildfile: build.xml does not exist!". This shows ANT is working, but doesn't know what to do.

The next step is to install OpenLaszlo. By default it installs into the program files folder. Do not accept the default path! Install into C:\work\OpenLaszloServer4.0.6 (notice no spaces) as seen in the screenshot below.

I'm not setting up any database stuff as yet as my primary concern is getting OpenLaszlo and Tapestry talking to each other. That and I haven't quite decided if I should be using something like hibernate or directly talking to the database in the configuration.

The final step is to setup the folders for the development process. I've included a screenshot below of the layout I have.

The OpenLaszlo4.0.6 folder is basically populated by the OpenLaszlo installer so I'll focus on the buccoo folder.
  • The lib subfolder contains all the jars that are dependent for Buccoo to compile properly.
  • The res subfolder has a temporary work area (to make some automated tasks simpler) as well as being an easy spot to integrate anything else that may require more than just copying a jar to the lib folder.
  • The src folder contains all the sources for the Tapestry side of Buccoo organized in the org.tobago.buccoo package.
  • The war folder should be created by the ANT script. It contains the contents as it should be for the final Buccoo.war file. It would copy files from the lib, compiled classes as well as any WAR specific files from the web folder.
  • The web folder contains any non-java resources (like Tapestry tml files) and meta-data (like the web.xml in the META-INF) that we want to include in the war.

That's it! Now we're ready to start writing the ant build.xml file to automate the compilation process.

1 comment:

Raju Bitter said...

Nice post. You'll find an example ANT build file showing how to compile LZX files out of ANT, bundle apps for deployment at

http://svn.openlaszlo.org/labs/lzproject/trunk/build.xml

The LZProject OpenLaszlo 4 blueprint application explains in detail how you can easily connect OpenLaszlo to a Java back-end.
http://labs.openlaszlo.org/lzproject/

Best regards,
Raju
OpenLaszlo Community Manager