3 Replies Latest reply on Nov 27, 2008 2:06 PM by Andres Navarro

    Good build.xml to build the ear file

    Urs Wagner Novice

      Is there a good template for an ANT build.xml
      file?
      I would like to compile, build, deploy, undeploy, test an ear application.

      Thanks for Your support.

        • 1. Re: Good build.xml to build the ear file
          wayne baylor Apprentice

          here's one i threw together, i'll leave it to you to figure out the dir structure that goes along with it :)

          <project name="web budget" default="" basedir=".">
          
           <property name="ejb.src.dir" value="ejb/src"/>
           <property name="web.src.dir" value="web/src"/>
           <property name="entity.src.dir" value="entity/src"/>
          
           <property name="ejb.meta-inf.dir" value="ejb/META-INF"/>
           <property name="web.web-inf.dir" value="web/WEB-INF"/>
           <property name="entity.meta-inf.dir" value="entity/META-INF"/>
           <property name="meta-inf.dir" value="META-INF"/>
          
           <property name="build.dir" value="build"/>
           <property name="dist.dir" value="${build.dir}/dist"/>
           <property name="classes.dir" value="${build.dir}/classes"/>
           <property name="archives.dir" value="${build.dir}/archives"/>
          
           <property name="jboss.deploy.dir" value="C:\Program Files\jboss-4.2.0.GA\server\default\deploy"/>
           <property name="jboss.lib.dir" value="C:\Program Files\jboss-4.2.0.GA\server\default\lib"/>
          
           <target name="compile">
           <mkdir dir="${classes.dir}"/>
          
           <javac destdir="${classes.dir}">
           <classpath>
           <fileset dir="${jboss.lib.dir}" includes="jboss-ejb3x.jar, ejb3-persistence.jar, servlet-api.jar"/>
           </classpath>
          
           <src path="${entity.src.dir}"/>
           <src path="${ejb.src.dir}"/>
           <src path="${web.src.dir}"/>
           </javac>
           <copy todir="${classes.dir}" flatten="true">
           <fileset dir="${web.src.dir}" includes="**/*.jsp"/>
           </copy>
           </target>
          
           <target name="package">
           <mkdir dir="${archives.dir}"/>
           <mkdir dir="${dist.dir}"/>
          
           <jar destfile="${archives.dir}/entity.jar" basedir="${classes.dir}" includes="**/model/*.class">
           <metainf dir="${entity.meta-inf.dir}" includes="*.xml"/>
           </jar>
          
           <jar destfile="${archives.dir}/ejb.jar" basedir="${classes.dir}" includes="**/eao/*.class">
           <metainf dir="${ejb.meta-inf.dir}" includes="*.xml"/>
           </jar>
          
           <war destfile="${archives.dir}/web.war" webxml="${web.web-inf.dir}/web.xml">
           <webinf dir="${web.web-inf.dir}" includes="*.xml" excludes="web.xml"/>
           <classes dir="${classes.dir}" includes="**/servlet/*.class"/>
           <fileset dir="${classes.dir}" includes="**/*.jsp"/>
           </war>
          
           <ear destfile="${dist.dir}/budget.ear" basedir="${archives.dir}"
           appxml="${meta-inf.dir}/application.xml">
           <metainf dir="${meta-inf.dir}" includes="*.xml" excludes="application.xml"/>
           </ear>
           </target>
          
           <target name="clean">
           <delete dir="${build.dir}"/>
           </target>
          
           <target name="deploy">
           <copy file="${dist.dir}/budget.ear" todir="${jboss.deploy.dir}"/>
           </target>
          </project>


          • 2. Re: Good build.xml to build the ear file
            Wolfgang Knauf Master

            If you need some kind of deployer which waits for successful deployment after copying the EAR/JAR/WAR file, I can offer you a bit of code I wrote for the Eclipse Web Tools JBoss plugin. It is basically an ant task, so it should be easy to extract it.

            You can find it here (code and ant file are in the linked zip):
            http://www.informatik.fh-wiesbaden.de/~knauf/public (Section "WTP 2.0: Serverdefinition with improved deployment support for JBoss 4.0 and JBoss 4.2")

            Best regards

            Wolfgang

            • 3. Re: Good build.xml to build the ear file
              Andres Navarro Newbie

              ohhhh
              This is exactly what I was looking for waynebaylor.
              Great script. Is not common to find people who want to control of the process. It was very useful.

              Thanks