Build.xml

From ADR TechWiki

Jump to: navigation, search

<project>

   <property file="build.properties"/>

   <path id="svnant.classpath">
    <pathelement location="${svnant.dir}/svnjavahl.jar" />
    <pathelement location="${svnant.dir}/svnant.jar" />
    <pathelement location="${svnant.dir}/svnClientAdapter.jar" />
   </path>

   <taskdef resource="svntask.properties" classpathref="svnant.classpath"/>

   <tstamp>
      <format property="build.date" pattern="MMddyyyy-HHmmss" timezone="America/Denver"/>
   </tstamp>

   <target
      name="clean-staging-all"
      depends="clean-staging-all-adrws,clean-staging-all-adrlib,clean-staging-all-etexts,clean-staging-all-etds" />

   <!-- @@CLEAN ALL -->
   <target name="clean-staging-all-adrws">
     <symlink action="delete" link="${staging.wwwdir}/adrws"/>
     <delete includeemptydirs="true">
        <fileset dir="${staging.wwwdir}"
           includes="adrws_*/** adrws_*"/>
     </delete>
     <delete file="${staging.wwwdir}/adrws"/>
   </target>

   <target name="clean-staging-all-adrlib">
     <symlink action="delete" link="${staging.wwwdir}/adrlib"/>
     <delete includeemptydirs="true">
        <fileset dir="${staging.wwwdir}"
           includes="adrlib_*/** adrlib_*"/>
     </delete>
     <delete file="${staging.wwwdir}/adrlib"/>
   </target>

   <target name="clean-staging-all-etexts">
     <symlink action="delete" link="${staging.wwwdir}/etexts"/>
     <delete includeemptydirs="true">
        <fileset dir="${staging.wwwdir}"
           includes="etexts_*/** etexts_*"/>
     </delete>
     <delete file="${staging.wwwdir}/etexts"/>
   </target>

   <target name="clean-staging-all-etds">
     <symlink action="delete" link="${staging.wwwdir}/etds"/>
     <delete includeemptydirs="true">
        <fileset dir="${staging.wwwdir}"
           includes="etds_*/** etds_*"/>
     </delete>
   </target>
   <!-- CLEAN ALL@@ -->


   <!-- DEPLOY ALL -->
   <target
      depends="deploy-staging-etds,deploy-staging-adrlib,deploy-staging-adrws,deploy-staging-etexts"
      name="deploy-staging-all"/>


   <!-- ETDS STAGING DEPLOYMENT -->
   <target name="deploy-staging-etds">

      <property
        name="destpath_etds"
        value="${staging.wwwdir}/etds_${build.versiontag}_${build.date}"
      />

      <echo message="Deploying ETDS to staging server ${staging.servername} (${destpath_etds})"/>

      <!-- EXPORT/COPY Repository code -->
      <delete dir="${destpath_etds}"/>

      <svn javahl="${javahl}">
         <export srcurl="${svn.src.etds}"
                 destpath="${destpath_etds}"
         />
      </svn>

      <!-- delete unnecessary directories and files -->
      <delete dir="${destpath_etds}/etd1/storage"/>
      <delete dir="${destpath_etds}/etd2/storage"/>
      <delete dir="${destpath_etds}/documentation"/>
      <delete dir="${destpath_etds}/logs"/>

      <delete>
         <fileset dir="${destpath_etds}" includes="*.txt"/>
      </delete>

      <delete>
         <fileset dir="${destpath_etds}" includes="*.doc"/>
      </delete>

      <symlink overwrite="true" link="${staging.wwwdir}/etds" resource="${destpath_etds}"/>

      <!-- *** -->
   </target>

   <!-- ADRLIB STAGING DEPLOYMENT -->
   <target name="deploy-staging-adrlib">

      <property
        name="destpath_adrlib"
        value="${staging.wwwdir}/adrlib_${build.versiontag}_${build.date}"
      />

      <echo message="Deploying ADRLIB to staging server ${staging.servername} (${destpath_adrlib})"/>

      <!-- EXPORT/COPY Repository code -->
      <delete dir="${destpath_adrlib}"/>

      <svn javahl="${javahl}">
         <export srcurl="${svn.src.adrlib}"
                 destpath="${destpath_adrlib}"
         />
      </svn>

      <!-- delete unnecessary directories and files -->
      <delete file="${destpath_adrlib}/setup.conf.php"/>
      <delete dir="${destpath_adrlib}/setup"/>
      <delete dir="${destpath_adrlib}/templates_c"/>

      <delete file="${destpath_adrlib}/error_handler.log"/>
      <touch file="${destpath_adrlib}/error_handler.log"/>
      <mkdir dir="${destpath_adrlib}/templates_c"/>

      <delete>
         <fileset dir="${destpath_adrlib}" includes="errors*"/>
      </delete>

      <delete>
         <fileset dir="${destpath_adrlib}"
            includes="config.inc.*" />
