Configuring Bedework to work with Eclipse
Overview of process
The process I use almost fully automates the build/deploy cycle. If the developers patch the code in SVN all I need to do is (1) synchronize code in eclipse (2) run “ant clean.deploy” in the Bedework build file (3) run my custom “build.all” ant target which will unzip the WAR files generated by the Bedework ant script, apply any custom code/patches, and zip them back up again (4) run my custom “deploy.all” script that will upload all the WAR files to our server (5) restart tomcat.
Here’s what the finished workspace looks like:
Things to keep in mind
- Don’t place any custom code in the project you are checking out from the Bedework SVN. Put your custom code in a separate project(s) and create ant scripts that will patch the WAR files generated by the Bedework build scripts in the quickstart. Also, don’t modify the Bedework ant scripts. Anything you modify you’ll need to worry about merging in the future. Keeping code in a separate project prevents it from accidentally being overwritten when synchronizing with the bedework SVN. And you want to be able to check your code into your own local SVN, so it needs to be in a separate project (you can’t map the same project to multiple SVN locations).
- The quickstart contains files that aren’t in SVN (e.g. the master build.xml file that kicks off the one in the Bedework directory in SVN). You’ll need to download the quickstart and place it on your local file system, then map the SVN project so it overwrites the files in the quickstart when you synchronize it.
- You might want to create a separate workspace for Bedework. If eclipse decides to rebuild the entire workspace (on crash etc) it can take forever, so the less projects the better. It also looks cleaner and it’s how Mike has his setup.
Download and install the quickstart
- Download the Bedework quick start for the version you’re working with. Unzip and place in a directory named:
[Do not build the project yet. Doing so will create a bunch of duplicate libraries and slow you down when you define the project in eclipse below]
(Of course you can use C:\ You’ll want a version name on the directory, as you’ll end up needing to work with more than one version at some point)
If you unzipped it right you’ll see a directory structure like:
Next, you want to have eclipse setup so you can just update from SVN and have it overwrite what’s currently in the quickstart. This will make it easy to rebuild with patches. So in eclipse:
- Install SVN eclipse plug-in. Download it from:
- Go to SVN repository exploring view and define a new repository location and point to:
(Change this URL to whatever version you are working with)
Now look at the directory structure in the SVN repository. It should look something like:
You’ll map this directory to:
So that when you update from SVN it overwrites the files in the quickstart. Note: prior to your first checkout, move the existing bedework directory out of the way or delete it. The checkout process will recreate it.
Checkout project from SVN, overwriting quickstart files
- In eclipse, Right-click on the SVN project in the repository exploring perspective and choose “checkout…” Choose “checkout as a project configured using the New Project Wizard”. Click Finish. Choose Java > Java Project in the tree view. Click Next. For project name use “bedework-3.4.1”. Choose “create project from existing source” radio button. Browse to “F:/bedework-3.4.1/bedework” (create the directory if it doesn’t exist). Click Finish.
(Note that you are going to want to have multiple Bedework projects in the workspace. So make sure you have the version number in the project name and all directories)
Now if you checkout from SVN it will overwrite the quickstart files.
Setup classpath (do this before you run ant clean.deploy)
- Do this so the project will compile in eclipse. Switch to java perspective. Rt-click on project and choose “properties”. Go to “java build path”. Click on “source” tab. Click “add folder” and add any folder you want to compile in eclipse. There are a lot of source folders. Example locations are:
/projects/access/src /projects/calendarapi/src …
- Go to libraries tab. Add libraries. Add all the ones under the /lib directory. There are also project specific libraries in most of the project dirs. You’ll need to figure out what libraries need to be added from each project. Avoid duplicates. You can use a full text search of the directory on the file system for whatever the missing class name is and identify the required library that way. At least that’s what I do.
How to find libraries – an example of stuff I use
So here’s how I find the libraries. I do this a lot with other applications so I might as well throw it in here. Eclipse can’t compile Bedework because it can’t find javax.portlet.PortletURL (see image):
I’ve been using this agent ransack thing for awhile (it’s free). It’s much quicker than windows built in text search. Just type in what you’re looking for and it’ll find the jars. It’s lightning fast after the first search completes. It must cache stuff in memory or something.
Ok, so the project should now compile in eclipse with (mostly) no errors.
If you did this right your project will look something like this in the package view:
Update and Build
Now let’s say you want to update because they’ve patched the code. Just right-click on the project in the Java perspective, go to “team”, and choose “synchronize with repository”. Then just “update” from the repository, it will download and overwrite the files in the quickstart.
Customize Bedework build stuff
The Bedework build script will read from a file named “bedework.build.properties” if it is located in your home directory (in my case on windows my home directory is at C:\Documents and Settings\cmann.CMANN2). This file is the same as “env.properties” (it’s just renamed). You probably want to do a diff in eclipse to see if the developers have added anything, and update the “bedework.build.properties” file in your home directory accordingly. Note that you want to keep this in your home directory to keep in from being overwritten.
Now switch to the command line and change to the F:\bedework-3.4.1\ directory. Run the command:
This will build all the wars and put them in:
Customizing the generated WAR files
I’ve got ANT scripts that go through and customize each of the generated war files. I keep these scripts in separate project called “bedework-3.4-umd”. Here’s what the project looks like:
The “build-all.xml” has a build.all and deploy.all target. It goes through and triggers the build scripts for each individual war (in the subdirectories). These do various things like copy my customized default.xsl, hibernate.properties, options.xml files into each WAR and copy custom libraries (like the oracle JDBC driver), and rebuild the war files. Then I have a deploy.all target that uses the sshexec ant task to copy it all up to the server, set permissions etc. If you don’t know how to use the sshexec and scp ant tasks you should really try them out. They allow you to automate all sorts of stuff on the server.
I've attached the ant scripts I use to this page. See the comments at the top of each script for information on how to use/configure them. You'll need to install the following libraries to the base ant install:
(See link on web page for dependent libraries you need to download for each task)
(There are more tricks to getting it to work, but hopefully this will help you out)
(Also, you can follow this procedure for say bedework-3.5 and create separate projects etc. This will make it possible to upgrade since you’ll have different versions running in dev and prod and will probably need to patch the prod one while working on the dev one)
Feel free to add/update as needed.
Thanks to these guys for suggestions etc:
And Mike and Arlen