0 Replies Latest reply on May 20, 2005 11:54 AM by garbett

    Using Ant to Configure JBoss from SCM

    garbett

      I have the original JBoss 4.0.2 source and the EJB3.0 source in CVS (any Software Configuration Management tool will work), along with the configuration files. I also have some other pieces and bits that need installation. To put it all together I use an Ant build file that assembles the works. All developers on our team have the same configuration. If you need a change in the configuration, all developers can pull and work from the updated configuration with a simple pull and build command. Automated testing also works from the same setup. No more configuration guesswork between boxes.

      Here's what I have, enjoy:

      # Sources
      project.src=${basedir}/../project/src
      jboss.src=${project.src}/jboss-4.0.2.tar.bz2
      jboss-ejb30.src=${project.src}/jboss-EJB-3.0_Preview_5.zip
      struts.src=${project.src}/jakarta-struts-1.2.4.tar.gz
      collections.src=${project.src}/commons-collections-3.1.tar.gz
      collections.dir=${srv.dir}/commons-collections-3.1
      
      # Jboss
      jboss.srv=${jboss.dir}/server/cnet
      jboss.dir=${srv.dir}/jboss-4.0.2
      jboss.home=${jboss.dir}
      jboss.client=${jboss.home}/client
      jboss.server=${jboss.srv}
      jboss.deploy=${jboss.srv}/deploy
      jboss-ejb30.dir=${srv.dir}/jboss-EJB-3.0_Preview_5
      
      # Tomcat
      tomcat.home=${jboss.deploy}/jbossweb-tomcat55.sar
      
      # Struts
      struts.dir=${srv.dir}/jakarta-struts-1.2.4
      


      <project name="phoenix" default="all" basedir=".">
      
       <property file="../common/build/build.properties"/>
      
       <target name="clean">
       <delete dir="${srv.dir}"/>
       </target>
      
       <target name="all" depends="assemble"/>
      
       <target name="assemble"
       depends="jboss-assemble,ejb30-assemble,struts-assemble"/>
      
       <!-- Install JBoss with configuration from CVS -->
       <target name="jboss-unpack">
       <mkdir dir="${srv.dir}"/>
       <untar src="${jboss.src}" dest="${srv.dir}" compression="bzip2"/>
       <mkdir dir="${jboss.srv}" />
       </target>
      
       <target name="jboss-assemble" depends="jboss-unpack">
       <!-- Create target server from all -->
       <copy todir="${jboss.srv}">
       <fileset dir="${jboss.dir}/server/all"/>
       </copy>
       <!-- Copy additional libraries to install -->
       <copy todir="${jboss.srv}/lib">
       <fileset dir="${web.lib}" includes="*.jar"/>
       </copy>
       <!-- Copy local configuration files from CVS -->
       <copy todir="${jboss.srv}" overwrite="true">
       <fileset dir="${common.jboss.conf}" includes="**/*.xml"/>
       </copy>
       <!-- Set the permissions on the run script -->
       <chmod file="${jboss.dir}/bin/run.sh" perm="755"/>
       </target>
      
       <!-- Install EJB3.0 to JBoss -->
       <target name="ejb30-unpack">
       <unzip src="${jboss-ejb30.src}" dest="${srv.dir}"/>
       <mkdir dir="${jboss.deploy}/ejb3.deployer"/>
       </target>
      
       <target name="ejb30-assemble" depends="ejb30-unpack">
      
       <copy todir="${jboss.deploy}/ejb3.deployer">
       <fileset dir="${jboss-ejb30.dir}/lib/ejb3.deployer" includes="**"/>
       </copy>
      
       <copy todir="${jboss.deploy}">
       <fileset dir="${jboss-ejb30.dir}/lib"
       includes="*.xml"/>
       </copy>
      
       <mkdir dir="${jboss.deploy}/jboss-aop-jdk50.deployer"/>
       <copy todir="${jboss.deploy}/jboss-aop-jdk50.deployer">
       <fileset dir="${jboss-ejb30.dir}/lib/jboss-aop-jdk50.deployer"
       includes="**"/>
       </copy>
      
       <delete dir="${jboss.deploy}/jboss-aop.deployer"/>
      
       <!-- Fix bug in Hibernate Libraries in packaging-->
       <copy todir="${jboss.srv}/lib">
       <fileset dir="${jboss.deploy}/ejb3.deployer"
       includes="hibernate*.jar"/>
       <fileset dir="${jboss.deploy}/jboss-hibernate.deployer"
       includes="hibernate*.jar"/>
       </copy>
       <delete>
       <fileset file="${jboss.deploy}/ejb3.deployer/hibernate*.jar"/>
       <fileset file="${jboss.deploy}/jboss-hibernate.deployer/hibernate*.jar"/>
       </delete>
      
      
       </target>
      
       <!-- Unpacke Struts for use in build -->
       <target name="struts-assemble">
       <untar src="${struts.src}" dest="${srv.dir}" compression="gzip"/>
       <untar src="${collections.src}" dest="${srv.dir}" compression="gzip"/>
       <!-- Upgrade collections to 3.1 -->
       <delete file="${struts.dir}/lib/commons-collections.jar"/>
       <copy file="${collections.dir}/commons-collections-3.1.jar"
       todir="${struts.dir}/lib"/>
       <!-- This copies the libs to the common lib of JBoss
       It is commented out because this is unsupported by struts.
       I.E. Never do this. See the following (Section 5.5)
       http://struts.apache.org/userGuide/configuration.html#dd_config
       Instead, the jars are packaged with each app.
       <copy todir="${jboss.srv}/lib" overwrite="false">
       <fileset dir="${struts.dir}/lib" includes="**/*.jar"/>
       </copy>
       -->
       </target>
      
       <target name="start-server">
       <exec executable="${jboss.dir}/bin/run.sh" os="Linux">
       <arg value="-c"/>
       <arg value="cnet"/>
       </exec>
       <exec executable="${jboss.dir}/bin/run.bat"
       os="Windows 2000,Windows XP,Windows NT">
       <arg value="-c"/>
       <arg value="cnet"/>
       </exec>
       </target>
      
      </project>