<!--            excludes="config.inc.staging" -->
      </delete>

      <delete dir="${destpath_adrlib}/wwwrun"/>

      <delete>
         <fileset dir="${destpath_adrlib}" includes="refresh.php"/>
      </delete>

      <!-- copy the config.inc.php -->
      <copy overwrite="true" file="/www/${target}/staging/config.inc.php" todir="${destpath_adrlib}"/>
      <copy overwrite="true" file="/www/${target}/staging/include/class.adr_config.php" todir="${destpath_adrlib}/include"/>
      <copy overwrite="true" file="/www/${target}/staging/images/banner_grad.png" todir="${destpath_adrlib}/images"/>

      <symlink overwrite="true" link="${staging.wwwdir}/staging" resource="${destpath_adrlib}"/>

      <!-- add symlink to flash viewer directory -->
      <symlink overwrite="true" link="${staging.wwwdir}/staging/flviewer/flvsvr" resource="${flvsvr.location}"/>
<!-- kem@@08/25/08 : do we need a new staging
      <move file="${staging.wwwdir}/adrlib/config.inc.staging"
         tofile="${staging.wwwdir}/adrlib/config.inc.php"/>
-->
      <chgrp group="www">
         <dirset dir="${staging.wwwdir}/staging"/>
<!--         <fileset dir="${staging.wwwdir}/adrlib" includes="**"/>  -->
      </chgrp>

      <chown owner="wwwrun">
<!--         <fileset dir="${staging.wwwdir}/adrlib" includes="**"/> -->
         <dirset dir="${staging.wwwdir}/staging"/>
      </chown>


      <!-- *** -->
   </target>


   <!-- ADRLIB STAGING DEPLOYMENT : INTIALIALIZED AND READY FOR SETUP -->
   <target name="deploy-staging-adrlib-init">

      <property
        name="destpath_adrlib"
        value="${staging.wwwdir}/adrlib_${build.versiontag}_${build.date}"
      />

      <echo message="Deploying INTIALIAL ADRLIB to staging server ${staging.servername} (${destpath_adrlib})"/>

      <!-- EXPORT/COPY Repository code -->
      <delete dir="${destpath_adrlib}"/>

      <svn javahl="${javahl}">
         <export srcurl="${svn.src.adrlib}"
                 destpath="${destpath_adrlib}"
         />
      </svn>

      <!-- delete unnecessary directories and files -->
      <delete file="${destpath_adrlib}/setup.conf.php"/>
      <delete dir="${destpath_adrlib}/templates_c"/>

      <delete file="${destpath_adrlib}/error_handler.log"/>
      <touch file="${destpath_adrlib}/error_handler.log"/>
      <mkdir dir="${destpath_adrlib}/templates_c"/>

      <delete>
         <fileset dir="${destpath_adrlib}" includes="errors*"/>
      </delete>

      <delete>
         <fileset dir="${destpath_adrlib}"
            includes="config.inc.*" />
