Here's my ant file for creating an EAR file.  I use one JAR for the EJB
stuff and one for the WAR stuff.  The base classes I copy into both
archive files.  I do this for simplicity more then anything else.
<!--
$Author: grim $
$Revision: 1.3 $
$Log: build.xml,v $
Revision 1.3  2001/06/03 07:12:54  grim
Realm is no longer needed with the upgrade to JBOSS, and it now builds
a ear file.

Revision 1.2  2001/05/31 01:14:19  grim
Getting the file to properly build WAR and EARs.  Still have to get it
to combine them and
put them in a single EAR.

Revision 1.1.1.1  2001/05/25 18:24:27  grim
Initial import into CVS


-->
<project name="Webville" default="All" basedir="." >

    <property name="jbossHome"          value= "/var/backend/jboss"/>
    <property name="tomcatHome"         value= "/var/backend/tomcat"/>
    <property name="jbossClientHome"    value= "${jbossHome}/client"/>
    <property name="build"              value= "/tmp/Webville"/>
    <property name="ejbBuild"           value= "${build}/ejb"/>
    <property name="webBuild"           value= "${build}/web"/>
    <property name="classBuild"         value= "${build}/classes"/>
    <property name="earBuild"           value= "${build}/ear"/>
    <!--<property name="jboss"              value=
"/var/backend/jboss"/>-->
    <property name="EJBDeploy"          value= "${jbossHome}/deploy"/>
    <property name="WARDeploy"          value=
"/var/backend/tomcat/webapps"/>

    <property name="jbossJarFiles"      value=
"${jbossClientHome}/jaas.jar:${jbossClientHome}/ejb.jar:${jbossHome}/lib/jboss-jaas.jar:${jbossClientHome}/jnp-client.jar:${jbossClientHome}/jboss-client.jar:${jbossClientHome}/jbosssx-client.jar:${jbossClientHome}/jbossmq-client.jar:${jbossClientHome}/connector.jar:${jbossHome}/lib/jdbc2_0-stdext.jar:${jbossHome}/lib/ext/jbosssx.jar"/>
    <property name="tomcatJarFiles"     value=
"${tomcatHome}/lib/servlet.jar:${tomcatHome}/lib/webserver.jar"/>
    <property name="miscJarFiles"       value=
"${jbossHome}/lib/ext/log4j.jar"/>
    <property name="classpath"          value=
"${jbossJarFiles}:${tomcatJarFiles}:/usr/local/lib/java/mm.mysql-2.0.4.jar:${miscJarFiles}"/>

    <property name="sourceDir"          value= "/home/grim/Webville"/>
    <property name="javaSourceDir"      value= "${sourceDir}/com"/>
    <property name="warSourceDir"       value= "${sourceDir}/docroot"/>





<!--
PREPARE
-->
        <target name="prepare">
    <!--Prepare the working directory-->
    <mkdir dir="${build}"/>

                <delete includeEmptyDirs="true">
                        <fileset dir="${build}"/>
                </delete>

    <!--<mkdir dir="${WARDeploy}/Webville"/>
    <delete includeEmptyDirs="true">
        <fileset dir="${WARDeploy}/Webville"/>
    </delete>
    -->
    <!--Prepare the EJB directory structure-->
    <mkdir dir="${classBuild}"/>

    <!--Prepare the war file structure-->
    <mkdir dir="${webBuild}"/>
    <mkdir dir="${webBuild}/WEB-INF"/>
    <mkdir dir="${webBuild}/WEB-INF/classes"/>
    <mkdir dir="${webBuild}/WEB-INF/lib"/>
    <mkdir dir="${webBuild}/WEB-INF/tlds"/>

    <!--Prepare the Enterpirse application file structure-->
    <mkdir dir="${earBuild}"/>
    <mkdir dir="${earBuild}/META-INF"/>

        </target>





