[jbossseam-issues] [JBoss JIRA] Commented: (JBSEAM-997) Hot deploy of Seam components in a WAR

Christian Bauer (JIRA) jira-events at lists.jboss.org
Wed Mar 7 12:41:22 EST 2007


    [ http://jira.jboss.com/jira/browse/JBSEAM-997?page=comments#action_12355322 ] 
            
Christian Bauer commented on JBSEAM-997:
----------------------------------------

This is an alternative build.xml I am using with IntelliJ (can't and don't want to split my source folder to compile into two different output paths). This is all based on seam-gen project which I have modified (completely almost). 

You need a build.properties:

jboss.home = /Users/turin/work/local/jboss/jboss-4.0.5.GA
hotdeploy.classes = **/wiki/core/action/* **/wiki/core/dao/* **/wiki/core/links/*
javac.debug = true
javac.deprecation = false
javac.nowarn = on

And the build.xml:

<?xml version="1.0"?>

<project name="wiki" default="explodewar" basedir=".">

    <!-- ################## CONFIG ####################### -->

    <!-- Give user a chance to override without editing this file or typing -D -->
    <property file="${basedir}/build.properties" />

    <property name="profile" value="dev"/>

    <!-- set global properties for this build -->
    <property name="project.name" value="wiki"/>

    <property name="src.java.dir" value="src/main"/>
    <property name="src.test.dir" value="src/test"/>
    <property name="src.etc.dir"  value="src/etc"/>
    <property name="view.dir"     value="view"/>

    <property name="build.dir"          value="build"/>
    <property name="classes.dir"        value="${build.dir}/classes"/>
    <property name="testclasses.dir"    value="${build.dir}/testclasses"/>
    <property name="exploded.dir"       value="${build.dir}/exploded"/>
    <property name="exploded.war.dir"   value="${exploded.dir}/${project.name}.war"/>

    <property name="deploy.dir"         value="${jboss.home}/server/default/deploy"/>
    <property name="deploy.war.dir"     value="${deploy.dir}/${project.name}.war"/>

    <property name="dist.dir" value="dist" />

    <property name="lib.dir" value="lib" />

    <property name="embedded-ejb3.dir" value="${basedir}/embedded-ejb/conf" />

    <!-- ################## ALIASES ####################### -->

    <patternset id="meta.files">
        <include name="**/*.xml"/>
        <include name="**/*.properties"/>
        <include name="**/*.sql"/>
        <include name="**/*.MF"/>
    </patternset>

    <fileset id="lib" dir="${lib.dir}">
        <include name="*.jar" />
    </fileset>

    <path id="build.classpath">
        <fileset refid="lib" />
    </path>

    <!-- ################## SETUP ####################### -->

    <target name="init" description="Initialize the project build">
        <mkdir dir="${dist.dir}"/>
        <mkdir dir="${classes.dir}"/>
        <mkdir dir="${testclasses.dir}"/>
        <mkdir dir="${exploded.war.dir}"/>
    </target>

    <target name="clean" description="Cleans up all build artifacts">
        <delete dir="${dist.dir}"/>
        <delete dir="${build.dir}"/>
    </target>

    <!-- ################## COMPILE ####################### -->

    <target name="compileclasses" depends="init"
            description="Compile the main Java source code">

        <javac classpathref="build.classpath"
                    destdir="${classes.dir}"
                      debug="${javac.debug}"
                deprecation="${javac.deprecation}"
                     nowarn="${javac.nowarn}">
            <src path="${src.java.dir}" />
        </javac>

        <!-- Copy resources (mapping files, properties, etc.) to classes -->
        <copy todir="${classes.dir}">
            <fileset dir="${src.java.dir}">
                <patternset refid="meta.files"/>
            </fileset>
        </copy>

    </target>

    <!-- ################## EXPLODE ####################### -->

    <target name="explodewar" depends="explodehotdeployclasses, exploderesources"
            description="Creates a hot-redeployable exploded WAR directory">
    </target>

    <target name="explodehotdeployclasses" depends="compileclasses">
        <copy todir="${exploded.war.dir}/WEB-INF/classes">
            <fileset dir="${classes.dir}" excludes="${hotdeploy.classes}"/>
        </copy>
        <copy todir="${exploded.war.dir}/WEB-INF/dev">
            <fileset dir="${classes.dir}" includes="${hotdeploy.classes}"/>
        </copy>
    </target>

    <target name="explodeallclasses" depends="compileclasses">
        <copy todir="${exploded.war.dir}/WEB-INF/classes">
            <fileset dir="${classes.dir}"/>
        </copy>
    </target>

    <target name="exploderesources" depends="compileclasses">

        <!-- ########## XHTML ########### -->
        <copy todir="${exploded.war.dir}">
            <fileset dir="${view.dir}"/>
        </copy>

        <!-- ########## Libs ########### -->
        <copy todir="${exploded.war.dir}/WEB-INF/lib">
            <fileset dir="${lib.dir}">
                <include name="ajax4jsf.jar" />
                <include name="oscache*.jar" />
                <include name="jsf-facelets.jar" />
                <include name="jboss-seam.jar" />
                <include name="jboss-seam-*.jar" />
                <exclude name="jboss-seam-gen.jar" />
                <include name="drools-*.jar"/>
                <include name="janino-*.jar"/>
                <include name="antlr-*.jar"/>
                <include name="commons-jci-*.jar"/>
                <include name="stringtemplate-*.jar"/>
                <include name="jbpm*.jar" />
                <include name="el-*.jar" />
            </fileset>
        </copy>
        <!-- TODO: Do we need this in etc? -->
        <copy todir="${exploded.war.dir}/WEB-INF">
            <fileset dir="${src.etc.dir}/WEB-INF">
                <include name="lib/*.*"/>
            </fileset>
        </copy>

        <!-- ########## Configuration files (WEB-INF) ########### -->
        <copy todir="${exploded.war.dir}/WEB-INF">
            <fileset dir="${src.etc.dir}/WEB-INF">
                <patternset refid="meta.files"/>
            </fileset>
            <!-- Set JBoss JNDI lookup pattern and disable embeddable EJB 3.0 container in Seam config files-->
            <filterset>
                <filter token="jndiPattern" value="${project.name}/#{ejbName}/local"/>
                <filter token="embeddedEjb" value="false"/>
            </filterset>
        </copy>

        <!-- ########## Configuration files (WEB-INF/classes) ########### -->
        <copy todir="${exploded.war.dir}/WEB-INF/classes">
            <fileset dir="${src.etc.dir}">
                <include name="seam.properties" />
                <include name="security.drl" />
                <include name="messages*.properties"/>
                <include name="*jpdl.xml" />
                <include name="hibernate.cfg.xml" />
                <include name="jbpm.cfg.xml" />
            </fileset>
        </copy>
        <copy tofile="${exploded.war.dir}/WEB-INF/classes/import.sql"
                file="${src.etc.dir}/import-${profile}.sql"
           overwrite="true"/>
        <!-- Replace @@LF@@ in import.sql with real SQL char(10) linefeed (concat)-->
        <replace file="${exploded.war.dir}/WEB-INF/classes/import.sql" token="@@LF@@" value="'+char(10)+'"/>

        <!-- ########## Configuration files (WEB-INF/classes/META-INF) ########### -->
        <copy todir="${exploded.war.dir}/WEB-INF/classes/META-INF">
            <fileset dir="${src.etc.dir}/META-INF">
                <include name="wiki.taglib.xml"/>
            </fileset>
        </copy>
        <copy tofile="${exploded.war.dir}/WEB-INF/classes/META-INF/persistence.xml"
                file="${src.etc.dir}/META-INF/persistence-${profile}-war.xml"
                overwrite="true"/>

    </target>

    <!-- ################## DEPLOYMENT ####################### -->

    <target name="hotdeploy" depends="compileclasses"
            description="Deploys only hotdeployable classes/resources to JBoss AS">
        <fail unless="jboss.home">jboss.home not set</fail>

        <!-- ######## Classes ######## -->
        <copy todir="${deploy.war.dir}/WEB-INF/dev">
            <fileset dir="${classes.dir}" includes="${hotdeploy.classes}"/>
        </copy>

        <!-- ######## XHTML ######## -->
        <copy todir="${deploy.war.dir}">
            <fileset dir="${view.dir}"/>
        </copy>

    </target>

    <target name="deploy" depends="explodewar"
            description="Deploy datasource and exploded archive to JBoss AS">
        <fail unless="jboss.home">jboss.home not set</fail>

        <!-- ######## Datasoure ######## -->
        <copy todir="${deploy.dir}">
            <fileset dir="${src.etc.dir}">
                <include name="${project.name}-${profile}-ds.xml" />
            </fileset>
        </copy>

        <!-- ######## Exploded WAR ######## -->
        <copy todir="${deploy.war.dir}">
            <fileset dir="${exploded.war.dir}"/>
        </copy>

    </target>

    <target name="undeploy"
            description="Undeploy datasource and exploded archive">
        <fail unless="jboss.home">jboss.home not set</fail>

        <delete dir="${deploy.war.dir}" failonerror="no"/>
        <delete file="${deploy.dir}/${project.name}-${profile}-ds.xml" failonerror="no"/>

    </target>

    <target name="redeploy" depends="deploy" description="Deploy and restart the WAR">
        <touch file="${deploy.war.dir}/WEB-INF/web.xml"/>
    </target>

    <!-- ######################## DISTRIBUTION ################## -->

    <target name="dist" depends="clean, explodeallclasses, exploderesources"
            description="Package a WAR archive">

        <jar jarfile="${dist.dir}/${project.name}.war" basedir="${exploded.war.dir}"/>

        <copy tofile="${dist.dir}/${project.name}-ds.xml"
                file="${src.etc.dir}/${project.name}-${profile}-ds.xml"/>
        
    </target>

<!--
    <target name="compiletest" unless="eclipse.running" description="Compile the Java source code for the tests">
        <mkdir dir="${test.dir}"/>
        <javac classpathref="build.classpath"
                        destdir="${test.dir}"
                          debug="${javac.debug}"
                    deprecation="${javac.deprecation}"
                        nowarn="on">
                <src path="${src.components.dir}" />
                <src path="${src.other.dir}" />
                <src path="${src.test.dir}" />
        </javac>
    </target>

    <target name="buildtest" depends="compiletest" description="Build the tests">
        <copy todir="${test.dir}">
            <fileset dir="${basedir}/resources">
                <exclude name="META-INF/persistence*.xml"/>
                <exclude name="import*.sql"/>
                <exclude name="${project.name}-*-ds.xml"/>
            </fileset>
        </copy>
        <copy tofile="${test.dir}/META-INF/persistence.xml"
                file="${basedir}/resources/META-INF/persistence-test-war.xml"
           overwrite="true"/>
        <copy tofile="${test.dir}/import.sql"
                file="${basedir}/resources/import-test.sql"
           overwrite="true"/>
        <copy todir="${test.dir}" flatten="true">
            <fileset dir="${src.test.dir}">
                <include name="**/*Test.xml" />
            </fileset>
        </copy>
    </target>

    <target name="test" depends="buildtest" description="Run the tests">
        <taskdef resource="testngtasks" classpath="${testng.jar}" />
        <testng outputdir="${basedir}/test-report">
            <classpath path="${test.dir}" />
            <classpath path="${embedded-ejb3.dir}" />
            <classpath refid="build.classpath" />
            <xmlfileset dir="${test.dir}" includes="*Test.xml" />
        </testng>
    </target>
    -->

</project>


I'm not done with the testing stuff. In IntelliJ, configure a Web Module, make src/main/ the only source folder and select build/classes/ as the output folder. Then configure the 'hotdeploy' Ant target to run After Compilation. I also have a shortcut on 'redeploy' which I use after modifying classes that are not hot-redeployable.

As an option I can configure the JBoss DeploymentScanner to directly deploy my build/exploded/ directory, then all the copying goes away. The 'hotdeploy' and 'redeploy' targets would have to be changed for that. 


> Hot deploy of Seam components in a WAR
> --------------------------------------
>
>                 Key: JBSEAM-997
>                 URL: http://jira.jboss.com/jira/browse/JBSEAM-997
>             Project: JBoss Seam
>          Issue Type: Feature Request
>          Components: Core
>            Reporter: Gavin King
>         Assigned To: Gavin King
>             Fix For: 1.2.1.GA
>
>
> Seam JavaBean components deployed into WEB-INF/dev should be subject to hot re-deploy w/o a container restart.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the seam-issues mailing list