<!--            excludes="config.inc.staging" -->
      </delete>

      <delete dir="${destpath_adrlib}/wwwrun"/>

      <delete>
         <fileset dir="${destpath_adrlib}" includes="refresh.php"/>
      </delete>

      <symlink overwrite="true" link="${staging.wwwdir}/staging" resource="${destpath_adrlib}"/>

      <!-- add symlink to flash viewer directory -->
      <symlink overwrite="true" link="${staging.wwwdir}/staging/flviewer/flvsvr"
resource="${flvsvr.location}"/>
<!-- kem@@08/25/08 : do we need a new staging
      <move file="${staging.wwwdir}/adrlib/config.inc.staging"
         tofile="${staging.wwwdir}/adrlib/config.inc.php"/>
-->
      <chgrp group="www">
         <dirset dir="${staging.wwwdir}/staging"/>
<!--         <fileset dir="${staging.wwwdir}/adrlib" includes="**"/>  -->
      </chgrp>

      <chown owner="wwwrun">
<!--         <fileset dir="${staging.wwwdir}/adrlib" includes="**"/> -->
         <dirset dir="${staging.wwwdir}/staging"/>
      </chown>

      <echo message="NOTE : Please be sure to configure the instance and remove the setup directory after configuration and installation!"/>
      <!-- *** -->
   </target>


   <!-- ADR ETEXTS STAGING DEPLOYMENT -->
   <target name="deploy-staging-etexts">

      <property
        name="destpath_etexts"
        value="${staging.wwwdir}/etexts_${build.versiontag}_${build.date}"
      />

      <echo message="Deploying E-TEXTS to staging server ${staging.servername} (${destpath_etexts})"/>

      <!-- EXPORT/COPY Repository code -->
      <delete dir="${destpath_etexts}"/>

      <svn javahl="${javahl}">
         <export srcurl="${svn.build.etexts}"
                 destpath="${destpath_etexts}"
         />
      </svn>

      <!-- delete unnecessary directories and files -->
      <delete file="${destpath_etexts}/CHANGES"/>
      <delete file="${destpath_etexts}/INSTALL"/>
      <delete file="${destpath_etexts}/LICENSE"/>

      <delete>
         <fileset dir="${destpath_etexts}" includes="LICENSE_*"/>
      </delete>

      <delete>
         <fileset dir="${destpath_etexts}"
            includes="index.*"
            excludes="index.staging index.php.staging"/>
      </delete>

      <symlink overwrite="true" link="${staging.wwwdir}/etexts" resource="${destpath_etexts}"/>

      <!-- This is for the PHP redirct to the tomcat instance -->
      <move file="${staging.wwwdir}/etexts/index.php.staging"
         tofile="${staging.wwwdir}/etexts/index.php"/>

      <move file="${staging.wwwdir}/etexts/index.staging"
         tofile="${staging.wwwdir}/etexts/index.htm"/>

      <symlink overwrite="true" link="${staging.wwwdir}/etexts/data" resource="/devobj/xtf/data"/>

      <echo message="Building XTF index for staging ..."/>
      <exec dir="${staging.wwwdir}/etexts/bin"
            executable="perl">
         <env key="XTF_HOME" value="/usr/local/tomcat/webapps/staging_etexts"/>
         <arg value="textIndexer"/>
         <arg value="-clean"/>
         <arg value="-index default"/>
      </exec>


      <chgrp group="tomcat">
         <fileset dir="${staging.wwwdir}/etexts"/>
      </chgrp>

      <chown owner="tomcat">
         <fileset dir="${staging.wwwdir}/etexts"/>
      </chown>

      <!-- *** -->
   </target>

   <!-- ADR ADRWS STAGING DEPLOYMENT -->
   <target name="deploy-staging-adrws">

      <property
         name="destpath_adrws"
         value="${staging.wwwdir}/adrws_${build.versiontag}_${build.date}"
      />

      <echo message="Deploying ADRWS to staging server ${staging.servername} (${destpath_adrws})"/>

      <!-- EXPORT/COPY Repository code -->
      <mkdir dir="${destpath_adrws}/tmp"/>
      <mkdir dir="${destpath_adrws}/tmp/classes"/>

      <svn javahl="${javahl}">
         <export srcurl="${svn.src.adrws-src}"
                 destpath="${destpath_adrws}/tmp/src" />

         <export srcurl="${svn.src.adrws-webxml}"
                 destpath="${destpath_adrws}/tmp/web.xml" />

         <export srcurl="${svn.src.adrws-lib}"
                 destpath="${destpath_adrws}/tmp/lib" />

         <export srcurl="${svn.src.adrws-webcontent}"
                 destpath="${destpath_adrws}/tmp/content" />
      </svn>


      <!-- COMPILE THE SOURCES -->
      <javac srcdir="${destpath_adrws}/tmp/src"
             destdir="${destpath_adrws}/tmp/classes"
             listfiles="yes">
         <classpath>
            <fileset dir="${destpath_adrws}/tmp/lib">
               <include name="**/*.jar"/>
            </fileset>
         </classpath>
      </javac>

      <!-- MAKE A WAR FOR THE WEBAPP -->
      <war destfile="${destpath_adrws}/ADRWS.war" webxml="${destpath_adrws}/tmp/web.xml">
         <fileset dir="${destpath_adrws}/tmp/content"/>
         <lib dir="${destpath_adrws}/tmp/lib"/>
         <classes dir="${destpath_adrws}/tmp/classes"/>
      </war>

      <available file="${destpath_adrws}/ADRWS.war" property="isWarAvail"/>
      <fail unless="isWarAvail" message="WAR doesn't exist - cannot deploy ADRWS webapp!"/>

      <delete dir="${destpath_adrws}/tmp"/>

      <symlink overwrite="true" link="${staging.wwwdir}/adrws" resource="${destpath_adrws}"/>
   </target>



   <!-- ADR HANDLES STAGING DEPLOYMENT -->
   <target name="deploy-staging-handles">

      <property
         name="destpath_handles"
         value="${staging.wwwdir}/handles_${build.versiontag}_${build.date}"
      />

      <echo message="Deploying HANDLES to staging server ${staging.servername} (${despath_handles})"/>

      <!-- EXPORT/COPY Repository code -->

      <svn javahl="${javahl}">
         <export srcurl="${svn.build.handles}"
                 destpath="${destpath_handles}" />
      </svn>

      <delete>
         <fileset dir="${destpath_handles}"
            includes="*.txt"/>
      </delete>

      <symlink overwrite="true" link="${staging.wwwdir}/handles" resource="${destpath_handles}"/>


      <!-- MAKE A WAR FOR THE WEBAPP -->