<!--
Compile all of the java classes in the source tree for use by the
various
packagers.
-->
    <target name="CompileEverything" depends="prepare">
        <javac srcdir="${javaSourceDir}" destdir="${classBuild}"
            debug="on"
            deprecation="on"
            classpath="${classpath}"
        />
    </target>





<!--
Make sure that the latest copy of the tomcat realm is available
-->
    <target name="realm" depends="CompileEverything">
<!--        <jar jarfile="${build}/realm.jar">
            <fileset dir="${classBuild}"/>
        </jar>
        <copy file="${build}/realm.jar"
            todir="${jbossHome}/lib/ext" />
-->
    </target>





<!--
Create the ear file for the EJB
-->
        <target name="EJB" depends="CompileEverything">
    <!--Copy all of the Meta inf for the ejb classes into the build
            META-INF dir-->
                <copy todir="${ejbBuild}/META-INF">
        <fileset dir="META-INF">
            <exclude name="application.xml"/>
        </fileset>
                </copy>

                <copy todir="${ejbBuild}/">
        <fileset dir="${classBuild}"/>
                </copy>

    <!--Jar it up for deployment -->
                <jar jarfile="${build}/Webville.jar" >
        <fileset dir="${ejbBuild}"/>
    </jar>

        </target>





<!--
Create the WAR file for the EJB
-->
        <target name="WAR" depends="EJB">
    <copy todir="${webBuild}/WEB-INF/classes">
        <fileset dir="${classBuild}"/>
    </copy>

    <copy todir="${webBuild}">
        <fileset dir="${warSourceDir}"/>
    </copy>

    <copy todir="${webBuild}/WEB-INF/lib">
        <fileset dir="${jbossHome}/client"/>
    </copy>

    <jar jarfile="${build}/Webville.war">
        <fileset dir="${webBuild}"/>
    </jar>

    <!--<copy todir="${WARDeploy}/Webville">
        <fileset dir="${webBuild}"/>
    </copy>
    -->
        </target>


<!--
Build Everything
-->
        <target name="All" depends="prepare, realm, EJB, WAR">
    <!--First copy the ejb jar and war files into the application
directory-->
    <copy file="${build}/Webville.jar" todir="${earBuild}"/>
    <copy file="${build}/Webville.war" todir="${earBuild}"/>

    <!--Copy the application.xml file into the META-INF direcotry-->
    <copy file="${sourceDir}/META-INF/application.xml"
todir="${earBuild}/META-INF"/>


    <!--JBOSS will try and deploy a jar file, even if it is not done
being built
        so we, have to build it then copy it.-->

    <!-- EAR it up :) -->
    <jar jarfile="${build}/Webville.ear">
        <fileset dir="${earBuild}"/>
    </jar>

                <copy file="${build}/Webville.ear" todir="${EJBDeploy}"/>
    
        </target>

</project>

--- Marcel Schepers <[EMAIL PROTECTED]> wrote:
> Hello,
> 
> Besides the connection troubles mentioned in an earlier post I have
> one other thing on my mind. While investigating the connection
> problem
> I found out that I am not deploying my web application in a correct
> manner. For the record, I am using JBoss with Tomcat embedded. The
> deal seems to be to create one ear file and let JBoss/Tomcat sort it
> out. The creation of one EAR file is very confusing for me. For
> instance, do need to create at least two jar files? One containing
> only EJB's and one containing the regular java classes who act as
> proxy for the EJB's. And futhermore, I would like to automate the
> creation of the .ear file using Ant. Has anyone done that? And if so,
> could you give me some guidelines on how to setup the directory
> structure? Perhaps some Ant example code?
> 
> Thanks,
> Marcel
> 
> 
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/jboss-user


=====
Grim Shieldsson (James A Barrows)
Acting Chieftain of Clan StormWolf
Barbarian Freehold Alliance
Oppurtunity doesn't knock.  It only presents itself after you kick down the door.
--Kyle Chandler

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/

_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to