seam-gen and multiple projects

Home/Java/JBoss/Seam/seam-gen and multiple projects

seam-gen is a command line tool (although the new JBoss Tools eclipse plugin supports an Eclipse driven version as well) which can be used to create new Seam projects with a basic set of files, configs, and templates. It can also update the Seam jars in the project, do deployments, echo settings, create new actions, new forms, new entities, and so on. It is very handy, not only for developers who are just starting out with Seam, but also for experienced Seam developers (who might have customized the template resources which seam-gen uses to create the project framework).

The one big gap with seam-gen is that it keeps it’s project settings in a file in the seam-gen directory of the seam project (which I checkout from CVS as an Eclipse project, making it easy to update). What this means is that there is only one project supported. If I use seam-gen to create a new project called shoestore, then I create another project called yourspace, now I can’t use seam-gen to create a new form in shoestore, or update shoestore to the latest Seam jars.

Obviously if you’re only working on one project at a time, this isn’t a problem, but I tend to have multiple projects going at once. A couple existing applications in maintenance mode, a couple projects under development, and maybe a project or two to test something out in. So tonight I’ve made a couple of tiny changes to to the seam-gen tool, and the ant build.xml file it uses, which allow you to create, and continue to work with, any number of projects using seam-gen.

The two files to change are the seam (or seam.bat if you are using Windows) executable file (found in the root directory of your Seam downloaded (or checked-out) project) and the build.xml ant build file found inside the seam-gen directory, within the Seam project.

In the seam file you will want to replace lines 33-35 (at revision 1.20 at least) which look like this:

java -cp "${JAVA_HOME}\lib\tools.jar;..\lib\ant-launcher.jar;..\lib\ant-nodeps.jar;..\lib\ant.jar" -Dant.home=..\lib ${*}
java -cp "${JAVA_HOME}/lib/tools.jar:../lib/ant-launcher.jar:../lib/ant-nodeps.jar:../lib/ant.jar" -Dant.home=../lib ${*}

with the following lines:


[ "${2}" = "" ] then
java -cp "${JAVA_HOME}\lib\tools.jar;..\lib\ant-launcher.jar;..\lib\ant-nodeps.jar;..\lib\ant.jar" -Dant.home=..\lib ${*}
java -cp "${JAVA_HOME}\lib\tools.jar;..\lib\ant-launcher.jar;..\lib\ant-nodeps.jar;..\lib\ant.jar" -Dant.home=..\lib -propertyfile ${1} ${2}
if [ "${2}" = "" ] then
java -cp "${JAVA_HOME}/lib/tools.jar:../lib/ant-launcher.jar:../lib/ant-nodeps.jar:../lib/ant.jar" -Dant.home=../lib ${*}
java -cp "${JAVA_HOME}/lib/tools.jar:../lib/ant-launcher.jar:../lib/ant-nodeps.jar:../lib/ant.jar" -Dant.home=../lib -propertyfile ${1} ${2}

As I don’t have a Windows machine, I have not been able to test changes to the seam.bat version, but they should be similar.

Basically, what we are doing here, is if a second argument has been passed in (i.e. ‘seam myproject new-form’ instead of ‘seam new-form’) we use the first argument, assume it is the project name, and load up that project’s file when we call the actual seam-gen ant tasks.

The second part is to modify the actual build.xml ant build file to create project specific properties file when using ‘seam setup’.

Replace line 355 (on revistion 1.90) which looks like this:

<propertyfile file=""></propertyfile>

with this:

<propertyfile file="${}"></propertyfile>

Then replace line 381, which looks like this:

<echo message="Type 'seam new-project' to create the new project"></echo>

with this:

<echo message="Type 'seam ${} new-project' to create the new project">

That is all there is to it. Now, by prefacing a seam command with a project name, you can manage multiple projects with seam-gen.

Missing features include the windows seam.bat edit (I don’t have a Windows machine to test this on), and a list target to list available projects based on the files present (my Ant-fu is not strong enough).

The Eclipse generated patch file for the build.xml edits is here: build.xml patch file

The Eclipse generated patch file for the seam edits is here: seam patch file



By | 2017-05-18T15:18:59+00:00 August 17th, 2007|Java, JBoss, Seam|1 Comment

About the Author:

One Comment

  1. […] This blog will contain content related to Java, Seam, Security, my sites and projects, as well as other technical subjects I am interested in. Comments and questions are welcome! « seam-gen and multiple projects […]

Leave A Comment