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):









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):



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



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


Posted

in

, ,

by

Comments

3 responses to “seam-gen and multiple projects part two”

  1. Devon Avatar

    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.

  2. ngonidan Avatar
    ngonidan

    One important thing, so how do we run the scripts/projects above,

    To help out others who might get stuck here,

    Now, there is NO more any need to go to the seam directory to run seam setup etc,

    I quote Devon here:

    The above changes enhance seam-gen to generate targets within the generated project’s ant build script, which in turn call the related seam-gen tasks.

    SO this means each projects build.xml file created from now onwards, has the code added above which enables it to call seam-gen tasks, so to run the above from the command prompt, just change directory to the projects root folder and type ant, by default ant looks for a build file called build.xml if none is specified on the command line and then runs the tasks there in this case resulting in seam-gen tasks being called just like you had type seam setup etc.

    i.e.
    H:\testseammultipleprojects>ant
    Buildfile: build.xml
    init:
    groovy.compile:
    groovy.copy:
    compile:
    [javac] Compiling 3 source files to H:\testseammultipleprojects\
    exploded-archives\testseammultipleprojects.jar
    copyclasses:
    archive:
    [jar] Building jar: H:\testseammultipleprojects\dist\testseamm
    ultipleprojects.jar
    [jar] Warning: WEB-INF\classes\components.properties modified in the futur
    e.
    [jar] Building jar: H:\testseammultipleprojects\dist\testseamm
    ultipleprojects.war
    [jar] Building jar: H:\testseammultipleprojects\dist\testseamm
    ultipleprojects.ear
    datasource:
    deploy:
    [copy] Copying 1 file to C:\jboss-4.2.2.GA\server\default\deploy
    BUILD SUCCESSFUL
    Total time: 23 seconds

    Hope it helps, Saves a couple of hours and hair !!!!!

  3. ngonidan Avatar
    ngonidan

    Also just to correct my typo above i case it might be misunderstood, you need to run seam setup initially, but from then on no need !!!

Leave a Reply

Your email address will not be published. Required fields are marked *

PHP Code Snippets Powered By : XYZScripts.com