Site Network: Personal | Professional | Photography

Technical Blog

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 part two

This is a follow-up from my post two days ago "seam-gen and multiple projects".

After some feedback from "atao" in this thread on the JBoss Seam forum, I have taken a different approach to the problem, and have enhanced seam-gen to generate targets within the generated project's ant build script, which in turn call the related seam-gen tasks. This is more elegant for two reasons. Firstly, the projects are independent and don't rely on special configs kept outside of the project. Secondly, you can run those tasks from within your IDE (Eclipse for me) while doing development. You don't have to fire up a command prompt, navigate to your seam installation, and run the seam-gen commands there. All in all a much better solution. Thank you very much "atao" for the better approach.

The changes made to the seam-gen related files are slightly more extensive than the previous approach, but well worth it.

First: in $SEAM_HOME/seam-gen/build-scripts you need to change build.properties to contain this:

jboss.home=@jbossHome@
seamgen.home=@seamGenHome@

Second: in $SEAM_HOME/seam-gen/build-scripts you need to add the following block at the bottom of the build file (just before the tag):


<target name="update-project" description="Update project dependencies">
<ant antfile="${seamgen.home}/build.xml" target="update-project" dir="${seamgen.home}"></ant></target>

<property file="seamgen.properties"></property> <target name="new-action" description="Create a new action">
<ant antfile="${seamgen.home}/build.xml" target="new-action" dir="${seamgen.home}"></ant></target>
<property file="seamgen.properties"></property> <target name="new-form" description="Create a new form action">
<ant antfile="${seamgen.home}/build.xml" target="new-form" dir="${seamgen.home}"></ant></target>
<property file="seamgen.properties"></property> <target name="new-conversation" description="Create a new conversation">
<ant antfile="${seamgen.home}/build.xml" target="new-conversation" dir="${seamgen.home}"></ant></target>
<property file="seamgen.properties"></property> <target name="new-entity" description="Create a new entity">
<ant antfile="${seamgen.home}/build.xml" target="new-entity" dir="${seamgen.home}"></ant></target>
<property file="seamgen.properties"></property> <target name="generate-entities" description="Reverse engineer entities from the database">
<ant antfile="${seamgen.home}/build.xml" target="generate-entities" dir="${seamgen.home}"></ant></target>
<property file="seamgen.properties"></property>

Finally, in $SEAM_HOME/seam-gen you need to make a few edits to build.xml:

in the definition of the "project" filterset, within the "init-properties" target, you need to add the following filter (I put mine right after line 97 of revision 1.90):

<filter token="seamGenHome" value="${basedir}">
</filter>

Then, in the "file-copy" target, you need to add the following task call (I put mine on line 632 of revision 1.90):

<copy file="build.properties" tofile="${project.home}/seamgen.properties">
</copy>

If you want to just download the enhanced files here they are (based on the current head as of today):

$SEAM_HOME/seam-gen/build-scripts/build.properties
$SEAM_HOME/seam-gen/build-scripts/build.xml
$SEAM_HOME/seam-gen/build.xml

Enjoy!

Devon

One Response to “seam-gen and multiple projects part two”

  1. Devon Says:

    One thing to note: If you are using Eclipse 3.3 (as I am), then this bug:

    https://bugs.eclipse.org/bugs/show_bug.cgi?id=195986

    Will prevent you from using some of the seam-gen tasks from within Eclipse. The use of defaultvalues for user input causes Eclipse 3.3 to throw a NullPointerException. Hopefully we’ll get a fix in 3.3.1.

Leave a Reply