<!--
      <war destfile="${destpath_adrws}/ADRWS.war" webxml="${destpath_adrws}/tmp$
         <fileset dir="${destpath_adrws}/tmp/content"/>
         <lib dir="${destpath_adrws}/tmp/lib"/>
         <classes dir="${destpath_adrws}/tmp/classes"/>
      </war>

      <available file="${destpath_adrws}/ADRWS.war" property="isWarAvail"/>

-->

   </target>


   <!-- ADRLIB LIVE DEPLOYMENT -->
   <target name="deploy-live-adrlib">
      <echo message="${build.date}"/>

      <!-- SSH Files to the production server -->
      <exec executable="rsync">
         <arg line="rsync -e ssh -avz ${staging.etdsdir} ${production.user}@${production.servername}:${production.etdsdir}etds_${production.versiontag}_${build.date}" />
      </exec>
      <!-- *** -->

   </target>

   <!-- ETDS LIVE DEPLOYMENT -->
   <target name="deploy-live-etds">
      <echo message="${build.date}"/>

      <!-- SSH Files to the production server -->
      <exec executable="rsync">
         <arg line="rsync -e ssh -avz ${staging.etdsdir} ${production.user}@${production.servername}:${production.etdsdir}etds_${production.versiontag}_${build.date}" />
      </exec>
      <!-- *** -->

   </target>

</project>

Personal tools