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 to contain this:


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=""></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=""></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=""></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=""></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=""></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=""></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}">

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="" tofile="${project.home}/">

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