<project name="ARJ's Ant Stuff" default="init" basedir=".">  <target name="init">    <echo message="Initializing build-library.xml" />    <property file="${basedir}/build.properties" />  </target>  <target name="unwar" depends="init">    <fail unless="srcwar">You need to supply the property "srcwar"!</fail>    <fail unless="build">You need to supply the property "build"!</fail>    <dirname file="${srcwar}" property="build" />    <property name="war.src" value="${build}/war" />    <echo message="Work dir is: ${war.src}" />    <mkdir dir="${war.src}" />    <unzip src="${srcwar}" dest="${war.src}" />  </target>  <!-- :::::::::::::::::: JSP COMPILATION :::::::::::::::::::: -->    <target name="java-jsp" depends="unwar">    <fail unless="tomcat.home">You need to supply the property "tomcat.home"!</fail>    <taskdef classname="org.apache.jasper.JspC" name="jasper2">      <classpath>        <path id="jspc.classpath">           <pathelement location="${java.home}/../lib/tools.jar" />           <fileset dir="${war.src}/WEB-INF/lib">             <include name="*.jar" />           </fileset>           <fileset dir="${tomcat.home}/server/lib">             <include name="*.jar" />           </fileset>           <fileset dir="${tomcat.home}/common/lib">             <include name="*.jar" />           </fileset>           <fileset dir="${tomcat.home}/bin">             <include name="commons-logging-api.jar" />           </fileset>         </path>      </classpath>     </taskdef>    <property name="jsp.java"          value="${build}/jsp/java" />    <property name="jsp.build.webxml"  value="${build}/jsp/generated-web.xml" />    <mkdir dir="${jsp.java}" />    <jasper2       validateXml="false"       uriroot="${war.src}"       outputDir="${jsp.java}"      poolingEnabled="false"      webXmlFragment="${jsp.build.webxml}"  />  </target>  <target name="compile-jsp" depends="java-jsp"    description="Pre-compiles JSPs">    <property name="jsp.classes"       value="${build}/jsp/classes" />    <property name="jsp.merged.webxml" value="${build}/jsp/merged-web.xml" />    <property name="jsp.jarfile"       value="${build}/jsp/precompiled-jsp.jar" />    <mkdir dir="${jsp.classes}"/>    <javac srcdir="${jsp.java}" destdir="${jsp.classes}">      <classpath refid="jspc.classpath"/>    </javac>    <jar jarfile="${jsp.jarfile}">      <fileset dir="${jsp.classes}" includes="**/*.class" />    </jar>    <loadfile property="generated-web.xml" srcFile="${jsp.build.webxml}"/>    <copy file="${war.src}/WEB-INF/web.xml" toFile="${jsp.merged.webxml}" overwrite="true">      <filterset begintoken="&lt;!--" endtoken="--&gt;">        <filter token=" PLACEHOLDER FOR PRE-COMPILED JSP SERVLETS " value="${generated-web.xml}" />      </filterset>    </copy>  </target>  <!-- Callers must pass  ${srcwar} and ${destwar} -->  <target name="war-tomcat" depends="compile-jsp"    description="Builds the WAR file for Tomcat (with pre-compiled JSPs)">    <fail unless="destwar">You need to supply the property "destwar"!</fail>    <war warfile="${destwar}"         webxml="${jsp.merged.webxml}" defaultexcludes="true">       <lib dir="${war.src}"   includes="*.jar"/>       <lib dir="${build}/jsp" includes="precompiled-jsp.jar" />       <fileset dir="${war.src}" defaultexcludes="yes">         <exclude name="**/*.jar"/>         <exclude name="**/*.jsp"/>         <exclude name="META-INF/**"/>         <exclude name="WEB-INF/**"/>       </fileset>       <webinf dir="${war.src}/WEB-INF" includes="**" />    </war>  </target>  <!-- :::::::::::::::::::::: STATIC CONTENT TARBALL :::::::::::::::::: -->    <!-- Callers must pass  ${srcwar} and ${desttar}, ${static.user}, ${static.group}       and can override ${static.mode} -->  <target name="static" depends="unwar"   description="Builds static content tar file for Apache/IIS.">    <fail unless="desttar">You need to supply the property "desttar"!</fail>    <fail unless="static.user">You need to supply the property "static.user"!</fail>    <fail unless="static.group">You need to supply the property "static.group"!</fail>    <property name="static.mode"  value="550" />    <tar destfile="${desttar}" longfile="fail" compression="gzip">      <tarfileset dir="${war.src}" defaultexcludes="yes"        username="${static.user}" group="${static.group}" mode="${static.mode}">        <include name="**/*.css" />        <include name="**/*.gif" />        <include name="**/*.htm" />        <include name="**/*.html" />        <include name="**/*.jpg" />        <include name="**/*.js" />        <include name="**/*.png" />      </tarfileset>    </tar>  </target>  <!-- :::::::::::::::::::::::: DEPLOY :::::::::::::::::::::::: -->   <!-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->       <target name="deploy-environment-init">    <fail unless="build"        message="You need to set build first!"/>    <fail unless="appname"      message="You need to set appname first!"/>    <echo message="Creating deployment script." />    <property name="deploy.script" value="${build}/${appname}-deploy-script.sh" />    <delete file="${deploy.script}" />    <echo file="${deploy.script}">echo "Unpacking files."${line.separator}</echo>    <echo message="Creating deployment script ${deploy.script}" />  </target>    <target name="deploy-environment" depends="deploy-environment-init,deploy-src1,deploy-src2,deploy-src3,deploy-src4,deploy-src5,deploy-script-exec">    <!-- Note that setting ${tar.config} is the responsibility of the caller.         Properties ${remote.ip}, ${remote.user} should be set if the target is remote. -->    <echo message="Deploying distribution package." />  </target>  <!-- :::::::::::::::::: LIBRARY FUNCTIONS ::::::::::::::::::: -->   <!-- :::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->   <target name="deploy-src1" if="copy.src1">    <antcall target="deploy-file">      <param name="copy.src"    value="${copy.src1}" />      <param name="copy.dest"   value="${copy.dest1}" />      <param name="copy.type"   value="${copy.type1}" />    </antcall>  </target>    <target name="deploy-src2" if="copy.src2">    <antcall target="deploy-file">      <param name="copy.src"    value="${copy.src2}" />      <param name="copy.dest"   value="${copy.dest2}" />      <param name="copy.type"   value="${copy.type2}" />    </antcall>  </target>  <target name="deploy-src3" if="copy.src3">    <antcall target="deploy-file">      <param name="copy.src"    value="${copy.src3}" />      <param name="copy.dest"   value="${copy.dest3}" />      <param name="copy.type"   value="${copy.type3}" />    </antcall>  </target>  <target name="deploy-src4" if="copy.src4">    <antcall target="deploy-file">      <param name="copy.src"    value="${copy.src4}" />      <param name="copy.dest"   value="${copy.dest4}" />      <param name="copy.type"   value="${copy.type4}" />    </antcall>  </target>  <target name="deploy-src5" if="copy.src5">    <antcall target="deploy-file">      <param name="copy.src"    value="${copy.src5}" />      <param name="copy.dest"   value="${copy.dest5}" />      <param name="copy.type"   value="${copy.type5}" />    </antcall>  </target>  <target name="deploy-file" depends="deploy-file-init,deploy-file-if-local,deploy-file-if-remote,deploy-script-tar,deploy-script-copy"/>  <target name="deploy-file-init">    <fail unless="copy.src"  message="You need to set copy.src first!"/>    <fail unless="copy.dest" message="You need to set copy.dest first!"/>    <condition property="isTarFile" value="true">      <contains string="${copy.src}" substring=".tar.gz" casesensitive="true" />    </condition>      </target>    <target name="deploy-file-if-local" unless="remote.ip">    <!-- Note that setting ${copy.src} is the responsibility of the caller -->    <property name="deploy.fullpath" value="${copy.src}" />  </target>    <target name="deploy-file-if-remote" if="remote.ip">    <!-- Note that setting ${copy.src}, ${copy.dest}, ${remote.user}, ${remote.ip} is the responsibility of the caller -->    <fail unless="remote.user" message="You need to set remote.user first!"/>    <fail unless="remote.ip"   message="You need to set remote.ip first!"/>    <basename property="deploy.file" file="${copy.src}"/>    <property name="deploy.fullpath" value="/tmp/${deploy.file}" />    <echo message="==== Copying ${copy.src} to ${remote.user}@${remote.ip}:${deploy.fullpath} ====" />    <exec executable="scp" failonerror="true">      <arg value="${copy.src}" />      <arg value="${remote.user}@${remote.ip}:${deploy.fullpath}" />    </exec>  </target>    <target name="deploy-script-tar" if="isTarFile">    <!-- Don't call this target directly. All properties should have been previously set and verified -->    <echo file="${deploy.script}" append="true">echo "${line.separator}=== Unpacking ${deploy.fullpath} to ${copy.dest} ==="${line.separator}</echo>    <echo file="${deploy.script}" append="true">sudo tar -p --same-owner -C ${copy.dest} -xzvf ${deploy.fullpath}${line.separator}</echo>  </target>  <target name="deploy-script-copy" unless="isTarFile">    <!-- Don't call this target directly. All properties should have been previously set and verified -->    <echo file="${deploy.script}" append="true">echo "${line.separator}=== Copying ${deploy.fullpath} to ${copy.dest} ==="${line.separator}</echo>    <echo file="${deploy.script}" append="true">cp ${deploy.fullpath} ${copy.dest}${line.separator}</echo>  </target>  <target name="deploy-script-exec" if="deploy.script" depends="deploy-script-exec-if-local,deploy-script-exec-if-remote"/>   <target name="deploy-script-exec-if-local" unless="remote.ip">    <basename property="deploy.file" file="${deploy.script}"/>    <echo message="To install the distribution package, execute ${deploy.script}" />     <echo message="==== It looks like everything deployed nicely! Cool. ====" />  </target>    <target name="deploy-script-exec-if-remote" if="remote.ip">    <!-- Note that setting ${remote.user}, ${remote.ip} is the responsibility of the caller -->    <fail unless="remote.user" message="You need to set remote.user first!"/>    <fail unless="remote.ip"   message="You need to set remote.ip first!"/>    <echo message="==== Deploying ${deploy.script}...====" />    <basename property="deploy.file" file="${deploy.script}"/>    <property name="deploy.fullpath" value="/tmp/${deploy.file}" />    <exec executable="scp" failonerror="true">      <arg value="${deploy.script}" />      <arg value="${remote.user}@${remote.ip}:${deploy.fullpath}" />    </exec>    <echo message="==== Executing ${deploy.fullpath} on ${remote.ip} as ${remote.user} ====" /><!--    <exec executable="ssh" failonerror="true">      <arg value="${remote.user}@${remote.ip}" />      <arg value="sudo sh ${deploy.fullpath}" />    </exec>-->    <echo message="==== It looks like everything deployed nicely! Cool. ====" />  </target></project>