You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Dominique Plante <dp...@pacbell.net> on 2002/08/22 23:48:20 UTC

Using ANT to deploy an EJB JAR to JBoss and run a client application

I just wanted to share my experience on how I changed an existing build
target so that it would conditionally add JBoss specific deployment
files, based on whether a property is present.
The build file in question also has a target for running a client that
uses the EJB mentioned above.

Here is the target before I made the change:
  <target name="ejbjar" depends="compile">
    <jar jarfile="build/titan.jar">
      <fileset dir="${build.classes.dir}">
        <include name="com/titan/cabin/*.class"/>
      </fileset>
      <fileset dir="${src.resources}/">
          <include name="**/*.xml"/>
      </fileset>
     </jar>
  </target>

Here is the target after I made the change:
  <target name="ejbjar" depends="compile">
    <jar jarfile="build/titan.jar">
      <fileset dir="${build.classes.dir}">
        <include name="com/titan/cabin/*.class"/>
      </fileset>
      <fileset dir="${src.resources}/">
          <include name="**/*.xml"/>
      </fileset>
      <fileset dir ="${src.jboss.resources}/">
          <patternset>
            <include name="**/*.xml" if="deploy-JBoss"/>
            <exclude name="**/*" unless="deploy-JBoss"/>
          </patternset>
      </fileset>
     </jar>
  </target>

To conditionally include the files in the jar, you must have a line like
the following before this target is defined:
	<property name="deploy-JBoss" value="true"/>

To never include the files in the jar, you can either comment out the
line, or erase it.  The commented version of the line is something like:
	<!--property name="deploy-JBoss" value="true"/-->

Note that I further isolated JBoss specific files into their own
directory.

My original intention was to augment the generic ejbjar target, then
have another JBoss-deploy target that would add to the jar file.  The
reason that this did not work for me is because I ran into problems when
running a client that was launched from an ANT target and that was
dependent on the JBoss-deploy target.  I would get errors that the
server was unavailable at some point during client execution - this was
because the JAR was being redeployed as the client was running.

The build file is from the JBoss 3.0 Workbook (see
http://www.monson-haefel.com/titanbooks/download.html)

I finally found the ant-contrib documentation at
http://ant-contrib.sourceforge.net/ant-contrib/manual/
And the library at
http://gump.covalent.net/jars/latest/ant-contrib/ant-contrib-20020821.ja
r (and the source at
http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/ant-contrib/).  I thought
I would be able to use <if> task, but I got answer saying I couldn't use
it within the <jar> task.

If someone can suggest a better way or doing this, I would like to read
about it - email me.

Dom


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>