Java/Ant/JavaDoc Document
Содержание
Ant Javadoc setting
<source lang="java">
<?xml version="1.0" encoding="UTF-8"?>
<project name="actions" default="default" basedir=".">
<description>Builds, tests, and runs the project Actions.</description> <import file="nbproject/build-impl.xml"/> <import file="nbproject/profiler-build-impl.xml"/> <target name="-post-compile-test"> <copy file="test/actions/ActionsXML1.xml" todir="build/classes/test"/> <copy file="test/actions/Bundle1.properties" todir="build/classes/test"/> </target> <target name="-post-compile-test-single" depends="-post-compile-test"/> <target name="cleanjavadoc" description="Delete javadoc files from the web site area"> <delete failonerror="false"> <fileset dir="www/javadoc" includes="**/*.html"/> </delete> </target> <target name="javadoc"> <mkdir dir="dist/javadoc"/> <property file="${basedir}/nbproject/project.properties"/> <property file="${basedir}/nbproject/private/private.properties"/> <javadoc overview="${basedir}/doc/api/overview.html" destdir="dist/javadoc" source="1.5" notree="${javadoc.notree}" use="${javadoc.use}" nonavbar="${javadoc.nonavbar}" noindex="${javadoc.noindex}" splitindex="${javadoc.splitindex}" author="${javadoc.author}" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}" private="${javadoc.private}" failonerror="true" stylesheetfile="doc/api/stylesheet.css" > <classpath> <path path="${javac.classpath}"/> </classpath> <packageset dir="src" defaultexcludes="yes"> <include name="actions/**" /> <exclude name="actions/ui/**" /> <exclude name="actions/borrowed/**"/> </packageset> </javadoc> <copy file="doc/api/actions.dtd" tofile="dist/javadoc/actions.dtd"/> <copy file="doc/api/actionsDoc.html" tofile="dist/javadoc/actionsDoc.html"/> </target> <target name="-post-jar"> <echo message="Copying jar to JNN dev dir"/> <delete failonerror="false" file="../jnn_new/jnn/lib/Actions.jar"/> <delete failonerror="false" file="../jnn_new/jnn/jnn.app/Contents/Resources/Java/lib/Actions.jar"/> <copy failonerror="true" file="dist/Actions.jar" todir="../jnn_new/jnn/lib/"/> <copy failonerror="true" file="dist/Actions.jar" todir="../jnn_new/jnn/jnn.app/Contents/Resources/Java/lib/"/> </target> <target name="release" depends="jar,cleanjavadoc,javadoc" description="Prepare a new release"> <copy file="dist/Actions.jar" todir="www"/> <zip destfile="www/ActionsAPI.zip" basedir="dist/javadoc" update="false" whenempty="fail" compress="true"/> <mkdir dir="www/javadoc"/> <copy todir="www/javadoc"> <fileset dir="dist/javadoc" includes="**"/> </copy> </target>
</project>
</source>
Assemble the documentation
<source lang="java">
<?xml version="1.0"?> <project name="Example Application Build" default="build-both" basedir=".">
<property file="build.properties"/> <property name="cvsroot" value=":pserver:anoncvs@cvs.apache.org:/home/cvspublic" /> <property name="mysql.cvsroot" value=":pserver:anonymous@cvs.sourceforge.net:/cvsroot/mmmysql" /> <path id="build.classpath"> <pathelement location="${servlet24.jar}"/> <pathelement location="${jsp20.jar}"/> <pathelement location="${mysql.jar}"/> <pathelement path="${appName.jar}"/> </path> <fileset id="javadoc" dir="${src}"> <exclude name="*/conf/**"/> <exclude name="*/docs/*"/> <include name="shared/**"/> <include name="stand-alone/**"/> <include name="web/java/**"/> </fileset> <property name="docs.all.dir" value="${build}"/> <patternset id="docs.all"> <include name="docs/**"/> </patternset> <property name="docs.misc.dir" value="${src}/shared/docs"/> <patternset id="docs.misc"> <include name="README"/> <include name="LICENSE"/> </patternset> <property name="src.files.dir" value="."/> <patternset id="src.files"> <include name="${src}/**"/> <include name="build.*"/> </patternset> <patternset id="bin.jar"> <include name="*.jar"/> </patternset> <patternset id="bin.war"> <include name="*.war"/> </patternset> <target name="dir" description="Create the working directories"> <echo message="Creating the working directories"/> <mkdir dir="${build.stand-alone.root}"/> <mkdir dir="${build.web.classes}"/> <mkdir dir="${dist}"/> <mkdir dir="${lib}"/> </target> <target name="checkout-jstl" depends="dir" description="Update or check out required sources from CVS for the JSTL"> <echo message="Checking out the required JSTL sources from CVS"/> <cvs cvsroot="${cvsroot}" quiet="true" command="checkout -P ${jstl.build}" dest="${build}" compression="true" /> </target> <target name="checkout-mysql-connector" depends="dir" description="Update or check out required sources from CVS for the MySQL connector"> <echo message="Checking out the required sources from CVS for the MySQL connector" /> <cvs cvsroot="${mysql.cvsroot}" quiet="true" command="checkout" package="${mysql.build}" dest="${build}" compression="true" /> </target> <target name="build-jstl" depends="checkout-jstl" description="Build the JSTL from source"> <echo message="Building the JSTL from source"/> <ant antfile="build.xml" dir="${build}/${jstl.build}"/> <copy todir="${lib}"> <fileset dir="${build}/${jstl.build}/${build}/lib"> <include name="*.jar"/> </fileset> </copy> </target> <target name="build-mysql-connector" depends="checkout-mysql-connector" description="Build the MySQL connector from source"> <echo message="Building the MySQL connector from source"/> <mkdir dir="${build}/dist-mysql-jdbc"/> <ant antfile="build.xml" dir="${build}/${mysql.build}"/> <copy tofile="${mysql.jar}"> <fileset dir="${build}/build-mysql-jdbc"> <include name="mysql-connector*/*.jar"/> </fileset> </copy> </target> <target name="compile-stand-alone" depends="dir" description="Compile stand-alone application"> <echo message="Compiling the stand-alone application"/> <javac srcdir="${src.shared.java}" destdir="${build.stand-alone.root}"/> <javac srcdir="${src.stand-alone.java}" destdir="${build.stand-alone.root}"/> </target>
<target name="stand-alone-complete" depends="build-mysql-connector, package-stand-alone" description="Compile stand-alone application, using CVS version of the MySQL connector"> <echo message="Compiling stand-alone application, using CVS versions of the MySQL connector"/> </target> <target name="package-stand-alone" depends="compile-stand-alone" description="Package the stand-alone application"> <echo message="Creating the stand-alone JAR file"/> <copy file="${database.properties}" todir="${build.stand-alone.root}"/> <jar destfile="${appName.jar}" basedir="${build.stand-alone.root}"/> </target> <target name="compile-web" depends="dir" description="Compile web application"> <echo message="Compiling the web application"/> <javac destdir="${build.web.classes}"> <src path="${src.shared.java}"/> </javac> <javac srcdir="${src.web.java}" destdir="${build.web.classes}"> <classpath refid="build.classpath"/> </javac> </target>
<target name="web-complete" depends="build-mysql-connector, build-jstl, package-web" description="Compile web application, using CVS versions of the MySQL connector and the JSTL"> <echo message="Compiling web application, using CVS versions of the MySQL connector and the JSTL"/> </target> <target name="copy-web" depends="compile-web" description="Copy the web files"> <echo message="Copying the web pages and configuration files"/> <copy todir="${build.web.root}"> <fileset dir="${src.web.pages}"/> </copy> <copy todir="${build.web.tags}"> <fileset dir="${src.web.tags}"/> </copy> <copy todir="${build.web.web-inf}"> <fileset dir="${src.web.conf}"> <include name="*.tld"/> </fileset> </copy> <copy todir="${build.web.lib}"> <fileset dir="${lib}"/> </copy> <copy file="${database.properties}" todir="${build.web.classes}"/> </target>
<target name="package-web" depends="compile-web" description="Build the WAR file in one step"> <echo message="Building the WAR file in one step"/> <war destfile="${appName.war}" basedir="${src.web.pages}" webxml="${src.web.conf}/web.xml"> <lib dir="${lib}"/> <classes dir="${build.web.root}"/> <zipfileset dir="${src.web.tags}" prefix="WEB-INF/tags"/> <zipfileset file="${database.properties}" prefix="WEB-INF/classes"/> <zipfileset dir="${src.web.conf}" prefix="WEB-INF"> <include name="*.tld"/> </zipfileset> </war> </target>
<target name="build-both" depends="package-stand-alone, package-web" description="Compile both applications, without CVS versions of the MySQL connector and the JSTL"> <echo message="Compiled both applications, without CVS versions of the MySQL connector and the JSTL"/> </target> <target name="build-all" depends="stand-alone-complete, web-complete" description="Compile both applications, using CVS versions of the MySQL connector and the JSTL"> <echo message="Compiled both applications, using CVS versions of the MySQL connector and the JSTL"/> </target>
<target name="download-servlet-jar" depends="dir" description="Download the servlet JAR"> <echo message="Downloading the servlet JAR"/> <get src="http://www.ibiblio.org/maven/servletapi/jars/servletapi-2.4.jar" dest="${servlet24.jar}" verbose="true"/> </target> <target name="download-jsp-jar" depends="dir" description="Download the JSP JAR"> <echo message="Downloading the JSP JAR"/> <get src="http://www.ibiblio.org/maven/jspapi/jars/jsp-api-2.0.jar" dest="${jsp20.jar}" verbose="true"/> </target> <target name="check-docs" description="Check that the documentation is up to date"> <echo message="Checking that the documentation is up to date"/> <condition property="docs.notRequired"> <and> <uptodate targetfile="${dist}/${appName}-${package.docs}.zip"> <srcfiles dir="${src}" includes="**"/> </uptodate> <uptodate targetfile="${dist}/${appName}-${package.docs}.tar.gz"> <srcfiles dir="${src}" includes="**"/> </uptodate> </and> </condition> </target> <target name="javadocs" depends="dir,check-docs" description="Generate Javadocs for the application" unless="docs.notRequired"> <echo message="Generating Javadocs for the application"/> <javadoc destdir="${docs}/api" windowtitle="${javadoc.windowtitle}"> <fileset refid="javadoc"/> <doctitle> ${javadoc.doctitle} </doctitle> <classpath refid="build.classpath"/> <link href="http://java.sun.ru/j2se/${javadoc.j2se.version}/docs/api"/> <link href="http://java.sun.ru/j2ee/${javadoc.j2ee.version}/docs/api"/> </javadoc> </target> <target name="javadocs-offline" depends="dir,check-docs" description="Generate Javadocs for the application, using offline package-list files" unless="docs.notRequired"> <echo message="Generating Javadocs for the application, using offline package-list files"/> <javadoc destdir="${docs}/api" windowtitle="${javadoc.windowtitle}"> <fileset refid="javadoc"/> <doctitle> ${javadoc.doctitle} </doctitle> <classpath refid="build.classpath"/>
<link href="${javadoc.j2se.offline}" resolveLink="true"/> <link href="${javadoc.j2ee.offline}" resolveLink="true"/> </javadoc> </target> <target name="docs" depends="javadocs" description="Assemble the documentation" unless="docs.notRequired"> <echo message="Assembling the documentation"/> <copy todir="${docs}"> <fileset dir="${src.shared.docs}"> <include name="*.html"/> </fileset> </copy> <copy todir="${docs}/stand-alone"> <fileset dir="${src.stand-alone.docs}"> <include name="*.html"/> </fileset> </copy> <copy todir="${docs}/web"> <fileset dir="${src.web.docs}"> <include name="*.html"/> </fileset> </copy> </target> <target name="zip-docs" depends="docs" description="Zip the documentation"> <echo message="Zipping the documentation"/> <zip destfile="${dist}/${appName}-${package.docs}.zip"> <fileset dir="${docs.all.dir}"> <patternset refid="docs.all"/> </fileset> <fileset dir="${docs.misc.dir}"> <patternset refid="docs.misc"/> </fileset> </zip> <checksum file="${dist}/${appName}-${package.docs}.zip" forceOverwrite="true"/> <checksum file="${dist}/${appName}-${package.docs}.zip" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="zip-src" depends="zip-docs" description="Zip the source and documentation together"> <echo message="Zipping the source and documentation together"/> <zip destfile="${dist}/${appName}-src.zip"> <zipfileset src="${dist}/${appName}-${package.docs}.zip"/> <fileset dir="${src.files.dir}"> <patternset refid="src.files"/> </fileset> </zip> <checksum file="${dist}/${appName}-src.zip" forceOverwrite="true"/> <checksum file="${dist}/${appName}-src.zip" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="zip-bin-stand-alone" depends="package-stand-alone,zip-docs" description="Zip the binary stand-alone distribution with the documentation"> <echo message="Zipping the binary stand-alone distribution with the documentation"/> <zip destfile="${dist}/${appName}-${package.stand-alone}-bin.zip"> <zipfileset src="${dist}/${appName}-${package.docs}.zip"/> <zipfileset dir="${dist}" prefix="lib"> <patternset refid="bin.jar"/> </zipfileset> <fileset dir="."> <include name="${mysql.jar}"/> </fileset> </zip> <checksum file="${dist}/${appName}-${package.stand-alone}-bin.zip" forceOverwrite="true"/> <checksum file="${dist}/${appName}-${package.stand-alone}-bin.zip" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="zip-bin-web" depends="package-web,zip-docs" description="Zip the binary web distribution with the documentation"> <echo message="Zipping the binary web distribution with the documentation"/> <zip destfile="${dist}/${appName}-${package.web}-bin.zip"> <zipfileset src="${dist}/${appName}-${package.docs}.zip"/> <fileset dir="${dist}"> <patternset refid="bin.war"/> </fileset> </zip> <checksum file="${dist}/${appName}-${package.web}-bin.zip" forceOverwrite="true"/> <checksum file="${dist}/${appName}-${package.web}-bin.zip" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="zip-bin" depends="zip-bin-stand-alone,zip-bin-web" description="Zip the binary distribution with the documentation"> <echo message="Zipping the binary distribution with the documentation"/> <zip destfile="${dist}/${appName}-bin.zip" duplicate="preserve" update="true"> <zipgroupfileset dir="${dist}" includes="*.zip"/> </zip> <checksum file="${dist}/${appName}-bin.zip" forceOverwrite="true"/> <checksum file="${dist}/${appName}-bin.zip" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="zip-all" depends="zip-src,zip-bin" description="Zip the binary and source distributions"> <echo message="Zipped the binary and source distributions"/> </target> <target name="tar-docs" depends="docs" description="Tar the documentation"> <echo message="Tarring the documentation"/> <tar destfile="${dist}/${appName}-${package.docs}.tar.gz" compression="gzip"> <tarfileset dir="${docs.all.dir}"> <patternset refid="docs.all"/> </tarfileset> <tarfileset dir="${docs.misc.dir}"> <patternset refid="docs.misc"/> </tarfileset> </tar> <checksum file="${dist}/${appName}-${package.docs}.tar.gz" forceOverwrite="true"/> <checksum file="${dist}/${appName}-${package.docs}.tar.gz" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="tar-src" depends="tar-docs" description="Tar the documentation"> <echo message="Tarring the documentation"/> <tar destfile="${dist}/${appName}-src.tar.gz" compression="gzip"> <tarfileset dir="${docs.all.dir}"> <patternset refid="docs.all"/> </tarfileset> <tarfileset dir="${docs.misc.dir}"> <patternset refid="docs.misc"/> </tarfileset> <tarfileset dir="${src.files.dir}"> <patternset refid="src.files"/> </tarfileset> </tar> <checksum file="${dist}/${appName}-src.tar.gz" forceOverwrite="true"/> <checksum file="${dist}/${appName}-src.tar.gz" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="tar-bin-stand-alone" depends="package-stand-alone,tar-docs" description="Tar the binary stand-alone distribution with the documentation"> <echo message="Tarring the binary stand-alone distribution with the documentation"/> <tar destfile="${dist}/${appName}-${package.stand-alone}-bin.tar.gz" compression="gzip"> <tarfileset dir="${docs.all.dir}"> <patternset refid="docs.all"/> </tarfileset> <tarfileset dir="${docs.misc.dir}"> <patternset refid="docs.misc"/> </tarfileset> <tarfileset dir="${dist}" prefix="lib"> <patternset refid="bin.jar"/> </tarfileset> <tarfileset dir="."> <include name="${mysql.jar}"/> </tarfileset> </tar> <checksum file="${dist}/${appName}-${package.stand-alone}-bin.tar.gz" forceOverwrite="true"/> <checksum file="${dist}/${appName}-${package.stand-alone}-bin.tar.gz" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="tar-bin-web" depends="package-web,tar-docs" description="Tar the binary web distribution with the documentation"> <echo message="Tarring the binary web distribution with the documentation"/> <tar destfile="${dist}/${appName}-${package.web}-bin.tar.gz" compression="gzip"> <tarfileset dir="${docs.all.dir}"> <patternset refid="docs.all"/> </tarfileset> <tarfileset dir="${docs.misc.dir}"> <patternset refid="docs.misc"/> </tarfileset> <tarfileset dir="${dist}"> <patternset refid="bin.war"/> </tarfileset> </tar> <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" forceOverwrite="true"/> <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="tar-bin" depends="tar-bin-stand-alone,tar-bin-web" description="Tar the binary distribution with the documentation"> <echo message="Tarring the binary distribution with the documentation"/> <tar destfile="${dist}/${appName}-bin.tar.gz" compression="gzip"> <tarfileset dir="${docs.all.dir}"> <patternset refid="docs.all"/> </tarfileset> <tarfileset dir="${docs.misc.dir}"> <patternset refid="docs.misc"/> </tarfileset> <tarfileset dir="${src.files.dir}"> <patternset refid="src.files"/> </tarfileset> <tarfileset dir="${dist}" prefix="lib"> <patternset refid="bin.jar"/> </tarfileset> <tarfileset dir="."> <include name="${mysql.jar}"/> </tarfileset> <tarfileset dir="${dist}"> <patternset refid="bin.war"/> </tarfileset> </tar> <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true"/> <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="tar-bin-web-new" depends="package-web,tar-docs,zip-bin-web" description="Tar the binary web distribution with the documentation"> <echo message="Tarring the binary web distribution with the documentation"/> <unzip src="${dist}/${appName}-${package.web}-bin.zip" dest="${tmp}/web"/> <tar destfile="${dist}/${appName}-${package.web}-bin.tar.gz" compression="gzip"> <tarfileset dir="${tmp}/web"/> </tar> <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" forceOverwrite="true"/> <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="tar-bin-new" depends="zip-bin,tar-bin-stand-alone,tar-bin-web-new" description="Tar the binary distribution with the documentation"> <echo message="Tarring the binary distribution with the documentation"/> <delete failonerror="false" includeemptydirs="true"> <fileset dir="${tmp}" includes="**"/> </delete> <unzip src="${dist}/${appName}-bin.zip" dest="${tmp}"/> <tar destfile="${dist}/${appName}-bin.tar.gz" compression="gzip"> <tarfileset dir="${tmp}"/> </tar> <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true"/> <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="tar-all" depends="tar-src,tar-bin" description="Tar the binary and source distributions"> <echo message="Tarred the binary and source distributions"/> </target>
<target name="ftp-docs" depends="zip-docs,tar-docs" description="Place the documentation on FTP"> <echo message="Placing the documentation on FTP"/> <ftp server="${ftp.server}" userid="${ftp.user}" password="${ftp.password}" remotedir="${ftp.src.dir}" action="send" newer="true" timediffauto="true"> <fileset dir="${dist}"> <include name="${appName}-${package.docs}.*"/> </fileset> </ftp> </target> <target name="ftp-src" depends="zip-src,tar-src" description="Place the source code on FTP"> <echo message="Placing the source code on FTP"/> <ftp server="${ftp.server}" userid="${ftp.user}" password="${ftp.password}" remotedir="${ftp.src.dir}" action="send" newer="true" timediffauto="true"> <fileset dir="${dist}"> <include name="${appName}-src.*"/> </fileset> </ftp> </target> <target name="ftp-bin" depends="zip-bin,tar-bin" description="Place the binaries on FTP"> <echo message="Placing the binaries on FTP"/> <ftp server="${ftp.server}" userid="${ftp.user}" password="${ftp.password}" remotedir="${ftp.bin.dir}" action="send" newer="true" timediffauto="true"> <fileset dir="${dist}"> <include name="${appName}*bin*"/> </fileset> </ftp> </target> <target name="ftp" description="Place everything on FTP"> <echo message="Placing everything on FTP"/> <antcall target="ftp-docs"/> <antcall target="ftp-src"/> <antcall target="ftp-bin"/> </target>
<target name="email-docs" depends="zip-docs,tar-docs" description="E-mailing the documentation"> <echo message="E-mailing the documentation"/> <mail from="${mail.from}" tolist="${mail.tolist}" mailhost="${mail.mailhost}" user="${mail.user}" password="${mail.password}" subject="${mail.subject}"> <message> ${mail.message.docs} </message> <fileset dir="${dist}"> <include name="${appName}-${package.docs}.*"/> </fileset> </mail> </target> <target name="deploy-copy-files" depends="copy-web" description="Deploy the application by copying it to Tomcat"> <echo message="Copying the expanded web application to CATALINA_HOME"/> <property environment="env"/> <copy todir="${build.web.web-inf}" file="${src.web.conf}/web.xml"/> <copy todir="${env.CATALINA_HOME}/webapps/${appName}"> <fileset dir="${build.web.root}"/> </copy> </target> <target name="deploy-copy-war" depends="package-web" description="Deploy the WAR by copying it to Tomcat"> <echo message="Copying the WAR to CATALINA_HOME"/> <property environment="env"/> <copy file="${appName.war}" todir="${env.CATALINA_HOME}/webapps"/> </target> <target name="deploy-context" depends="copy-web" description="Deploy the web application using a context XML file"> <echo message="Deploying the web application using a context XML file"/> <property environment="env"/> <copy todir="${build.web.web-inf}" file="${src.web.conf}/web.xml"/> <copy todir="${env.CATALINA_HOME}/conf/Catalina/localhost" file="${src.web.conf}/${appName}.xml"/> </target> <taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask"/> <target name="deploy" depends="package-web" description="Hot deploy the application"> <echo message="Deploying the WAR to Tomcat"/> <deploy url="${manager.url}" username="${manager.user}" password="${manager.password}" path="/${appName}" war="file:${appName.war}" update="true"/> </target> <taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask"/> <target name="undeploy" description="Undeploy the application"> <echo message="Undeploying the WAR"/> <undeploy url="${manager.url}" username="${manager.user}" password="${manager.password}" path="/${appName}"/> </target> <target name="clean" description="Clean up the working directories"> <echo message="Cleaning up"/> <delete dir="${build}"/> </target>
</project>
</source>
Checking that the documentation is up to date
<source lang="java">
<?xml version="1.0"?> <project name="Example Application Build" default="build-both" basedir=".">
<property file="build.properties"/> <property name="cvsroot" value=":pserver:anoncvs@cvs.apache.org:/home/cvspublic" /> <property name="mysql.cvsroot" value=":pserver:anonymous@cvs.sourceforge.net:/cvsroot/mmmysql" /> <path id="build.classpath"> <pathelement location="${servlet24.jar}"/> <pathelement location="${jsp20.jar}"/> <pathelement location="${mysql.jar}"/> <pathelement path="${appName.jar}"/> </path> <fileset id="javadoc" dir="${src}"> <exclude name="*/conf/**"/> <exclude name="*/docs/*"/> <include name="shared/**"/> <include name="stand-alone/**"/> <include name="web/java/**"/> </fileset> <property name="docs.all.dir" value="${build}"/> <patternset id="docs.all"> <include name="docs/**"/> </patternset> <property name="docs.misc.dir" value="${src}/shared/docs"/> <patternset id="docs.misc"> <include name="README"/> <include name="LICENSE"/> </patternset> <property name="src.files.dir" value="."/> <patternset id="src.files"> <include name="${src}/**"/> <include name="build.*"/> </patternset> <patternset id="bin.jar"> <include name="*.jar"/> </patternset> <patternset id="bin.war"> <include name="*.war"/> </patternset> <target name="dir" description="Create the working directories"> <echo message="Creating the working directories"/> <mkdir dir="${build.stand-alone.root}"/> <mkdir dir="${build.web.classes}"/> <mkdir dir="${dist}"/> <mkdir dir="${lib}"/> </target> <target name="checkout-jstl" depends="dir" description="Update or check out required sources from CVS for the JSTL"> <echo message="Checking out the required JSTL sources from CVS"/> <cvs cvsroot="${cvsroot}" quiet="true" command="checkout -P ${jstl.build}" dest="${build}" compression="true" /> </target> <target name="checkout-mysql-connector" depends="dir" description="Update or check out required sources from CVS for the MySQL connector"> <echo message="Checking out the required sources from CVS for the MySQL connector" /> <cvs cvsroot="${mysql.cvsroot}" quiet="true" command="checkout" package="${mysql.build}" dest="${build}" compression="true" /> </target> <target name="build-jstl" depends="checkout-jstl" description="Build the JSTL from source"> <echo message="Building the JSTL from source"/> <ant antfile="build.xml" dir="${build}/${jstl.build}"/> <copy todir="${lib}"> <fileset dir="${build}/${jstl.build}/${build}/lib"> <include name="*.jar"/> </fileset> </copy> </target> <target name="build-mysql-connector" depends="checkout-mysql-connector" description="Build the MySQL connector from source"> <echo message="Building the MySQL connector from source"/> <mkdir dir="${build}/dist-mysql-jdbc"/> <ant antfile="build.xml" dir="${build}/${mysql.build}"/> <copy tofile="${mysql.jar}"> <fileset dir="${build}/build-mysql-jdbc"> <include name="mysql-connector*/*.jar"/> </fileset> </copy> </target> <target name="compile-stand-alone" depends="dir" description="Compile stand-alone application"> <echo message="Compiling the stand-alone application"/> <javac srcdir="${src.shared.java}" destdir="${build.stand-alone.root}"/> <javac srcdir="${src.stand-alone.java}" destdir="${build.stand-alone.root}"/> </target>
<target name="stand-alone-complete" depends="build-mysql-connector, package-stand-alone" description="Compile stand-alone application, using CVS version of the MySQL connector"> <echo message="Compiling stand-alone application, using CVS versions of the MySQL connector"/> </target> <target name="package-stand-alone" depends="compile-stand-alone" description="Package the stand-alone application"> <echo message="Creating the stand-alone JAR file"/> <copy file="${database.properties}" todir="${build.stand-alone.root}"/> <jar destfile="${appName.jar}" basedir="${build.stand-alone.root}"/> </target> <target name="compile-web" depends="dir" description="Compile web application"> <echo message="Compiling the web application"/> <javac destdir="${build.web.classes}"> <src path="${src.shared.java}"/> </javac> <javac srcdir="${src.web.java}" destdir="${build.web.classes}"> <classpath refid="build.classpath"/> </javac> </target>
<target name="web-complete" depends="build-mysql-connector, build-jstl, package-web" description="Compile web application, using CVS versions of the MySQL connector and the JSTL"> <echo message="Compiling web application, using CVS versions of the MySQL connector and the JSTL"/> </target> <target name="copy-web" depends="compile-web" description="Copy the web files"> <echo message="Copying the web pages and configuration files"/> <copy todir="${build.web.root}"> <fileset dir="${src.web.pages}"/> </copy> <copy todir="${build.web.tags}"> <fileset dir="${src.web.tags}"/> </copy> <copy todir="${build.web.web-inf}"> <fileset dir="${src.web.conf}"> <include name="*.tld"/> </fileset> </copy> <copy todir="${build.web.lib}"> <fileset dir="${lib}"/> </copy> <copy file="${database.properties}" todir="${build.web.classes}"/> </target>
<target name="package-web" depends="compile-web" description="Build the WAR file in one step"> <echo message="Building the WAR file in one step"/> <war destfile="${appName.war}" basedir="${src.web.pages}" webxml="${src.web.conf}/web.xml"> <lib dir="${lib}"/> <classes dir="${build.web.root}"/> <zipfileset dir="${src.web.tags}" prefix="WEB-INF/tags"/> <zipfileset file="${database.properties}" prefix="WEB-INF/classes"/> <zipfileset dir="${src.web.conf}" prefix="WEB-INF"> <include name="*.tld"/> </zipfileset> </war> </target>
<target name="build-both" depends="package-stand-alone, package-web" description="Compile both applications, without CVS versions of the MySQL connector and the JSTL"> <echo message="Compiled both applications, without CVS versions of the MySQL connector and the JSTL"/> </target> <target name="build-all" depends="stand-alone-complete, web-complete" description="Compile both applications, using CVS versions of the MySQL connector and the JSTL"> <echo message="Compiled both applications, using CVS versions of the MySQL connector and the JSTL"/> </target>
<target name="download-servlet-jar" depends="dir" description="Download the servlet JAR"> <echo message="Downloading the servlet JAR"/> <get src="http://www.ibiblio.org/maven/servletapi/jars/servletapi-2.4.jar" dest="${servlet24.jar}" verbose="true"/> </target> <target name="download-jsp-jar" depends="dir" description="Download the JSP JAR"> <echo message="Downloading the JSP JAR"/> <get src="http://www.ibiblio.org/maven/jspapi/jars/jsp-api-2.0.jar" dest="${jsp20.jar}" verbose="true"/> </target> <target name="check-docs" description="Check that the documentation is up to date"> <echo message="Checking that the documentation is up to date"/> <condition property="docs.notRequired"> <and> <uptodate targetfile="${dist}/${appName}-${package.docs}.zip"> <srcfiles dir="${src}" includes="**"/> </uptodate> <uptodate targetfile="${dist}/${appName}-${package.docs}.tar.gz"> <srcfiles dir="${src}" includes="**"/> </uptodate> </and> </condition> </target> <target name="javadocs" depends="dir,check-docs" description="Generate Javadocs for the application" unless="docs.notRequired"> <echo message="Generating Javadocs for the application"/> <javadoc destdir="${docs}/api" windowtitle="${javadoc.windowtitle}"> <fileset refid="javadoc"/> <doctitle> ${javadoc.doctitle} </doctitle> <classpath refid="build.classpath"/> <link href="http://java.sun.ru/j2se/${javadoc.j2se.version}/docs/api"/> <link href="http://java.sun.ru/j2ee/${javadoc.j2ee.version}/docs/api"/> </javadoc> </target> <target name="javadocs-offline" depends="dir,check-docs" description="Generate Javadocs for the application, using offline package-list files" unless="docs.notRequired"> <echo message="Generating Javadocs for the application, using offline package-list files"/> <javadoc destdir="${docs}/api" windowtitle="${javadoc.windowtitle}"> <fileset refid="javadoc"/> <doctitle> ${javadoc.doctitle} </doctitle> <classpath refid="build.classpath"/>
<link href="${javadoc.j2se.offline}" resolveLink="true"/> <link href="${javadoc.j2ee.offline}" resolveLink="true"/> </javadoc> </target> <target name="docs" depends="javadocs" description="Assemble the documentation" unless="docs.notRequired"> <echo message="Assembling the documentation"/> <copy todir="${docs}"> <fileset dir="${src.shared.docs}"> <include name="*.html"/> </fileset> </copy> <copy todir="${docs}/stand-alone"> <fileset dir="${src.stand-alone.docs}"> <include name="*.html"/> </fileset> </copy> <copy todir="${docs}/web"> <fileset dir="${src.web.docs}"> <include name="*.html"/> </fileset> </copy> </target> <target name="zip-docs" depends="docs" description="Zip the documentation"> <echo message="Zipping the documentation"/> <zip destfile="${dist}/${appName}-${package.docs}.zip"> <fileset dir="${docs.all.dir}"> <patternset refid="docs.all"/> </fileset> <fileset dir="${docs.misc.dir}"> <patternset refid="docs.misc"/> </fileset> </zip> <checksum file="${dist}/${appName}-${package.docs}.zip" forceOverwrite="true"/> <checksum file="${dist}/${appName}-${package.docs}.zip" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="zip-src" depends="zip-docs" description="Zip the source and documentation together"> <echo message="Zipping the source and documentation together"/> <zip destfile="${dist}/${appName}-src.zip"> <zipfileset src="${dist}/${appName}-${package.docs}.zip"/> <fileset dir="${src.files.dir}"> <patternset refid="src.files"/> </fileset> </zip> <checksum file="${dist}/${appName}-src.zip" forceOverwrite="true"/> <checksum file="${dist}/${appName}-src.zip" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="zip-bin-stand-alone" depends="package-stand-alone,zip-docs" description="Zip the binary stand-alone distribution with the documentation"> <echo message="Zipping the binary stand-alone distribution with the documentation"/> <zip destfile="${dist}/${appName}-${package.stand-alone}-bin.zip"> <zipfileset src="${dist}/${appName}-${package.docs}.zip"/> <zipfileset dir="${dist}" prefix="lib"> <patternset refid="bin.jar"/> </zipfileset> <fileset dir="."> <include name="${mysql.jar}"/> </fileset> </zip> <checksum file="${dist}/${appName}-${package.stand-alone}-bin.zip" forceOverwrite="true"/> <checksum file="${dist}/${appName}-${package.stand-alone}-bin.zip" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="zip-bin-web" depends="package-web,zip-docs" description="Zip the binary web distribution with the documentation"> <echo message="Zipping the binary web distribution with the documentation"/> <zip destfile="${dist}/${appName}-${package.web}-bin.zip"> <zipfileset src="${dist}/${appName}-${package.docs}.zip"/> <fileset dir="${dist}"> <patternset refid="bin.war"/> </fileset> </zip> <checksum file="${dist}/${appName}-${package.web}-bin.zip" forceOverwrite="true"/> <checksum file="${dist}/${appName}-${package.web}-bin.zip" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="zip-bin" depends="zip-bin-stand-alone,zip-bin-web" description="Zip the binary distribution with the documentation"> <echo message="Zipping the binary distribution with the documentation"/> <zip destfile="${dist}/${appName}-bin.zip" duplicate="preserve" update="true"> <zipgroupfileset dir="${dist}" includes="*.zip"/> </zip> <checksum file="${dist}/${appName}-bin.zip" forceOverwrite="true"/> <checksum file="${dist}/${appName}-bin.zip" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="zip-all" depends="zip-src,zip-bin" description="Zip the binary and source distributions"> <echo message="Zipped the binary and source distributions"/> </target> <target name="tar-docs" depends="docs" description="Tar the documentation"> <echo message="Tarring the documentation"/> <tar destfile="${dist}/${appName}-${package.docs}.tar.gz" compression="gzip"> <tarfileset dir="${docs.all.dir}"> <patternset refid="docs.all"/> </tarfileset> <tarfileset dir="${docs.misc.dir}"> <patternset refid="docs.misc"/> </tarfileset> </tar> <checksum file="${dist}/${appName}-${package.docs}.tar.gz" forceOverwrite="true"/> <checksum file="${dist}/${appName}-${package.docs}.tar.gz" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="tar-src" depends="tar-docs" description="Tar the documentation"> <echo message="Tarring the documentation"/> <tar destfile="${dist}/${appName}-src.tar.gz" compression="gzip"> <tarfileset dir="${docs.all.dir}"> <patternset refid="docs.all"/> </tarfileset> <tarfileset dir="${docs.misc.dir}"> <patternset refid="docs.misc"/> </tarfileset> <tarfileset dir="${src.files.dir}"> <patternset refid="src.files"/> </tarfileset> </tar> <checksum file="${dist}/${appName}-src.tar.gz" forceOverwrite="true"/> <checksum file="${dist}/${appName}-src.tar.gz" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="tar-bin-stand-alone" depends="package-stand-alone,tar-docs" description="Tar the binary stand-alone distribution with the documentation"> <echo message="Tarring the binary stand-alone distribution with the documentation"/> <tar destfile="${dist}/${appName}-${package.stand-alone}-bin.tar.gz" compression="gzip"> <tarfileset dir="${docs.all.dir}"> <patternset refid="docs.all"/> </tarfileset> <tarfileset dir="${docs.misc.dir}"> <patternset refid="docs.misc"/> </tarfileset> <tarfileset dir="${dist}" prefix="lib"> <patternset refid="bin.jar"/> </tarfileset> <tarfileset dir="."> <include name="${mysql.jar}"/> </tarfileset> </tar> <checksum file="${dist}/${appName}-${package.stand-alone}-bin.tar.gz" forceOverwrite="true"/> <checksum file="${dist}/${appName}-${package.stand-alone}-bin.tar.gz" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="tar-bin-web" depends="package-web,tar-docs" description="Tar the binary web distribution with the documentation"> <echo message="Tarring the binary web distribution with the documentation"/> <tar destfile="${dist}/${appName}-${package.web}-bin.tar.gz" compression="gzip"> <tarfileset dir="${docs.all.dir}"> <patternset refid="docs.all"/> </tarfileset> <tarfileset dir="${docs.misc.dir}"> <patternset refid="docs.misc"/> </tarfileset> <tarfileset dir="${dist}"> <patternset refid="bin.war"/> </tarfileset> </tar> <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" forceOverwrite="true"/> <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="tar-bin" depends="tar-bin-stand-alone,tar-bin-web" description="Tar the binary distribution with the documentation"> <echo message="Tarring the binary distribution with the documentation"/> <tar destfile="${dist}/${appName}-bin.tar.gz" compression="gzip"> <tarfileset dir="${docs.all.dir}"> <patternset refid="docs.all"/> </tarfileset> <tarfileset dir="${docs.misc.dir}"> <patternset refid="docs.misc"/> </tarfileset> <tarfileset dir="${src.files.dir}"> <patternset refid="src.files"/> </tarfileset> <tarfileset dir="${dist}" prefix="lib"> <patternset refid="bin.jar"/> </tarfileset> <tarfileset dir="."> <include name="${mysql.jar}"/> </tarfileset> <tarfileset dir="${dist}"> <patternset refid="bin.war"/> </tarfileset> </tar> <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true"/> <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="tar-bin-web-new" depends="package-web,tar-docs,zip-bin-web" description="Tar the binary web distribution with the documentation"> <echo message="Tarring the binary web distribution with the documentation"/> <unzip src="${dist}/${appName}-${package.web}-bin.zip" dest="${tmp}/web"/> <tar destfile="${dist}/${appName}-${package.web}-bin.tar.gz" compression="gzip"> <tarfileset dir="${tmp}/web"/> </tar> <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" forceOverwrite="true"/> <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="tar-bin-new" depends="zip-bin,tar-bin-stand-alone,tar-bin-web-new" description="Tar the binary distribution with the documentation"> <echo message="Tarring the binary distribution with the documentation"/> <delete failonerror="false" includeemptydirs="true"> <fileset dir="${tmp}" includes="**"/> </delete> <unzip src="${dist}/${appName}-bin.zip" dest="${tmp}"/> <tar destfile="${dist}/${appName}-bin.tar.gz" compression="gzip"> <tarfileset dir="${tmp}"/> </tar> <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true"/> <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="tar-all" depends="tar-src,tar-bin" description="Tar the binary and source distributions"> <echo message="Tarred the binary and source distributions"/> </target>
<target name="ftp-docs" depends="zip-docs,tar-docs" description="Place the documentation on FTP"> <echo message="Placing the documentation on FTP"/> <ftp server="${ftp.server}" userid="${ftp.user}" password="${ftp.password}" remotedir="${ftp.src.dir}" action="send" newer="true" timediffauto="true"> <fileset dir="${dist}"> <include name="${appName}-${package.docs}.*"/> </fileset> </ftp> </target> <target name="ftp-src" depends="zip-src,tar-src" description="Place the source code on FTP"> <echo message="Placing the source code on FTP"/> <ftp server="${ftp.server}" userid="${ftp.user}" password="${ftp.password}" remotedir="${ftp.src.dir}" action="send" newer="true" timediffauto="true"> <fileset dir="${dist}"> <include name="${appName}-src.*"/> </fileset> </ftp> </target> <target name="ftp-bin" depends="zip-bin,tar-bin" description="Place the binaries on FTP"> <echo message="Placing the binaries on FTP"/> <ftp server="${ftp.server}" userid="${ftp.user}" password="${ftp.password}" remotedir="${ftp.bin.dir}" action="send" newer="true" timediffauto="true"> <fileset dir="${dist}"> <include name="${appName}*bin*"/> </fileset> </ftp> </target> <target name="ftp" description="Place everything on FTP"> <echo message="Placing everything on FTP"/> <antcall target="ftp-docs"/> <antcall target="ftp-src"/> <antcall target="ftp-bin"/> </target>
<target name="email-docs" depends="zip-docs,tar-docs" description="E-mailing the documentation"> <echo message="E-mailing the documentation"/> <mail from="${mail.from}" tolist="${mail.tolist}" mailhost="${mail.mailhost}" user="${mail.user}" password="${mail.password}" subject="${mail.subject}"> <message> ${mail.message.docs} </message> <fileset dir="${dist}"> <include name="${appName}-${package.docs}.*"/> </fileset> </mail> </target> <target name="deploy-copy-files" depends="copy-web" description="Deploy the application by copying it to Tomcat"> <echo message="Copying the expanded web application to CATALINA_HOME"/> <property environment="env"/> <copy todir="${build.web.web-inf}" file="${src.web.conf}/web.xml"/> <copy todir="${env.CATALINA_HOME}/webapps/${appName}"> <fileset dir="${build.web.root}"/> </copy> </target> <target name="deploy-copy-war" depends="package-web" description="Deploy the WAR by copying it to Tomcat"> <echo message="Copying the WAR to CATALINA_HOME"/> <property environment="env"/> <copy file="${appName.war}" todir="${env.CATALINA_HOME}/webapps"/> </target> <target name="deploy-context" depends="copy-web" description="Deploy the web application using a context XML file"> <echo message="Deploying the web application using a context XML file"/> <property environment="env"/> <copy todir="${build.web.web-inf}" file="${src.web.conf}/web.xml"/> <copy todir="${env.CATALINA_HOME}/conf/Catalina/localhost" file="${src.web.conf}/${appName}.xml"/> </target> <taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask"/> <target name="deploy" depends="package-web" description="Hot deploy the application"> <echo message="Deploying the WAR to Tomcat"/> <deploy url="${manager.url}" username="${manager.user}" password="${manager.password}" path="/${appName}" war="file:${appName.war}" update="true"/> </target> <taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask"/> <target name="undeploy" description="Undeploy the application"> <echo message="Undeploying the WAR"/> <undeploy url="${manager.url}" username="${manager.user}" password="${manager.password}" path="/${appName}"/> </target> <target name="clean" description="Clean up the working directories"> <echo message="Cleaning up"/> <delete dir="${build}"/> </target>
</project>
</source>
Generate Javadoc from Ant
<source lang="java">
<project name="alma" default="main" basedir="." >
<property name="app.name" value="alma" />
<property name="app.package" value="com/memoire" />
<property name="app.version" value="0.36" />
<property name="app.year" value="2001" />
<property name="dir.classes" location="classes" />
<property name="dir.dist" location="dist" />
<property name="dir.javadocs" location="docs" />
<property name="dir.project" location="." />
<property name="dir.src" location="." />
<property name="dir.package" value="com/memoire" />
<property name="debug" value="on"/>
<property name="packages" value="com.memoire.*"/>
<target name="showsystem" >
<showsystem />
</target>
<target name="prepare">
<tstamp /> <mkdir dir="${dir.classes}" /> <mkdir dir="${dir.dist}" />
</target>
<target name="compile" depends="prepare">
<javac srcdir="${dir.src}" destdir="${dir.classes}" classpath="${dir.src}" debug="${debug}" failonerror="no" > <include name="com/memoire/acme/Acme*.java"/> <include name="com/memoire/re/RE*.java"/> <include name="com/memoire/mst/Mst*.java"/> <include name="com/memoire/pbc/Pbc*.java"/> <include name="com/memoire/fu/Fu*.java"/> <include name="com/memoire/dnd/Dnd*.java"/> <include name="com/memoire/xml/Xml*.java"/> <include name="com/memoire/yapod/Yapod*.java"/> <include name="com/memoire/bu/Bu*.java"/> <include name="com/memoire/dja/Dja*.java"/> <include name="com/memoire/agl/Agl*.java"/> <include name="com/memoire/alma/Alma*.java"/> <include name="com/memoire/jedit/JEdit*.java"/> <include name="com/memoire/editor/Editor*.java"/> <include name="com/memoire/foo/Foo*.java"/> <include name="com/memoire/silk/Silk*.java"/> <include name="com/memoire/script/Script*.java"/> <exclude name="com/memoire/ant/*.java"/> <exclude name="com/memoire/editor/EditorJext.java"/> <exclude name="com/memoire/script/ScriptInterpreterBeanshell.java"/> <exclude name="com/memoire/script/ScriptInterpreterDawn.java"/> <exclude name="com/memoire/script/ScriptInterpreterFiji.java"/> <exclude name="com/memoire/script/ScriptInterpreterFoo.java"/> <exclude name="com/memoire/script/ScriptInterpreterPnuts.java"/> <exclude name="com/memoire/script/ScriptInterpreterPython.java"/> <exclude name="com/memoire/script/ScriptInterpreterRhino.java"/> <exclude name="com/memoire/script/ScriptInterpreterRuby.java"/> </javac>
</target>
<target name="dist" depends="compile">
<jar jarfile="${dir.dist}/${app.name}.jar" manifest="manifest-alma.txt" > <fileset dir="${dir.classes}" > <patternset> <exclude name="**/dependency cache"/> </patternset> </fileset> <fileset dir="${dir.src}" > <patternset> <include name="**/*.dja"/> <include name="**/*.foo"/> <include name="**/*.gif"/> <include name="**/*.txt"/> </patternset> </fileset> </jar>
</target>
<target name="main" depends="compile, dist" >
<echo>Alma application package created</echo>
</target>
<target name="javadocs" depends="prepare">
<mkdir dir="${dir.javadocs}"/> <javadoc packagenames="${packages}" sourcepath="${dir.src}" destdir="${dir.javadocs}" classpath="${dir.src}" author="true" version="true" use="true" windowtitle="${app.name} API" doctitle="<h1>${app.name}</h1>" />
</target>
<target name="clean" >
<delete dir="${dir.dist}" /> <delete dir="${dir.classes}" />
</target>
<target name="all" depends="clean,main,javadocs" >
<echo>Alma application package cleaned and created</echo>
</target>
<target name="app-run" depends="main" >
<java classname="com.memoire.alma.Alma" classpath="${dir.dist}/${app.name}.jar" fork="yes"> </java>
</target> <target name="run-alma" depends="main" >
<java classname="com.memoire.alma.Alma" classpath="${dir.dist}/${app.name}.jar" fork="yes"> </java>
</target> <target name="run-dja" depends="main" >
<java classname="com.memoire.dja.Dja" classpath="${dir.dist}/${app.name}.jar" fork="yes"> </java>
</target> <target name="run-agl" depends="main" >
<java classname="com.memoire.agl.Agl" classpath="${dir.dist}/${app.name}.jar" fork="no"> </java>
</target> <target name="run-foo" depends="main" >
<java classname="com.memoire.foo.Foo" classpath="${dir.dist}/${app.name}.jar" fork="no"> </java>
</target> <target name="run-reformatage" depends="main" >
<java classname="com.memoire.agl.AglOutilReformatage" classpath="${dir.dist}/${app.name}.jar" fork="no"> </java>
</target> <target name="run-coloration" depends="main" >
<java classname="com.memoire.agl.AglOutilColoration" classpath="${dir.dist}/${app.name}.jar" fork="no"> </java>
</target>
</project>
</source>
Generate Javadocs for the application
<source lang="java">
<?xml version="1.0"?> <project name="Example Application Build" default="build-both" basedir=".">
<property file="build.properties"/> <property name="cvsroot" value=":pserver:anoncvs@cvs.apache.org:/home/cvspublic" /> <property name="mysql.cvsroot" value=":pserver:anonymous@cvs.sourceforge.net:/cvsroot/mmmysql" /> <path id="build.classpath"> <pathelement location="${servlet24.jar}"/> <pathelement location="${jsp20.jar}"/> <pathelement location="${mysql.jar}"/> <pathelement path="${appName.jar}"/> </path> <fileset id="javadoc" dir="${src}"> <exclude name="*/conf/**"/> <exclude name="*/docs/*"/> <include name="shared/**"/> <include name="stand-alone/**"/> <include name="web/java/**"/> </fileset> <property name="docs.all.dir" value="${build}"/> <patternset id="docs.all"> <include name="docs/**"/> </patternset> <property name="docs.misc.dir" value="${src}/shared/docs"/> <patternset id="docs.misc"> <include name="README"/> <include name="LICENSE"/> </patternset> <property name="src.files.dir" value="."/> <patternset id="src.files"> <include name="${src}/**"/> <include name="build.*"/> </patternset> <patternset id="bin.jar"> <include name="*.jar"/> </patternset> <patternset id="bin.war"> <include name="*.war"/> </patternset> <target name="dir" description="Create the working directories"> <echo message="Creating the working directories"/> <mkdir dir="${build.stand-alone.root}"/> <mkdir dir="${build.web.classes}"/> <mkdir dir="${dist}"/> <mkdir dir="${lib}"/> </target> <target name="checkout-jstl" depends="dir" description="Update or check out required sources from CVS for the JSTL"> <echo message="Checking out the required JSTL sources from CVS"/> <cvs cvsroot="${cvsroot}" quiet="true" command="checkout -P ${jstl.build}" dest="${build}" compression="true" /> </target> <target name="checkout-mysql-connector" depends="dir" description="Update or check out required sources from CVS for the MySQL connector"> <echo message="Checking out the required sources from CVS for the MySQL connector" /> <cvs cvsroot="${mysql.cvsroot}" quiet="true" command="checkout" package="${mysql.build}" dest="${build}" compression="true" /> </target> <target name="build-jstl" depends="checkout-jstl" description="Build the JSTL from source"> <echo message="Building the JSTL from source"/> <ant antfile="build.xml" dir="${build}/${jstl.build}"/> <copy todir="${lib}"> <fileset dir="${build}/${jstl.build}/${build}/lib"> <include name="*.jar"/> </fileset> </copy> </target> <target name="build-mysql-connector" depends="checkout-mysql-connector" description="Build the MySQL connector from source"> <echo message="Building the MySQL connector from source"/> <mkdir dir="${build}/dist-mysql-jdbc"/> <ant antfile="build.xml" dir="${build}/${mysql.build}"/> <copy tofile="${mysql.jar}"> <fileset dir="${build}/build-mysql-jdbc"> <include name="mysql-connector*/*.jar"/> </fileset> </copy> </target> <target name="compile-stand-alone" depends="dir" description="Compile stand-alone application"> <echo message="Compiling the stand-alone application"/> <javac srcdir="${src.shared.java}" destdir="${build.stand-alone.root}"/> <javac srcdir="${src.stand-alone.java}" destdir="${build.stand-alone.root}"/> </target>
<target name="stand-alone-complete" depends="build-mysql-connector, package-stand-alone" description="Compile stand-alone application, using CVS version of the MySQL connector"> <echo message="Compiling stand-alone application, using CVS versions of the MySQL connector"/> </target> <target name="package-stand-alone" depends="compile-stand-alone" description="Package the stand-alone application"> <echo message="Creating the stand-alone JAR file"/> <copy file="${database.properties}" todir="${build.stand-alone.root}"/> <jar destfile="${appName.jar}" basedir="${build.stand-alone.root}"/> </target> <target name="compile-web" depends="dir" description="Compile web application"> <echo message="Compiling the web application"/> <javac destdir="${build.web.classes}"> <src path="${src.shared.java}"/> </javac> <javac srcdir="${src.web.java}" destdir="${build.web.classes}"> <classpath refid="build.classpath"/> </javac> </target>
<target name="web-complete" depends="build-mysql-connector, build-jstl, package-web" description="Compile web application, using CVS versions of the MySQL connector and the JSTL"> <echo message="Compiling web application, using CVS versions of the MySQL connector and the JSTL"/> </target> <target name="copy-web" depends="compile-web" description="Copy the web files"> <echo message="Copying the web pages and configuration files"/> <copy todir="${build.web.root}"> <fileset dir="${src.web.pages}"/> </copy> <copy todir="${build.web.tags}"> <fileset dir="${src.web.tags}"/> </copy> <copy todir="${build.web.web-inf}"> <fileset dir="${src.web.conf}"> <include name="*.tld"/> </fileset> </copy> <copy todir="${build.web.lib}"> <fileset dir="${lib}"/> </copy> <copy file="${database.properties}" todir="${build.web.classes}"/> </target>
<target name="package-web" depends="compile-web" description="Build the WAR file in one step"> <echo message="Building the WAR file in one step"/> <war destfile="${appName.war}" basedir="${src.web.pages}" webxml="${src.web.conf}/web.xml"> <lib dir="${lib}"/> <classes dir="${build.web.root}"/> <zipfileset dir="${src.web.tags}" prefix="WEB-INF/tags"/> <zipfileset file="${database.properties}" prefix="WEB-INF/classes"/> <zipfileset dir="${src.web.conf}" prefix="WEB-INF"> <include name="*.tld"/> </zipfileset> </war> </target>
<target name="build-both" depends="package-stand-alone, package-web" description="Compile both applications, without CVS versions of the MySQL connector and the JSTL"> <echo message="Compiled both applications, without CVS versions of the MySQL connector and the JSTL"/> </target> <target name="build-all" depends="stand-alone-complete, web-complete" description="Compile both applications, using CVS versions of the MySQL connector and the JSTL"> <echo message="Compiled both applications, using CVS versions of the MySQL connector and the JSTL"/> </target>
<target name="download-servlet-jar" depends="dir" description="Download the servlet JAR"> <echo message="Downloading the servlet JAR"/> <get src="http://www.ibiblio.org/maven/servletapi/jars/servletapi-2.4.jar" dest="${servlet24.jar}" verbose="true"/> </target> <target name="download-jsp-jar" depends="dir" description="Download the JSP JAR"> <echo message="Downloading the JSP JAR"/> <get src="http://www.ibiblio.org/maven/jspapi/jars/jsp-api-2.0.jar" dest="${jsp20.jar}" verbose="true"/> </target> <target name="check-docs" description="Check that the documentation is up to date"> <echo message="Checking that the documentation is up to date"/> <condition property="docs.notRequired"> <and> <uptodate targetfile="${dist}/${appName}-${package.docs}.zip"> <srcfiles dir="${src}" includes="**"/> </uptodate> <uptodate targetfile="${dist}/${appName}-${package.docs}.tar.gz"> <srcfiles dir="${src}" includes="**"/> </uptodate> </and> </condition> </target> <target name="javadocs" depends="dir,check-docs" description="Generate Javadocs for the application" unless="docs.notRequired"> <echo message="Generating Javadocs for the application"/> <javadoc destdir="${docs}/api" windowtitle="${javadoc.windowtitle}"> <fileset refid="javadoc"/> <doctitle> ${javadoc.doctitle} </doctitle> <classpath refid="build.classpath"/> <link href="http://java.sun.ru/j2se/${javadoc.j2se.version}/docs/api"/> <link href="http://java.sun.ru/j2ee/${javadoc.j2ee.version}/docs/api"/> </javadoc> </target> <target name="javadocs-offline" depends="dir,check-docs" description="Generate Javadocs for the application, using offline package-list files" unless="docs.notRequired"> <echo message="Generating Javadocs for the application, using offline package-list files"/> <javadoc destdir="${docs}/api" windowtitle="${javadoc.windowtitle}"> <fileset refid="javadoc"/> <doctitle> ${javadoc.doctitle} </doctitle> <classpath refid="build.classpath"/>
<link href="${javadoc.j2se.offline}" resolveLink="true"/> <link href="${javadoc.j2ee.offline}" resolveLink="true"/> </javadoc> </target> <target name="docs" depends="javadocs" description="Assemble the documentation" unless="docs.notRequired"> <echo message="Assembling the documentation"/> <copy todir="${docs}"> <fileset dir="${src.shared.docs}"> <include name="*.html"/> </fileset> </copy> <copy todir="${docs}/stand-alone"> <fileset dir="${src.stand-alone.docs}"> <include name="*.html"/> </fileset> </copy> <copy todir="${docs}/web"> <fileset dir="${src.web.docs}"> <include name="*.html"/> </fileset> </copy> </target> <target name="zip-docs" depends="docs" description="Zip the documentation"> <echo message="Zipping the documentation"/> <zip destfile="${dist}/${appName}-${package.docs}.zip"> <fileset dir="${docs.all.dir}"> <patternset refid="docs.all"/> </fileset> <fileset dir="${docs.misc.dir}"> <patternset refid="docs.misc"/> </fileset> </zip> <checksum file="${dist}/${appName}-${package.docs}.zip" forceOverwrite="true"/> <checksum file="${dist}/${appName}-${package.docs}.zip" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="zip-src" depends="zip-docs" description="Zip the source and documentation together"> <echo message="Zipping the source and documentation together"/> <zip destfile="${dist}/${appName}-src.zip"> <zipfileset src="${dist}/${appName}-${package.docs}.zip"/> <fileset dir="${src.files.dir}"> <patternset refid="src.files"/> </fileset> </zip> <checksum file="${dist}/${appName}-src.zip" forceOverwrite="true"/> <checksum file="${dist}/${appName}-src.zip" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="zip-bin-stand-alone" depends="package-stand-alone,zip-docs" description="Zip the binary stand-alone distribution with the documentation"> <echo message="Zipping the binary stand-alone distribution with the documentation"/> <zip destfile="${dist}/${appName}-${package.stand-alone}-bin.zip"> <zipfileset src="${dist}/${appName}-${package.docs}.zip"/> <zipfileset dir="${dist}" prefix="lib"> <patternset refid="bin.jar"/> </zipfileset> <fileset dir="."> <include name="${mysql.jar}"/> </fileset> </zip> <checksum file="${dist}/${appName}-${package.stand-alone}-bin.zip" forceOverwrite="true"/> <checksum file="${dist}/${appName}-${package.stand-alone}-bin.zip" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="zip-bin-web" depends="package-web,zip-docs" description="Zip the binary web distribution with the documentation"> <echo message="Zipping the binary web distribution with the documentation"/> <zip destfile="${dist}/${appName}-${package.web}-bin.zip"> <zipfileset src="${dist}/${appName}-${package.docs}.zip"/> <fileset dir="${dist}"> <patternset refid="bin.war"/> </fileset> </zip> <checksum file="${dist}/${appName}-${package.web}-bin.zip" forceOverwrite="true"/> <checksum file="${dist}/${appName}-${package.web}-bin.zip" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="zip-bin" depends="zip-bin-stand-alone,zip-bin-web" description="Zip the binary distribution with the documentation"> <echo message="Zipping the binary distribution with the documentation"/> <zip destfile="${dist}/${appName}-bin.zip" duplicate="preserve" update="true"> <zipgroupfileset dir="${dist}" includes="*.zip"/> </zip> <checksum file="${dist}/${appName}-bin.zip" forceOverwrite="true"/> <checksum file="${dist}/${appName}-bin.zip" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="zip-all" depends="zip-src,zip-bin" description="Zip the binary and source distributions"> <echo message="Zipped the binary and source distributions"/> </target> <target name="tar-docs" depends="docs" description="Tar the documentation"> <echo message="Tarring the documentation"/> <tar destfile="${dist}/${appName}-${package.docs}.tar.gz" compression="gzip"> <tarfileset dir="${docs.all.dir}"> <patternset refid="docs.all"/> </tarfileset> <tarfileset dir="${docs.misc.dir}"> <patternset refid="docs.misc"/> </tarfileset> </tar> <checksum file="${dist}/${appName}-${package.docs}.tar.gz" forceOverwrite="true"/> <checksum file="${dist}/${appName}-${package.docs}.tar.gz" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="tar-src" depends="tar-docs" description="Tar the documentation"> <echo message="Tarring the documentation"/> <tar destfile="${dist}/${appName}-src.tar.gz" compression="gzip"> <tarfileset dir="${docs.all.dir}"> <patternset refid="docs.all"/> </tarfileset> <tarfileset dir="${docs.misc.dir}"> <patternset refid="docs.misc"/> </tarfileset> <tarfileset dir="${src.files.dir}"> <patternset refid="src.files"/> </tarfileset> </tar> <checksum file="${dist}/${appName}-src.tar.gz" forceOverwrite="true"/> <checksum file="${dist}/${appName}-src.tar.gz" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="tar-bin-stand-alone" depends="package-stand-alone,tar-docs" description="Tar the binary stand-alone distribution with the documentation"> <echo message="Tarring the binary stand-alone distribution with the documentation"/> <tar destfile="${dist}/${appName}-${package.stand-alone}-bin.tar.gz" compression="gzip"> <tarfileset dir="${docs.all.dir}"> <patternset refid="docs.all"/> </tarfileset> <tarfileset dir="${docs.misc.dir}"> <patternset refid="docs.misc"/> </tarfileset> <tarfileset dir="${dist}" prefix="lib"> <patternset refid="bin.jar"/> </tarfileset> <tarfileset dir="."> <include name="${mysql.jar}"/> </tarfileset> </tar> <checksum file="${dist}/${appName}-${package.stand-alone}-bin.tar.gz" forceOverwrite="true"/> <checksum file="${dist}/${appName}-${package.stand-alone}-bin.tar.gz" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="tar-bin-web" depends="package-web,tar-docs" description="Tar the binary web distribution with the documentation"> <echo message="Tarring the binary web distribution with the documentation"/> <tar destfile="${dist}/${appName}-${package.web}-bin.tar.gz" compression="gzip"> <tarfileset dir="${docs.all.dir}"> <patternset refid="docs.all"/> </tarfileset> <tarfileset dir="${docs.misc.dir}"> <patternset refid="docs.misc"/> </tarfileset> <tarfileset dir="${dist}"> <patternset refid="bin.war"/> </tarfileset> </tar> <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" forceOverwrite="true"/> <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="tar-bin" depends="tar-bin-stand-alone,tar-bin-web" description="Tar the binary distribution with the documentation"> <echo message="Tarring the binary distribution with the documentation"/> <tar destfile="${dist}/${appName}-bin.tar.gz" compression="gzip"> <tarfileset dir="${docs.all.dir}"> <patternset refid="docs.all"/> </tarfileset> <tarfileset dir="${docs.misc.dir}"> <patternset refid="docs.misc"/> </tarfileset> <tarfileset dir="${src.files.dir}"> <patternset refid="src.files"/> </tarfileset> <tarfileset dir="${dist}" prefix="lib"> <patternset refid="bin.jar"/> </tarfileset> <tarfileset dir="."> <include name="${mysql.jar}"/> </tarfileset> <tarfileset dir="${dist}"> <patternset refid="bin.war"/> </tarfileset> </tar> <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true"/> <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="tar-bin-web-new" depends="package-web,tar-docs,zip-bin-web" description="Tar the binary web distribution with the documentation"> <echo message="Tarring the binary web distribution with the documentation"/> <unzip src="${dist}/${appName}-${package.web}-bin.zip" dest="${tmp}/web"/> <tar destfile="${dist}/${appName}-${package.web}-bin.tar.gz" compression="gzip"> <tarfileset dir="${tmp}/web"/> </tar> <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" forceOverwrite="true"/> <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="tar-bin-new" depends="zip-bin,tar-bin-stand-alone,tar-bin-web-new" description="Tar the binary distribution with the documentation"> <echo message="Tarring the binary distribution with the documentation"/> <delete failonerror="false" includeemptydirs="true"> <fileset dir="${tmp}" includes="**"/> </delete> <unzip src="${dist}/${appName}-bin.zip" dest="${tmp}"/> <tar destfile="${dist}/${appName}-bin.tar.gz" compression="gzip"> <tarfileset dir="${tmp}"/> </tar> <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true"/> <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="tar-all" depends="tar-src,tar-bin" description="Tar the binary and source distributions"> <echo message="Tarred the binary and source distributions"/> </target>
<target name="ftp-docs" depends="zip-docs,tar-docs" description="Place the documentation on FTP"> <echo message="Placing the documentation on FTP"/> <ftp server="${ftp.server}" userid="${ftp.user}" password="${ftp.password}" remotedir="${ftp.src.dir}" action="send" newer="true" timediffauto="true"> <fileset dir="${dist}"> <include name="${appName}-${package.docs}.*"/> </fileset> </ftp> </target> <target name="ftp-src" depends="zip-src,tar-src" description="Place the source code on FTP"> <echo message="Placing the source code on FTP"/> <ftp server="${ftp.server}" userid="${ftp.user}" password="${ftp.password}" remotedir="${ftp.src.dir}" action="send" newer="true" timediffauto="true"> <fileset dir="${dist}"> <include name="${appName}-src.*"/> </fileset> </ftp> </target> <target name="ftp-bin" depends="zip-bin,tar-bin" description="Place the binaries on FTP"> <echo message="Placing the binaries on FTP"/> <ftp server="${ftp.server}" userid="${ftp.user}" password="${ftp.password}" remotedir="${ftp.bin.dir}" action="send" newer="true" timediffauto="true"> <fileset dir="${dist}"> <include name="${appName}*bin*"/> </fileset> </ftp> </target> <target name="ftp" description="Place everything on FTP"> <echo message="Placing everything on FTP"/> <antcall target="ftp-docs"/> <antcall target="ftp-src"/> <antcall target="ftp-bin"/> </target>
<target name="email-docs" depends="zip-docs,tar-docs" description="E-mailing the documentation"> <echo message="E-mailing the documentation"/> <mail from="${mail.from}" tolist="${mail.tolist}" mailhost="${mail.mailhost}" user="${mail.user}" password="${mail.password}" subject="${mail.subject}"> <message> ${mail.message.docs} </message> <fileset dir="${dist}"> <include name="${appName}-${package.docs}.*"/> </fileset> </mail> </target> <target name="deploy-copy-files" depends="copy-web" description="Deploy the application by copying it to Tomcat"> <echo message="Copying the expanded web application to CATALINA_HOME"/> <property environment="env"/> <copy todir="${build.web.web-inf}" file="${src.web.conf}/web.xml"/> <copy todir="${env.CATALINA_HOME}/webapps/${appName}"> <fileset dir="${build.web.root}"/> </copy> </target> <target name="deploy-copy-war" depends="package-web" description="Deploy the WAR by copying it to Tomcat"> <echo message="Copying the WAR to CATALINA_HOME"/> <property environment="env"/> <copy file="${appName.war}" todir="${env.CATALINA_HOME}/webapps"/> </target> <target name="deploy-context" depends="copy-web" description="Deploy the web application using a context XML file"> <echo message="Deploying the web application using a context XML file"/> <property environment="env"/> <copy todir="${build.web.web-inf}" file="${src.web.conf}/web.xml"/> <copy todir="${env.CATALINA_HOME}/conf/Catalina/localhost" file="${src.web.conf}/${appName}.xml"/> </target> <taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask"/> <target name="deploy" depends="package-web" description="Hot deploy the application"> <echo message="Deploying the WAR to Tomcat"/> <deploy url="${manager.url}" username="${manager.user}" password="${manager.password}" path="/${appName}" war="file:${appName.war}" update="true"/> </target> <taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask"/> <target name="undeploy" description="Undeploy the application"> <echo message="Undeploying the WAR"/> <undeploy url="${manager.url}" username="${manager.user}" password="${manager.password}" path="/${appName}"/> </target> <target name="clean" description="Clean up the working directories"> <echo message="Cleaning up"/> <delete dir="${build}"/> </target>
</project>
</source>
Generate Javadocs for the application, using offline package-list files
<source lang="java">
<?xml version="1.0"?> <project name="Example Application Build" default="build-both" basedir=".">
<property file="build.properties"/> <property name="cvsroot" value=":pserver:anoncvs@cvs.apache.org:/home/cvspublic" /> <property name="mysql.cvsroot" value=":pserver:anonymous@cvs.sourceforge.net:/cvsroot/mmmysql" /> <path id="build.classpath"> <pathelement location="${servlet24.jar}"/> <pathelement location="${jsp20.jar}"/> <pathelement location="${mysql.jar}"/> <pathelement path="${appName.jar}"/> </path> <fileset id="javadoc" dir="${src}"> <exclude name="*/conf/**"/> <exclude name="*/docs/*"/> <include name="shared/**"/> <include name="stand-alone/**"/> <include name="web/java/**"/> </fileset> <property name="docs.all.dir" value="${build}"/> <patternset id="docs.all"> <include name="docs/**"/> </patternset> <property name="docs.misc.dir" value="${src}/shared/docs"/> <patternset id="docs.misc"> <include name="README"/> <include name="LICENSE"/> </patternset> <property name="src.files.dir" value="."/> <patternset id="src.files"> <include name="${src}/**"/> <include name="build.*"/> </patternset> <patternset id="bin.jar"> <include name="*.jar"/> </patternset> <patternset id="bin.war"> <include name="*.war"/> </patternset> <target name="dir" description="Create the working directories"> <echo message="Creating the working directories"/> <mkdir dir="${build.stand-alone.root}"/> <mkdir dir="${build.web.classes}"/> <mkdir dir="${dist}"/> <mkdir dir="${lib}"/> </target> <target name="checkout-jstl" depends="dir" description="Update or check out required sources from CVS for the JSTL"> <echo message="Checking out the required JSTL sources from CVS"/> <cvs cvsroot="${cvsroot}" quiet="true" command="checkout -P ${jstl.build}" dest="${build}" compression="true" /> </target> <target name="checkout-mysql-connector" depends="dir" description="Update or check out required sources from CVS for the MySQL connector"> <echo message="Checking out the required sources from CVS for the MySQL connector" /> <cvs cvsroot="${mysql.cvsroot}" quiet="true" command="checkout" package="${mysql.build}" dest="${build}" compression="true" /> </target> <target name="build-jstl" depends="checkout-jstl" description="Build the JSTL from source"> <echo message="Building the JSTL from source"/> <ant antfile="build.xml" dir="${build}/${jstl.build}"/> <copy todir="${lib}"> <fileset dir="${build}/${jstl.build}/${build}/lib"> <include name="*.jar"/> </fileset> </copy> </target> <target name="build-mysql-connector" depends="checkout-mysql-connector" description="Build the MySQL connector from source"> <echo message="Building the MySQL connector from source"/> <mkdir dir="${build}/dist-mysql-jdbc"/> <ant antfile="build.xml" dir="${build}/${mysql.build}"/> <copy tofile="${mysql.jar}"> <fileset dir="${build}/build-mysql-jdbc"> <include name="mysql-connector*/*.jar"/> </fileset> </copy> </target> <target name="compile-stand-alone" depends="dir" description="Compile stand-alone application"> <echo message="Compiling the stand-alone application"/> <javac srcdir="${src.shared.java}" destdir="${build.stand-alone.root}"/> <javac srcdir="${src.stand-alone.java}" destdir="${build.stand-alone.root}"/> </target>
<target name="stand-alone-complete" depends="build-mysql-connector, package-stand-alone" description="Compile stand-alone application, using CVS version of the MySQL connector"> <echo message="Compiling stand-alone application, using CVS versions of the MySQL connector"/> </target> <target name="package-stand-alone" depends="compile-stand-alone" description="Package the stand-alone application"> <echo message="Creating the stand-alone JAR file"/> <copy file="${database.properties}" todir="${build.stand-alone.root}"/> <jar destfile="${appName.jar}" basedir="${build.stand-alone.root}"/> </target> <target name="compile-web" depends="dir" description="Compile web application"> <echo message="Compiling the web application"/> <javac destdir="${build.web.classes}"> <src path="${src.shared.java}"/> </javac> <javac srcdir="${src.web.java}" destdir="${build.web.classes}"> <classpath refid="build.classpath"/> </javac> </target>
<target name="web-complete" depends="build-mysql-connector, build-jstl, package-web" description="Compile web application, using CVS versions of the MySQL connector and the JSTL"> <echo message="Compiling web application, using CVS versions of the MySQL connector and the JSTL"/> </target> <target name="copy-web" depends="compile-web" description="Copy the web files"> <echo message="Copying the web pages and configuration files"/> <copy todir="${build.web.root}"> <fileset dir="${src.web.pages}"/> </copy> <copy todir="${build.web.tags}"> <fileset dir="${src.web.tags}"/> </copy> <copy todir="${build.web.web-inf}"> <fileset dir="${src.web.conf}"> <include name="*.tld"/> </fileset> </copy> <copy todir="${build.web.lib}"> <fileset dir="${lib}"/> </copy> <copy file="${database.properties}" todir="${build.web.classes}"/> </target>
<target name="package-web" depends="compile-web" description="Build the WAR file in one step"> <echo message="Building the WAR file in one step"/> <war destfile="${appName.war}" basedir="${src.web.pages}" webxml="${src.web.conf}/web.xml"> <lib dir="${lib}"/> <classes dir="${build.web.root}"/> <zipfileset dir="${src.web.tags}" prefix="WEB-INF/tags"/> <zipfileset file="${database.properties}" prefix="WEB-INF/classes"/> <zipfileset dir="${src.web.conf}" prefix="WEB-INF"> <include name="*.tld"/> </zipfileset> </war> </target>
<target name="build-both" depends="package-stand-alone, package-web" description="Compile both applications, without CVS versions of the MySQL connector and the JSTL"> <echo message="Compiled both applications, without CVS versions of the MySQL connector and the JSTL"/> </target> <target name="build-all" depends="stand-alone-complete, web-complete" description="Compile both applications, using CVS versions of the MySQL connector and the JSTL"> <echo message="Compiled both applications, using CVS versions of the MySQL connector and the JSTL"/> </target>
<target name="download-servlet-jar" depends="dir" description="Download the servlet JAR"> <echo message="Downloading the servlet JAR"/> <get src="http://www.ibiblio.org/maven/servletapi/jars/servletapi-2.4.jar" dest="${servlet24.jar}" verbose="true"/> </target> <target name="download-jsp-jar" depends="dir" description="Download the JSP JAR"> <echo message="Downloading the JSP JAR"/> <get src="http://www.ibiblio.org/maven/jspapi/jars/jsp-api-2.0.jar" dest="${jsp20.jar}" verbose="true"/> </target> <target name="check-docs" description="Check that the documentation is up to date"> <echo message="Checking that the documentation is up to date"/> <condition property="docs.notRequired"> <and> <uptodate targetfile="${dist}/${appName}-${package.docs}.zip"> <srcfiles dir="${src}" includes="**"/> </uptodate> <uptodate targetfile="${dist}/${appName}-${package.docs}.tar.gz"> <srcfiles dir="${src}" includes="**"/> </uptodate> </and> </condition> </target> <target name="javadocs" depends="dir,check-docs" description="Generate Javadocs for the application" unless="docs.notRequired"> <echo message="Generating Javadocs for the application"/> <javadoc destdir="${docs}/api" windowtitle="${javadoc.windowtitle}"> <fileset refid="javadoc"/> <doctitle> ${javadoc.doctitle} </doctitle> <classpath refid="build.classpath"/> <link href="http://java.sun.ru/j2se/${javadoc.j2se.version}/docs/api"/> <link href="http://java.sun.ru/j2ee/${javadoc.j2ee.version}/docs/api"/> </javadoc> </target> <target name="javadocs-offline" depends="dir,check-docs" description="Generate Javadocs for the application, using offline package-list files" unless="docs.notRequired"> <echo message="Generating Javadocs for the application, using offline package-list files"/> <javadoc destdir="${docs}/api" windowtitle="${javadoc.windowtitle}"> <fileset refid="javadoc"/> <doctitle> ${javadoc.doctitle} </doctitle> <classpath refid="build.classpath"/>
<link href="${javadoc.j2se.offline}" resolveLink="true"/> <link href="${javadoc.j2ee.offline}" resolveLink="true"/> </javadoc> </target> <target name="docs" depends="javadocs" description="Assemble the documentation" unless="docs.notRequired"> <echo message="Assembling the documentation"/> <copy todir="${docs}"> <fileset dir="${src.shared.docs}"> <include name="*.html"/> </fileset> </copy> <copy todir="${docs}/stand-alone"> <fileset dir="${src.stand-alone.docs}"> <include name="*.html"/> </fileset> </copy> <copy todir="${docs}/web"> <fileset dir="${src.web.docs}"> <include name="*.html"/> </fileset> </copy> </target> <target name="zip-docs" depends="docs" description="Zip the documentation"> <echo message="Zipping the documentation"/> <zip destfile="${dist}/${appName}-${package.docs}.zip"> <fileset dir="${docs.all.dir}"> <patternset refid="docs.all"/> </fileset> <fileset dir="${docs.misc.dir}"> <patternset refid="docs.misc"/> </fileset> </zip> <checksum file="${dist}/${appName}-${package.docs}.zip" forceOverwrite="true"/> <checksum file="${dist}/${appName}-${package.docs}.zip" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="zip-src" depends="zip-docs" description="Zip the source and documentation together"> <echo message="Zipping the source and documentation together"/> <zip destfile="${dist}/${appName}-src.zip"> <zipfileset src="${dist}/${appName}-${package.docs}.zip"/> <fileset dir="${src.files.dir}"> <patternset refid="src.files"/> </fileset> </zip> <checksum file="${dist}/${appName}-src.zip" forceOverwrite="true"/> <checksum file="${dist}/${appName}-src.zip" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="zip-bin-stand-alone" depends="package-stand-alone,zip-docs" description="Zip the binary stand-alone distribution with the documentation"> <echo message="Zipping the binary stand-alone distribution with the documentation"/> <zip destfile="${dist}/${appName}-${package.stand-alone}-bin.zip"> <zipfileset src="${dist}/${appName}-${package.docs}.zip"/> <zipfileset dir="${dist}" prefix="lib"> <patternset refid="bin.jar"/> </zipfileset> <fileset dir="."> <include name="${mysql.jar}"/> </fileset> </zip> <checksum file="${dist}/${appName}-${package.stand-alone}-bin.zip" forceOverwrite="true"/> <checksum file="${dist}/${appName}-${package.stand-alone}-bin.zip" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="zip-bin-web" depends="package-web,zip-docs" description="Zip the binary web distribution with the documentation"> <echo message="Zipping the binary web distribution with the documentation"/> <zip destfile="${dist}/${appName}-${package.web}-bin.zip"> <zipfileset src="${dist}/${appName}-${package.docs}.zip"/> <fileset dir="${dist}"> <patternset refid="bin.war"/> </fileset> </zip> <checksum file="${dist}/${appName}-${package.web}-bin.zip" forceOverwrite="true"/> <checksum file="${dist}/${appName}-${package.web}-bin.zip" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="zip-bin" depends="zip-bin-stand-alone,zip-bin-web" description="Zip the binary distribution with the documentation"> <echo message="Zipping the binary distribution with the documentation"/> <zip destfile="${dist}/${appName}-bin.zip" duplicate="preserve" update="true"> <zipgroupfileset dir="${dist}" includes="*.zip"/> </zip> <checksum file="${dist}/${appName}-bin.zip" forceOverwrite="true"/> <checksum file="${dist}/${appName}-bin.zip" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="zip-all" depends="zip-src,zip-bin" description="Zip the binary and source distributions"> <echo message="Zipped the binary and source distributions"/> </target> <target name="tar-docs" depends="docs" description="Tar the documentation"> <echo message="Tarring the documentation"/> <tar destfile="${dist}/${appName}-${package.docs}.tar.gz" compression="gzip"> <tarfileset dir="${docs.all.dir}"> <patternset refid="docs.all"/> </tarfileset> <tarfileset dir="${docs.misc.dir}"> <patternset refid="docs.misc"/> </tarfileset> </tar> <checksum file="${dist}/${appName}-${package.docs}.tar.gz" forceOverwrite="true"/> <checksum file="${dist}/${appName}-${package.docs}.tar.gz" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="tar-src" depends="tar-docs" description="Tar the documentation"> <echo message="Tarring the documentation"/> <tar destfile="${dist}/${appName}-src.tar.gz" compression="gzip"> <tarfileset dir="${docs.all.dir}"> <patternset refid="docs.all"/> </tarfileset> <tarfileset dir="${docs.misc.dir}"> <patternset refid="docs.misc"/> </tarfileset> <tarfileset dir="${src.files.dir}"> <patternset refid="src.files"/> </tarfileset> </tar> <checksum file="${dist}/${appName}-src.tar.gz" forceOverwrite="true"/> <checksum file="${dist}/${appName}-src.tar.gz" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="tar-bin-stand-alone" depends="package-stand-alone,tar-docs" description="Tar the binary stand-alone distribution with the documentation"> <echo message="Tarring the binary stand-alone distribution with the documentation"/> <tar destfile="${dist}/${appName}-${package.stand-alone}-bin.tar.gz" compression="gzip"> <tarfileset dir="${docs.all.dir}"> <patternset refid="docs.all"/> </tarfileset> <tarfileset dir="${docs.misc.dir}"> <patternset refid="docs.misc"/> </tarfileset> <tarfileset dir="${dist}" prefix="lib"> <patternset refid="bin.jar"/> </tarfileset> <tarfileset dir="."> <include name="${mysql.jar}"/> </tarfileset> </tar> <checksum file="${dist}/${appName}-${package.stand-alone}-bin.tar.gz" forceOverwrite="true"/> <checksum file="${dist}/${appName}-${package.stand-alone}-bin.tar.gz" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="tar-bin-web" depends="package-web,tar-docs" description="Tar the binary web distribution with the documentation"> <echo message="Tarring the binary web distribution with the documentation"/> <tar destfile="${dist}/${appName}-${package.web}-bin.tar.gz" compression="gzip"> <tarfileset dir="${docs.all.dir}"> <patternset refid="docs.all"/> </tarfileset> <tarfileset dir="${docs.misc.dir}"> <patternset refid="docs.misc"/> </tarfileset> <tarfileset dir="${dist}"> <patternset refid="bin.war"/> </tarfileset> </tar> <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" forceOverwrite="true"/> <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="tar-bin" depends="tar-bin-stand-alone,tar-bin-web" description="Tar the binary distribution with the documentation"> <echo message="Tarring the binary distribution with the documentation"/> <tar destfile="${dist}/${appName}-bin.tar.gz" compression="gzip"> <tarfileset dir="${docs.all.dir}"> <patternset refid="docs.all"/> </tarfileset> <tarfileset dir="${docs.misc.dir}"> <patternset refid="docs.misc"/> </tarfileset> <tarfileset dir="${src.files.dir}"> <patternset refid="src.files"/> </tarfileset> <tarfileset dir="${dist}" prefix="lib"> <patternset refid="bin.jar"/> </tarfileset> <tarfileset dir="."> <include name="${mysql.jar}"/> </tarfileset> <tarfileset dir="${dist}"> <patternset refid="bin.war"/> </tarfileset> </tar> <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true"/> <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="tar-bin-web-new" depends="package-web,tar-docs,zip-bin-web" description="Tar the binary web distribution with the documentation"> <echo message="Tarring the binary web distribution with the documentation"/> <unzip src="${dist}/${appName}-${package.web}-bin.zip" dest="${tmp}/web"/> <tar destfile="${dist}/${appName}-${package.web}-bin.tar.gz" compression="gzip"> <tarfileset dir="${tmp}/web"/> </tar> <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" forceOverwrite="true"/> <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="tar-bin-new" depends="zip-bin,tar-bin-stand-alone,tar-bin-web-new" description="Tar the binary distribution with the documentation"> <echo message="Tarring the binary distribution with the documentation"/> <delete failonerror="false" includeemptydirs="true"> <fileset dir="${tmp}" includes="**"/> </delete> <unzip src="${dist}/${appName}-bin.zip" dest="${tmp}"/> <tar destfile="${dist}/${appName}-bin.tar.gz" compression="gzip"> <tarfileset dir="${tmp}"/> </tar> <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true"/> <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="tar-all" depends="tar-src,tar-bin" description="Tar the binary and source distributions"> <echo message="Tarred the binary and source distributions"/> </target>
<target name="ftp-docs" depends="zip-docs,tar-docs" description="Place the documentation on FTP"> <echo message="Placing the documentation on FTP"/> <ftp server="${ftp.server}" userid="${ftp.user}" password="${ftp.password}" remotedir="${ftp.src.dir}" action="send" newer="true" timediffauto="true"> <fileset dir="${dist}"> <include name="${appName}-${package.docs}.*"/> </fileset> </ftp> </target> <target name="ftp-src" depends="zip-src,tar-src" description="Place the source code on FTP"> <echo message="Placing the source code on FTP"/> <ftp server="${ftp.server}" userid="${ftp.user}" password="${ftp.password}" remotedir="${ftp.src.dir}" action="send" newer="true" timediffauto="true"> <fileset dir="${dist}"> <include name="${appName}-src.*"/> </fileset> </ftp> </target> <target name="ftp-bin" depends="zip-bin,tar-bin" description="Place the binaries on FTP"> <echo message="Placing the binaries on FTP"/> <ftp server="${ftp.server}" userid="${ftp.user}" password="${ftp.password}" remotedir="${ftp.bin.dir}" action="send" newer="true" timediffauto="true"> <fileset dir="${dist}"> <include name="${appName}*bin*"/> </fileset> </ftp> </target> <target name="ftp" description="Place everything on FTP"> <echo message="Placing everything on FTP"/> <antcall target="ftp-docs"/> <antcall target="ftp-src"/> <antcall target="ftp-bin"/> </target>
<target name="email-docs" depends="zip-docs,tar-docs" description="E-mailing the documentation"> <echo message="E-mailing the documentation"/> <mail from="${mail.from}" tolist="${mail.tolist}" mailhost="${mail.mailhost}" user="${mail.user}" password="${mail.password}" subject="${mail.subject}"> <message> ${mail.message.docs} </message> <fileset dir="${dist}"> <include name="${appName}-${package.docs}.*"/> </fileset> </mail> </target> <target name="deploy-copy-files" depends="copy-web" description="Deploy the application by copying it to Tomcat"> <echo message="Copying the expanded web application to CATALINA_HOME"/> <property environment="env"/> <copy todir="${build.web.web-inf}" file="${src.web.conf}/web.xml"/> <copy todir="${env.CATALINA_HOME}/webapps/${appName}"> <fileset dir="${build.web.root}"/> </copy> </target> <target name="deploy-copy-war" depends="package-web" description="Deploy the WAR by copying it to Tomcat"> <echo message="Copying the WAR to CATALINA_HOME"/> <property environment="env"/> <copy file="${appName.war}" todir="${env.CATALINA_HOME}/webapps"/> </target> <target name="deploy-context" depends="copy-web" description="Deploy the web application using a context XML file"> <echo message="Deploying the web application using a context XML file"/> <property environment="env"/> <copy todir="${build.web.web-inf}" file="${src.web.conf}/web.xml"/> <copy todir="${env.CATALINA_HOME}/conf/Catalina/localhost" file="${src.web.conf}/${appName}.xml"/> </target> <taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask"/> <target name="deploy" depends="package-web" description="Hot deploy the application"> <echo message="Deploying the WAR to Tomcat"/> <deploy url="${manager.url}" username="${manager.user}" password="${manager.password}" path="/${appName}" war="file:${appName.war}" update="true"/> </target> <taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask"/> <target name="undeploy" description="Undeploy the application"> <echo message="Undeploying the WAR"/> <undeploy url="${manager.url}" username="${manager.user}" password="${manager.password}" path="/${appName}"/> </target> <target name="clean" description="Clean up the working directories"> <echo message="Cleaning up"/> <delete dir="${build}"/> </target>
</project>
</source>
Zip the documentation
<source lang="java">
<?xml version="1.0"?> <project name="Example Application Build" default="build-both" basedir=".">
<property file="build.properties"/> <property name="cvsroot" value=":pserver:anoncvs@cvs.apache.org:/home/cvspublic" /> <property name="mysql.cvsroot" value=":pserver:anonymous@cvs.sourceforge.net:/cvsroot/mmmysql" /> <path id="build.classpath"> <pathelement location="${servlet24.jar}"/> <pathelement location="${jsp20.jar}"/> <pathelement location="${mysql.jar}"/> <pathelement path="${appName.jar}"/> </path> <fileset id="javadoc" dir="${src}"> <exclude name="*/conf/**"/> <exclude name="*/docs/*"/> <include name="shared/**"/> <include name="stand-alone/**"/> <include name="web/java/**"/> </fileset> <property name="docs.all.dir" value="${build}"/> <patternset id="docs.all"> <include name="docs/**"/> </patternset> <property name="docs.misc.dir" value="${src}/shared/docs"/> <patternset id="docs.misc"> <include name="README"/> <include name="LICENSE"/> </patternset> <property name="src.files.dir" value="."/> <patternset id="src.files"> <include name="${src}/**"/> <include name="build.*"/> </patternset> <patternset id="bin.jar"> <include name="*.jar"/> </patternset> <patternset id="bin.war"> <include name="*.war"/> </patternset> <target name="dir" description="Create the working directories"> <echo message="Creating the working directories"/> <mkdir dir="${build.stand-alone.root}"/> <mkdir dir="${build.web.classes}"/> <mkdir dir="${dist}"/> <mkdir dir="${lib}"/> </target> <target name="checkout-jstl" depends="dir" description="Update or check out required sources from CVS for the JSTL"> <echo message="Checking out the required JSTL sources from CVS"/> <cvs cvsroot="${cvsroot}" quiet="true" command="checkout -P ${jstl.build}" dest="${build}" compression="true" /> </target> <target name="checkout-mysql-connector" depends="dir" description="Update or check out required sources from CVS for the MySQL connector"> <echo message="Checking out the required sources from CVS for the MySQL connector" /> <cvs cvsroot="${mysql.cvsroot}" quiet="true" command="checkout" package="${mysql.build}" dest="${build}" compression="true" /> </target> <target name="build-jstl" depends="checkout-jstl" description="Build the JSTL from source"> <echo message="Building the JSTL from source"/> <ant antfile="build.xml" dir="${build}/${jstl.build}"/> <copy todir="${lib}"> <fileset dir="${build}/${jstl.build}/${build}/lib"> <include name="*.jar"/> </fileset> </copy> </target> <target name="build-mysql-connector" depends="checkout-mysql-connector" description="Build the MySQL connector from source"> <echo message="Building the MySQL connector from source"/> <mkdir dir="${build}/dist-mysql-jdbc"/> <ant antfile="build.xml" dir="${build}/${mysql.build}"/> <copy tofile="${mysql.jar}"> <fileset dir="${build}/build-mysql-jdbc"> <include name="mysql-connector*/*.jar"/> </fileset> </copy> </target> <target name="compile-stand-alone" depends="dir" description="Compile stand-alone application"> <echo message="Compiling the stand-alone application"/> <javac srcdir="${src.shared.java}" destdir="${build.stand-alone.root}"/> <javac srcdir="${src.stand-alone.java}" destdir="${build.stand-alone.root}"/> </target>
<target name="stand-alone-complete" depends="build-mysql-connector, package-stand-alone" description="Compile stand-alone application, using CVS version of the MySQL connector"> <echo message="Compiling stand-alone application, using CVS versions of the MySQL connector"/> </target> <target name="package-stand-alone" depends="compile-stand-alone" description="Package the stand-alone application"> <echo message="Creating the stand-alone JAR file"/> <copy file="${database.properties}" todir="${build.stand-alone.root}"/> <jar destfile="${appName.jar}" basedir="${build.stand-alone.root}"/> </target> <target name="compile-web" depends="dir" description="Compile web application"> <echo message="Compiling the web application"/> <javac destdir="${build.web.classes}"> <src path="${src.shared.java}"/> </javac> <javac srcdir="${src.web.java}" destdir="${build.web.classes}"> <classpath refid="build.classpath"/> </javac> </target>
<target name="web-complete" depends="build-mysql-connector, build-jstl, package-web" description="Compile web application, using CVS versions of the MySQL connector and the JSTL"> <echo message="Compiling web application, using CVS versions of the MySQL connector and the JSTL"/> </target> <target name="copy-web" depends="compile-web" description="Copy the web files"> <echo message="Copying the web pages and configuration files"/> <copy todir="${build.web.root}"> <fileset dir="${src.web.pages}"/> </copy> <copy todir="${build.web.tags}"> <fileset dir="${src.web.tags}"/> </copy> <copy todir="${build.web.web-inf}"> <fileset dir="${src.web.conf}"> <include name="*.tld"/> </fileset> </copy> <copy todir="${build.web.lib}"> <fileset dir="${lib}"/> </copy> <copy file="${database.properties}" todir="${build.web.classes}"/> </target>
<target name="package-web" depends="compile-web" description="Build the WAR file in one step"> <echo message="Building the WAR file in one step"/> <war destfile="${appName.war}" basedir="${src.web.pages}" webxml="${src.web.conf}/web.xml"> <lib dir="${lib}"/> <classes dir="${build.web.root}"/> <zipfileset dir="${src.web.tags}" prefix="WEB-INF/tags"/> <zipfileset file="${database.properties}" prefix="WEB-INF/classes"/> <zipfileset dir="${src.web.conf}" prefix="WEB-INF"> <include name="*.tld"/> </zipfileset> </war> </target>
<target name="build-both" depends="package-stand-alone, package-web" description="Compile both applications, without CVS versions of the MySQL connector and the JSTL"> <echo message="Compiled both applications, without CVS versions of the MySQL connector and the JSTL"/> </target> <target name="build-all" depends="stand-alone-complete, web-complete" description="Compile both applications, using CVS versions of the MySQL connector and the JSTL"> <echo message="Compiled both applications, using CVS versions of the MySQL connector and the JSTL"/> </target>
<target name="download-servlet-jar" depends="dir" description="Download the servlet JAR"> <echo message="Downloading the servlet JAR"/> <get src="http://www.ibiblio.org/maven/servletapi/jars/servletapi-2.4.jar" dest="${servlet24.jar}" verbose="true"/> </target> <target name="download-jsp-jar" depends="dir" description="Download the JSP JAR"> <echo message="Downloading the JSP JAR"/> <get src="http://www.ibiblio.org/maven/jspapi/jars/jsp-api-2.0.jar" dest="${jsp20.jar}" verbose="true"/> </target> <target name="check-docs" description="Check that the documentation is up to date"> <echo message="Checking that the documentation is up to date"/> <condition property="docs.notRequired"> <and> <uptodate targetfile="${dist}/${appName}-${package.docs}.zip"> <srcfiles dir="${src}" includes="**"/> </uptodate> <uptodate targetfile="${dist}/${appName}-${package.docs}.tar.gz"> <srcfiles dir="${src}" includes="**"/> </uptodate> </and> </condition> </target> <target name="javadocs" depends="dir,check-docs" description="Generate Javadocs for the application" unless="docs.notRequired"> <echo message="Generating Javadocs for the application"/> <javadoc destdir="${docs}/api" windowtitle="${javadoc.windowtitle}"> <fileset refid="javadoc"/> <doctitle> ${javadoc.doctitle} </doctitle> <classpath refid="build.classpath"/> <link href="http://java.sun.ru/j2se/${javadoc.j2se.version}/docs/api"/> <link href="http://java.sun.ru/j2ee/${javadoc.j2ee.version}/docs/api"/> </javadoc> </target> <target name="javadocs-offline" depends="dir,check-docs" description="Generate Javadocs for the application, using offline package-list files" unless="docs.notRequired"> <echo message="Generating Javadocs for the application, using offline package-list files"/> <javadoc destdir="${docs}/api" windowtitle="${javadoc.windowtitle}"> <fileset refid="javadoc"/> <doctitle> ${javadoc.doctitle} </doctitle> <classpath refid="build.classpath"/>
<link href="${javadoc.j2se.offline}" resolveLink="true"/> <link href="${javadoc.j2ee.offline}" resolveLink="true"/> </javadoc> </target> <target name="docs" depends="javadocs" description="Assemble the documentation" unless="docs.notRequired"> <echo message="Assembling the documentation"/> <copy todir="${docs}"> <fileset dir="${src.shared.docs}"> <include name="*.html"/> </fileset> </copy> <copy todir="${docs}/stand-alone"> <fileset dir="${src.stand-alone.docs}"> <include name="*.html"/> </fileset> </copy> <copy todir="${docs}/web"> <fileset dir="${src.web.docs}"> <include name="*.html"/> </fileset> </copy> </target> <target name="zip-docs" depends="docs" description="Zip the documentation"> <echo message="Zipping the documentation"/> <zip destfile="${dist}/${appName}-${package.docs}.zip"> <fileset dir="${docs.all.dir}"> <patternset refid="docs.all"/> </fileset> <fileset dir="${docs.misc.dir}"> <patternset refid="docs.misc"/> </fileset> </zip> <checksum file="${dist}/${appName}-${package.docs}.zip" forceOverwrite="true"/> <checksum file="${dist}/${appName}-${package.docs}.zip" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="zip-src" depends="zip-docs" description="Zip the source and documentation together"> <echo message="Zipping the source and documentation together"/> <zip destfile="${dist}/${appName}-src.zip"> <zipfileset src="${dist}/${appName}-${package.docs}.zip"/> <fileset dir="${src.files.dir}"> <patternset refid="src.files"/> </fileset> </zip> <checksum file="${dist}/${appName}-src.zip" forceOverwrite="true"/> <checksum file="${dist}/${appName}-src.zip" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="zip-bin-stand-alone" depends="package-stand-alone,zip-docs" description="Zip the binary stand-alone distribution with the documentation"> <echo message="Zipping the binary stand-alone distribution with the documentation"/> <zip destfile="${dist}/${appName}-${package.stand-alone}-bin.zip"> <zipfileset src="${dist}/${appName}-${package.docs}.zip"/> <zipfileset dir="${dist}" prefix="lib"> <patternset refid="bin.jar"/> </zipfileset> <fileset dir="."> <include name="${mysql.jar}"/> </fileset> </zip> <checksum file="${dist}/${appName}-${package.stand-alone}-bin.zip" forceOverwrite="true"/> <checksum file="${dist}/${appName}-${package.stand-alone}-bin.zip" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="zip-bin-web" depends="package-web,zip-docs" description="Zip the binary web distribution with the documentation"> <echo message="Zipping the binary web distribution with the documentation"/> <zip destfile="${dist}/${appName}-${package.web}-bin.zip"> <zipfileset src="${dist}/${appName}-${package.docs}.zip"/> <fileset dir="${dist}"> <patternset refid="bin.war"/> </fileset> </zip> <checksum file="${dist}/${appName}-${package.web}-bin.zip" forceOverwrite="true"/> <checksum file="${dist}/${appName}-${package.web}-bin.zip" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="zip-bin" depends="zip-bin-stand-alone,zip-bin-web" description="Zip the binary distribution with the documentation"> <echo message="Zipping the binary distribution with the documentation"/> <zip destfile="${dist}/${appName}-bin.zip" duplicate="preserve" update="true"> <zipgroupfileset dir="${dist}" includes="*.zip"/> </zip> <checksum file="${dist}/${appName}-bin.zip" forceOverwrite="true"/> <checksum file="${dist}/${appName}-bin.zip" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="zip-all" depends="zip-src,zip-bin" description="Zip the binary and source distributions"> <echo message="Zipped the binary and source distributions"/> </target> <target name="tar-docs" depends="docs" description="Tar the documentation"> <echo message="Tarring the documentation"/> <tar destfile="${dist}/${appName}-${package.docs}.tar.gz" compression="gzip"> <tarfileset dir="${docs.all.dir}"> <patternset refid="docs.all"/> </tarfileset> <tarfileset dir="${docs.misc.dir}"> <patternset refid="docs.misc"/> </tarfileset> </tar> <checksum file="${dist}/${appName}-${package.docs}.tar.gz" forceOverwrite="true"/> <checksum file="${dist}/${appName}-${package.docs}.tar.gz" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="tar-src" depends="tar-docs" description="Tar the documentation"> <echo message="Tarring the documentation"/> <tar destfile="${dist}/${appName}-src.tar.gz" compression="gzip"> <tarfileset dir="${docs.all.dir}"> <patternset refid="docs.all"/> </tarfileset> <tarfileset dir="${docs.misc.dir}"> <patternset refid="docs.misc"/> </tarfileset> <tarfileset dir="${src.files.dir}"> <patternset refid="src.files"/> </tarfileset> </tar> <checksum file="${dist}/${appName}-src.tar.gz" forceOverwrite="true"/> <checksum file="${dist}/${appName}-src.tar.gz" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="tar-bin-stand-alone" depends="package-stand-alone,tar-docs" description="Tar the binary stand-alone distribution with the documentation"> <echo message="Tarring the binary stand-alone distribution with the documentation"/> <tar destfile="${dist}/${appName}-${package.stand-alone}-bin.tar.gz" compression="gzip"> <tarfileset dir="${docs.all.dir}"> <patternset refid="docs.all"/> </tarfileset> <tarfileset dir="${docs.misc.dir}"> <patternset refid="docs.misc"/> </tarfileset> <tarfileset dir="${dist}" prefix="lib"> <patternset refid="bin.jar"/> </tarfileset> <tarfileset dir="."> <include name="${mysql.jar}"/> </tarfileset> </tar> <checksum file="${dist}/${appName}-${package.stand-alone}-bin.tar.gz" forceOverwrite="true"/> <checksum file="${dist}/${appName}-${package.stand-alone}-bin.tar.gz" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="tar-bin-web" depends="package-web,tar-docs" description="Tar the binary web distribution with the documentation"> <echo message="Tarring the binary web distribution with the documentation"/> <tar destfile="${dist}/${appName}-${package.web}-bin.tar.gz" compression="gzip"> <tarfileset dir="${docs.all.dir}"> <patternset refid="docs.all"/> </tarfileset> <tarfileset dir="${docs.misc.dir}"> <patternset refid="docs.misc"/> </tarfileset> <tarfileset dir="${dist}"> <patternset refid="bin.war"/> </tarfileset> </tar> <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" forceOverwrite="true"/> <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="tar-bin" depends="tar-bin-stand-alone,tar-bin-web" description="Tar the binary distribution with the documentation"> <echo message="Tarring the binary distribution with the documentation"/> <tar destfile="${dist}/${appName}-bin.tar.gz" compression="gzip"> <tarfileset dir="${docs.all.dir}"> <patternset refid="docs.all"/> </tarfileset> <tarfileset dir="${docs.misc.dir}"> <patternset refid="docs.misc"/> </tarfileset> <tarfileset dir="${src.files.dir}"> <patternset refid="src.files"/> </tarfileset> <tarfileset dir="${dist}" prefix="lib"> <patternset refid="bin.jar"/> </tarfileset> <tarfileset dir="."> <include name="${mysql.jar}"/> </tarfileset> <tarfileset dir="${dist}"> <patternset refid="bin.war"/> </tarfileset> </tar> <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true"/> <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="tar-bin-web-new" depends="package-web,tar-docs,zip-bin-web" description="Tar the binary web distribution with the documentation"> <echo message="Tarring the binary web distribution with the documentation"/> <unzip src="${dist}/${appName}-${package.web}-bin.zip" dest="${tmp}/web"/> <tar destfile="${dist}/${appName}-${package.web}-bin.tar.gz" compression="gzip"> <tarfileset dir="${tmp}/web"/> </tar> <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" forceOverwrite="true"/> <checksum file="${dist}/${appName}-${package.web}-bin.tar.gz" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="tar-bin-new" depends="zip-bin,tar-bin-stand-alone,tar-bin-web-new" description="Tar the binary distribution with the documentation"> <echo message="Tarring the binary distribution with the documentation"/> <delete failonerror="false" includeemptydirs="true"> <fileset dir="${tmp}" includes="**"/> </delete> <unzip src="${dist}/${appName}-bin.zip" dest="${tmp}"/> <tar destfile="${dist}/${appName}-bin.tar.gz" compression="gzip"> <tarfileset dir="${tmp}"/> </tar> <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true"/> <checksum file="${dist}/${appName}-bin.tar.gz" forceOverwrite="true" algorithm="SHA1"/> </target> <target name="tar-all" depends="tar-src,tar-bin" description="Tar the binary and source distributions"> <echo message="Tarred the binary and source distributions"/> </target>
<target name="ftp-docs" depends="zip-docs,tar-docs" description="Place the documentation on FTP"> <echo message="Placing the documentation on FTP"/> <ftp server="${ftp.server}" userid="${ftp.user}" password="${ftp.password}" remotedir="${ftp.src.dir}" action="send" newer="true" timediffauto="true"> <fileset dir="${dist}"> <include name="${appName}-${package.docs}.*"/> </fileset> </ftp> </target> <target name="ftp-src" depends="zip-src,tar-src" description="Place the source code on FTP"> <echo message="Placing the source code on FTP"/> <ftp server="${ftp.server}" userid="${ftp.user}" password="${ftp.password}" remotedir="${ftp.src.dir}" action="send" newer="true" timediffauto="true"> <fileset dir="${dist}"> <include name="${appName}-src.*"/> </fileset> </ftp> </target> <target name="ftp-bin" depends="zip-bin,tar-bin" description="Place the binaries on FTP"> <echo message="Placing the binaries on FTP"/> <ftp server="${ftp.server}" userid="${ftp.user}" password="${ftp.password}" remotedir="${ftp.bin.dir}" action="send" newer="true" timediffauto="true"> <fileset dir="${dist}"> <include name="${appName}*bin*"/> </fileset> </ftp> </target> <target name="ftp" description="Place everything on FTP"> <echo message="Placing everything on FTP"/> <antcall target="ftp-docs"/> <antcall target="ftp-src"/> <antcall target="ftp-bin"/> </target>
<target name="email-docs" depends="zip-docs,tar-docs" description="E-mailing the documentation"> <echo message="E-mailing the documentation"/> <mail from="${mail.from}" tolist="${mail.tolist}" mailhost="${mail.mailhost}" user="${mail.user}" password="${mail.password}" subject="${mail.subject}"> <message> ${mail.message.docs} </message> <fileset dir="${dist}"> <include name="${appName}-${package.docs}.*"/> </fileset> </mail> </target> <target name="deploy-copy-files" depends="copy-web" description="Deploy the application by copying it to Tomcat"> <echo message="Copying the expanded web application to CATALINA_HOME"/> <property environment="env"/> <copy todir="${build.web.web-inf}" file="${src.web.conf}/web.xml"/> <copy todir="${env.CATALINA_HOME}/webapps/${appName}"> <fileset dir="${build.web.root}"/> </copy> </target> <target name="deploy-copy-war" depends="package-web" description="Deploy the WAR by copying it to Tomcat"> <echo message="Copying the WAR to CATALINA_HOME"/> <property environment="env"/> <copy file="${appName.war}" todir="${env.CATALINA_HOME}/webapps"/> </target> <target name="deploy-context" depends="copy-web" description="Deploy the web application using a context XML file"> <echo message="Deploying the web application using a context XML file"/> <property environment="env"/> <copy todir="${build.web.web-inf}" file="${src.web.conf}/web.xml"/> <copy todir="${env.CATALINA_HOME}/conf/Catalina/localhost" file="${src.web.conf}/${appName}.xml"/> </target> <taskdef name="deploy" classname="org.apache.catalina.ant.DeployTask"/> <target name="deploy" depends="package-web" description="Hot deploy the application"> <echo message="Deploying the WAR to Tomcat"/> <deploy url="${manager.url}" username="${manager.user}" password="${manager.password}" path="/${appName}" war="file:${appName.war}" update="true"/> </target> <taskdef name="undeploy" classname="org.apache.catalina.ant.UndeployTask"/> <target name="undeploy" description="Undeploy the application"> <echo message="Undeploying the WAR"/> <undeploy url="${manager.url}" username="${manager.user}" password="${manager.password}" path="/${appName}"/> </target> <target name="clean" description="Clean up the working directories"> <echo message="Cleaning up"/> <delete dir="${build}"/> </target>
</project>
</source>