| <?xml version="1.0" encoding="ISO-8859-1"?> |
| |
| <!-- |
| Licensed to the Apache Software Foundation (ASF) under one |
| or more contributor license agreements. See the NOTICE file |
| distributed with this work for additional information |
| regarding copyright ownership. The ASF licenses this file |
| to you under the Apache License, Version 2.0 (the |
| "License"); you may not use this file except in compliance |
| with the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, |
| software distributed under the License is distributed on an |
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| KIND, either express or implied. See the License for the |
| specific language governing permissions and limitations |
| under the License. |
| --> |
| |
| <project name="velocity-tools" default="all" basedir="."> |
| |
| <!-- ========== Properties ===================================== --> |
| |
| <!-- Give user a chance to override without editing this file |
| (and without typing -D each time it compiles it --> |
| <property file="${user.home}/.ant.properties" /> |
| <property file="${user.home}/build.properties" /> |
| <property file=".ant.properties" /> |
| |
| <!-- This file contains all the defaults for building VelocityTools --> |
| <property file="build.properties"/> <!-- Component local --> |
| |
| |
| |
| <!-- ========== Targets ======================================== --> |
| |
| |
| <!-- Main Target --> |
| <target name="all" depends="clean,jar.struts,examples,javadoc,docs,env" |
| description="Clean and build velocity-tools library, examples, and documentation."/> |
| |
| |
| <!-- Environment Target --> |
| <target name="env" description="Prints build parameters"> |
| <echo> |
| Global settings: |
| java.home = ${java.home} |
| user.home = ${user.home} |
| java.class.path = ${java.class.path} |
| |
| Project settings: |
| Version: ${project.id} |
| Debug: ${compile.debug} |
| Optimize: ${compile.optimize} |
| Deprecation: ${compile.deprecation} |
| Encoding: ${compile.encoding} |
| |
| Build settings: |
| Source Files: ${source.home} |
| Build Files: ${build.dir} |
| Distribution Files: ${dist.dir} |
| </echo> |
| </target> |
| |
| |
| <!-- Clean Target --> |
| <target name="clean" description="Deletes the build, dist and docs directories"> |
| <delete dir="${build.dir}"/> |
| <delete dir="${dist.dir}"/> |
| <delete dir="${docs.dir}"/> |
| |
| <!-- Clean example applications --> |
| <ant antfile="${basedir}/examples.xml" target="clean-examples" /> |
| |
| <!-- Clean tests --> |
| <ant antfile="${basedir}/test.xml" target="test.clean"/> |
| |
| </target> |
| |
| <!-- To do a truly, completely clean build, include this target --> |
| <target name="clean.lib" |
| description="Deletes the folder of downloaded dependencies"> |
| <delete dir="${lib.dir}"/> |
| <ant antfile="${basedir}/test.xml" target="test.clean.lib"/> |
| </target> |
| |
| |
| <!-- Prepare Environment --> |
| <target name="prepare" depends="prepare.compile,prepare.docs,prepare.examples"> |
| <echo message="-------- ${project.name} ${project.version} --------"/> |
| </target> |
| |
| <!-- Prepare Compilation Environment --> |
| <target name="prepare.compile"> |
| <!-- make necessary directories --> |
| <mkdir dir="${build.dir}"/> |
| <mkdir dir="${lib.dir}" /> |
| <mkdir dir="${classes.dir}"/> |
| <mkdir dir="${dist.dir}"/> |
| |
| <!-- download dependency jars --> |
| <ant antfile="${basedir}/download.xml" target="compile-download" /> |
| |
| <!-- construct classpath of all jars in lib repository --> |
| <path id="compile.classpath"> |
| <fileset dir="${lib.dir}"> |
| <include name="**/*.jar"/> |
| </fileset> |
| </path> |
| </target> |
| |
| <!-- Prepare Documentation Environment --> |
| <target name="prepare.docs"> |
| <!-- make necessary directories --> |
| <mkdir dir="${lib.dir}" /> |
| |
| <!-- download dependency jars --> |
| <ant antfile="${basedir}/download.xml" target="docs-download" /> |
| |
| <!-- construct classpath of all jars needed to build docs --> |
| <path id="docs.classpath"> |
| <fileset dir="${lib.dir}"> |
| <include name="**/*.jar"/> |
| </fileset> |
| </path> |
| </target> |
| |
| <!-- Prepare Examples Environment --> |
| <target name="prepare.examples"> |
| <!-- download dependency jars --> |
| <ant antfile="${basedir}/download.xml" target="examples-download" /> |
| </target> |
| |
| |
| <!-- Compile VelocityTools (all of it) --> |
| <target name="compile" depends="compile.struts" |
| description="Compiles the Velocity-Tools project (struts, view and generic)"/> |
| |
| <!-- Compile VelocityStruts (struts, view, generic) --> |
| <target name="compile.struts" depends="prepare.compile" |
| description="Compiles the Velocity-Tools project (struts, view, and generic)"> |
| <javac srcdir="${classes.src}" |
| debug="${compile.debug}" |
| optimize="${compile.optimize}" |
| source="${compile.source}" |
| target="${compile.target}" |
| deprecation="${compile.deprecation}" |
| encoding="${compile.encoding}" |
| destdir="${classes.dir}"> |
| <classpath refid="compile.classpath" /> |
| <include name="org/**"/> |
| </javac> |
| |
| <copy todir="${classes.dir}" filtering="yes"> |
| <fileset dir="${classes.src}"> |
| <include name="**/*.properties"/> |
| </fileset> |
| </copy> |
| </target> |
| |
| <!-- Compile Just VelocityView (view, generic) --> |
| <target name="compile.view" depends="prepare.compile" |
| description="Compiles VelocityView and the generic tools"> |
| <javac srcdir="${classes.src}" |
| debug="${compile.debug}" |
| optimize="${compile.optimize}" |
| source="${compile.source}" |
| target="${compile.target}" |
| deprecation="${compile.deprecation}" |
| encoding="${compile.encoding}" |
| destdir="${classes.dir}"> |
| <classpath refid="compile.classpath" /> |
| <include name="org/**"/> |
| <exclude name="**/struts/**"/> |
| </javac> |
| |
| <copy todir="${classes.dir}" filtering="yes"> |
| <fileset dir="${classes.src}"> |
| <include name="**/*.properties"/> |
| </fileset> |
| </copy> |
| </target> |
| |
| <!-- Compile Just Generic Tools (generic) --> |
| <target name="compile.generic" depends="prepare.compile" |
| description="Compiles just the generic tools in this project"> |
| <javac srcdir="${classes.src}" |
| debug="${compile.debug}" |
| optimize="${compile.optimize}" |
| source="${compile.source}" |
| target="${compile.target}" |
| deprecation="${compile.deprecation}" |
| encoding="${compile.encoding}" |
| destdir="${classes.dir}"> |
| <classpath refid="compile.classpath" /> |
| <include name="org/**"/> |
| <exclude name="**/struts/**"/> |
| <exclude name="**/view/**"/> |
| </javac> |
| </target> |
| |
| |
| |
| <!-- Jar VelocityTools (struts, view, generic) --> |
| <target name="jar" depends="jar.struts" |
| description="Creates a velocity-tools jar in the dist directory."/> |
| |
| <!-- Jar VelocityStruts (struts, view, generic) --> |
| <target name="jar.struts" depends="compile.struts" |
| description="Creates a velocity-tools jar in the dist directory."> |
| <jar jarfile="${dist.dir}/${struts.id}.jar"> |
| <fileset dir="${classes.dir}"/> |
| <metainf dir="${basedir}"> |
| <include name="LICENSE"/> |
| <include name="NOTICE"/> |
| </metainf> |
| <manifest> |
| <attribute name="Created-By" value="Apache Ant"/> |
| <attribute name="Package" value="org.apache.velocity.tools"/> |
| <attribute name="Build-Jdk" value="${java.version}"/> |
| <attribute name="Extension-Name" value="${struts.libname}"/> |
| <attribute name="Specification-Title" value="${struts.name} is ${struts.description}" /> |
| <attribute name="Specification-Vendor" value="Apache Software Foundation"/> |
| <attribute name="Implementation-Title" value="org.apache.velocity"/> |
| <attribute name="Implementation-Vendor-Id" value="org.apache"/> |
| <attribute name="Implementation-Vendor" value="Apache Software Foundation"/> |
| <attribute name="Implementation-Version" value="${project.version}"/> |
| </manifest> |
| </jar> |
| <checksum file="${dist.dir}/${struts.id}.jar" algorithm="md5" fileext=".md5"/> |
| <checksum file="${dist.dir}/${struts.id}.jar" algorithm="sha1" fileext=".sha1"/> |
| </target> |
| |
| <!-- Jar Just VelocityView (view, generic) --> |
| <target name="jar.view" depends="compile.view" |
| description="Creates a velocity-tools-view jar in the dist directory"> |
| <jar jarfile="${dist.dir}/${view.id}.jar"> |
| <fileset dir="${classes.dir}"> |
| <exclude name="**/struts/**"/> |
| </fileset> |
| <metainf dir="${basedir}"> |
| <include name="LICENSE"/> |
| <include name="NOTICE"/> |
| </metainf> |
| <manifest> |
| <attribute name="Created-By" value="Apache Ant"/> |
| <attribute name="Package" value="org.apache.velocity.tools"/> |
| <attribute name="Build-Jdk" value="${java.version}"/> |
| <attribute name="Extension-Name" value="${view.libname}"/> |
| <attribute name="Specification-Title" value="${view.name} is ${view.description}" /> |
| <attribute name="Specification-Vendor" value="Apache Software Foundation"/> |
| <attribute name="Implementation-Title" value="org.apache.velocity"/> |
| <attribute name="Implementation-Vendor-Id" value="org.apache"/> |
| <attribute name="Implementation-Vendor" value="Apache Software Foundation"/> |
| <attribute name="Implementation-Version" value="${project.version}"/> |
| </manifest> |
| </jar> |
| <checksum file="${dist.dir}/${view.id}.jar" algorithm="md5" fileext=".md5"/> |
| <checksum file="${dist.dir}/${view.id}.jar" algorithm="sha1" fileext=".sha1"/> |
| </target> |
| |
| <!-- Jar Just Generic Tools (generic) --> |
| <target name="jar.generic" depends="compile.generic" |
| description="Creates a velocity-tools-generic jar in the dist directory"> |
| <jar jarfile="${dist.dir}/${generic.id}.jar"> |
| <fileset dir="${classes.dir}"> |
| <exclude name="**/struts/**"/> |
| <exclude name="**/view/**"/> |
| </fileset> |
| <metainf dir="${basedir}"> |
| <include name="LICENSE"/> |
| <include name="NOTICE"/> |
| </metainf> |
| <manifest> |
| <attribute name="Created-By" value="Apache Ant"/> |
| <attribute name="Package" value="org.apache.velocity.tools.generic"/> |
| <attribute name="Build-Jdk" value="${java.version}"/> |
| <attribute name="Extension-Name" value="${generic.libname}"/> |
| <attribute name="Specification-Title" value="${generic.name} is ${generic.description}" /> |
| <attribute name="Specification-Vendor" value="Apache Software Foundation"/> |
| <attribute name="Implementation-Title" value="org.apache.velocity.tools"/> |
| <attribute name="Implementation-Vendor-Id" value="org.apache"/> |
| <attribute name="Implementation-Vendor" value="Apache Software Foundation"/> |
| <attribute name="Implementation-Version" value="${project.version}"/> |
| </manifest> |
| </jar> |
| <checksum file="${dist.dir}/${generic.id}.jar" algorithm="md5" fileext=".md5"/> |
| <checksum file="${dist.dir}/${generic.id}.jar" algorithm="sha1" fileext=".sha1"/> |
| </target> |
| |
| |
| |
| <!-- Build Javadocs (struts, view, generic) --> |
| <target name="javadoc" description="Builds Javadoc for the whole project."> |
| <mkdir dir="${javadoc.dir}" /> |
| <javadoc packagenames="org.apache.velocity.tools.*" |
| destdir="${docs.dir}/javadoc" |
| author="true" |
| private="true" |
| version="true" |
| doctitle="<h1>${javadoc.title}</h1>" |
| windowtitle="${javadoc.title}" |
| bottom="Copyright (c) ${javadoc.year} Apache Software Foundation" > |
| |
| <classpath refid="compile.classpath"/> |
| <sourcepath> |
| <pathelement path="${classes.src}" /> |
| </sourcepath> |
| </javadoc> |
| </target> |
| |
| |
| |
| <!-- Build Velocity-Tools documentation --> |
| <target name="docs" depends="prepare.docs" |
| description="Generate documentation into ${docs.dir}"> |
| <taskdef name="dvsl" classname="org.apache.dvsl.DVSLTask"> |
| <classpath refid="docs.classpath"/> |
| </taskdef> |
| |
| <dvsl basedir="${docs.src}" |
| destdir="${docs.dir}/" |
| toolboxfile="${docs.src}/toolbox.props" |
| extension=".html" |
| style="${docs.src}/site.dvsl" |
| excludes="**/*menu.xml" |
| includes="**/*.xml" /> |
| |
| <copy todir="${docs.dir}/images"> |
| <fileset dir="${docs.src}/images"> |
| <include name="*.png" /> |
| </fileset> |
| </copy> |
| </target> |
| |
| |
| <!-- Make documentation tar ball --> |
| <target name="tardocs" depends="javadoc,docs" |
| description="Combine all xdocs and docs into a tar ball."> |
| |
| <!-- make sure the dist directory exists --> |
| <mkdir dir="${dist.dir}" /> |
| <tar destfile="${dist.dir}/docs.tar.gz" |
| basedir="${basedir}" |
| includes="docs/**,xdocs/**" |
| compression="gzip" /> |
| </target> |
| |
| |
| <!-- Build all example applications --> |
| <target name="examples" depends="jar.view,jar.struts,prepare.examples" |
| description="Compiles and jars all example applications."> |
| <ant antfile="${basedir}/examples.xml" target="build-examples" /> |
| </target> |
| |
| <!-- Build VelocityView - Simple application --> |
| <target name="simple" depends="jar.view,prepare.examples" |
| description="Compiles and jars the VelocityView example application."> |
| <property name="target" value="war"/> |
| <ant antfile="${basedir}/examples.xml" target="simple-example" /> |
| </target> |
| |
| <!-- Build VelocityView - Showcase application --> |
| <target name="showcase" depends="jar.view,prepare.examples" |
| description="Compiles and jars the VelocityView Showcase example application."> |
| <property name="target" value="war"/> |
| <ant antfile="${basedir}/examples.xml" target="showcase-example" /> |
| </target> |
| |
| <!-- Let the user start Jetty on his local box --> |
| <target name="start.showcase.webapp" description="Launches the Showcase example application using Jetty (uses http://localhost:8081 by default)"> |
| <ant antfile="${basedir}/test.xml" target="start-showcase-webapp"/> |
| </target> |
| |
| <!-- Let the user stop Jetty --> |
| <target name="stop.showcase.webapp" description=""> |
| <ant antfile="${basedir}/test.xml" target="stop-showcase-webapp"/> |
| </target> |
| |
| <!-- Build VelocityStruts example application --> |
| <target name="struts" depends="jar.struts,prepare.examples" |
| description="Compiles and jars the VelocityStruts example application."> |
| <property name="target" value="war"/> |
| <ant antfile="${basedir}/examples.xml" target="struts-example" /> |
| </target> |
| |
| |
| |
| <!-- Convenient target for rolling releases --> |
| <target name="release" |
| depends="release.source,release.binaries,env" |
| description="Creates binary and source distribution files"/> |
| |
| <!-- Create source distribution files --> |
| <target name="release.source" |
| depends="clean" |
| description="Cleans everything and creates source distribution files"> |
| |
| <mkdir dir="${dist.dir}"/> |
| <zip zipfile="${dist.dir}/${project.id}-src.zip"> |
| <zipfileset dir="${basedir}" prefix="${project.id}-src"> |
| <include name="*"/> |
| <include name="examples/**"/> |
| <include name="src/**"/> |
| <include name="xdocs/**"/> |
| <include name="test/etc/**"/> |
| <include name="test/conf/**"/> |
| </zipfileset> |
| </zip> |
| <tar tarfile="${dist.dir}/${project.id}-src.tar" longfile="gnu"> |
| <tarfileset dir="${basedir}" prefix="${project.id}-src"> |
| <include name="*"/> |
| <include name="examples/**"/> |
| <include name="src/**"/> |
| <include name="xdocs/**"/> |
| <include name="test/etc/**"/> |
| <include name="test/conf/**"/> |
| </tarfileset> |
| </tar> |
| <gzip zipfile="${dist.dir}/${project.id}-src.tar.gz" |
| src="${dist.dir}/${project.id}-src.tar"/> |
| |
| <!-- Create checksums for the binary distribution files --> |
| <checksum file="${dist.dir}/${project.id}-src.zip" algorithm="md5" fileext=".md5"/> |
| <checksum file="${dist.dir}/${project.id}-src.zip" algorithm="sha1" fileext=".sha1"/> |
| <checksum file="${dist.dir}/${project.id}-src.tar.gz" algorithm="md5" fileext=".md5"/> |
| <checksum file="${dist.dir}/${project.id}-src.tar.gz" algorithm="sha1" fileext=".sha1"/> |
| </target> |
| |
| <!-- Create binary distribution files --> |
| <target name="release.binaries" |
| depends="clean,prepare,jar.struts,jar.view,jar.generic,examples,javadoc,docs,test" |
| description="Builds everything and creates the binary distribution files"> |
| |
| <!-- Gather misc docs/files --> |
| <mkdir dir="${release.dir}"/> |
| <copy todir="${release.dir}" file="${basedir}/CONTRIBUTORS"/> |
| <copy todir="${release.dir}" file="${basedir}/LICENSE"/> |
| <copy todir="${release.dir}" file="${basedir}/NOTICE"/> |
| <copy todir="${release.dir}" file="${basedir}/STATUS"/> |
| <copy todir="${release.dir}" file="${basedir}/README.txt"/> |
| <copy todir="${release.dir}" file="${basedir}/WHY_THREE_JARS.txt"/> |
| |
| <!-- Gather all project jars --> |
| <mkdir dir="${release.dir}/lib"/> |
| <copy todir="${release.dir}/lib"> |
| <fileset dir="${dist.dir}" includes="*.jar" /> |
| </copy> |
| |
| <!-- Gather all project dependencies --> |
| <copy todir="${release.dir}/lib"> |
| <fileset dir="${lib.dir}" includes="*.jar"/> |
| </copy> |
| |
| <!-- Gather example war files --> |
| <mkdir dir="${release.dir}/examples"/> |
| <copy todir="${release.dir}/examples"> |
| <fileset dir="${examples.home}"> |
| <include name="*.war" /> |
| </fileset> |
| </copy> |
| |
| <!-- Gather all generated documentation --> |
| <mkdir dir="${release.dir}/docs"/> |
| <copy todir="${release.dir}/docs"> |
| <fileset dir="${docs.dir}"> |
| <include name="**" /> |
| </fileset> |
| </copy> |
| |
| <!-- Create binary distribution files --> |
| <zip zipfile="${dist.dir}/${project.id}.zip" |
| basedir="${dist.dir}/release"/> |
| <tar tarfile="${dist.dir}/${project.id}.tar" longfile="gnu" |
| basedir="${dist.dir}/release"/> |
| <gzip zipfile="${dist.dir}/${project.id}.tar.gz" |
| src="${dist.dir}/${project.id}.tar"/> |
| |
| <!-- Create checksums for the binary distribution files --> |
| <checksum file="${dist.dir}/${project.id}.zip" algorithm="md5" fileext=".md5"/> |
| <checksum file="${dist.dir}/${project.id}.zip" algorithm="sha1" fileext=".sha1"/> |
| <checksum file="${dist.dir}/${project.id}.tar.gz" algorithm="md5" fileext=".md5"/> |
| <checksum file="${dist.dir}/${project.id}.tar.gz" algorithm="sha1" fileext=".sha1"/> |
| |
| <!-- Delete TAR files and staging dir as they're no longer needed --> |
| <delete> |
| <fileset dir="${dist.dir}" includes="*.tar"/> |
| <fileset dir="${dist.dir}/release"/> |
| </delete> |
| </target> |
| |
| |
| <!-- ========== Publish Targets ======================================== --> |
| |
| <target name="publish.check"> |
| <condition property="release.signed"> |
| <and> |
| <available file="${dist.dir}/${project.id}.tar.gz.asc"/> |
| <available file="${dist.dir}/${project.id}.zip.asc"/> |
| <available file="${dist.dir}/${project.id}-src.tar.gz.asc"/> |
| <available file="${dist.dir}/${project.id}-src.zip.asc"/> |
| <available file="${dist.dir}/${project.id}.jar.asc"/> |
| <available file="${dist.dir}/${view.id}.jar.asc"/> |
| <available file="${dist.dir}/${generic.id}.jar.asc"/> |
| </and> |
| </condition> |
| </target> |
| |
| <target name="publish.sigs" unless="release.signed" |
| depends="publish.check"> |
| <echo> |
| You must first execute "release" target, then sign the distribution |
| files with your pgp key (creating the needed '.asc'signature files). |
| You may also need to add the Jsch jar to Ant's classpath to enable the |
| optional 'scp' task. |
| </echo> |
| </target> |
| |
| <target name="publish.user" unless="username"> |
| <input message="Type your username and hit enter:" addproperty="username"/> |
| </target> |
| |
| <target name="publish.pass" unless="password"> |
| <input message="Type your password and hit enter:" addproperty="password"/> |
| </target> |
| |
| <target name="publish.auth" |
| depends="publish.user,publish.pass"> |
| <condition property="have.auth"> |
| <and> |
| <isset property="username"/> |
| <isset property="password"/> |
| </and> |
| </condition> |
| </target> |
| |
| <target name="prepare.publish" |
| depends="publish.sigs,publish.auth"> |
| <condition property="ready"> |
| <and> |
| <isset property="release.signed"/> |
| <isset property="have.auth"/> |
| </and> |
| </condition> |
| </target> |
| |
| <target name="publish" depends="prepare.publish" if="ready" |
| description="Uploads distribution files to the distribution server"> |
| <echo> |
| Uploading distribution files from |
| ${dist.dir} |
| to |
| ${username}:${password}@${publish.server}:${publish.dir} |
| </echo> |
| <scp todir="${username}:${password}@${publish.server}:${publish.dir}" |
| verbose="true" failonerror="true" trust="yes"> |
| <fileset dir="${dist.dir}"/> |
| </scp> |
| </target> |
| |
| <target name="publish.docs" depends="docs,publish.auth" if="have.auth" |
| description="Updates development documentation on the website"> |
| <zip zipfile="${dist.dir}/docs.zip" |
| basedir="${docs.dir}"/> |
| <echo> |
| Zips documentation files from |
| ${docs.dir} |
| and uploads them to |
| ${username}:${password}@${publish.server}:${publish.docs.dir} |
| </echo> |
| <scp todir="${username}:${password}@${publish.server}:${publish.docs.dir}" |
| verbose="true" failonerror="true" trust="yes"> |
| <fileset dir="${dist.dir}"> |
| <include name="docs.zip"/> |
| </fileset> |
| </scp> |
| </target> |
| |
| |
| <!-- ========== Test Targets ======================================== --> |
| |
| <!-- Main test target --> |
| <target name="test" description="Test VelocityTools" depends="test.generic,test.view"> |
| </target> |
| |
| <!-- Generic tests --> |
| <target name="test.generic" description="Test GenericTools" depends="jar.view"> |
| <ant antfile="${basedir}/test.xml" target="test.generic" /> |
| </target> |
| |
| <!-- View tests --> |
| <target name="test.view" description="Test VelocityView" depends="jar.view"> |
| <ant antfile="${basedir}/test.xml" target="test.view" /> |
| </target> |
| |
| <!-- View tests --> |
| <target name="test.stop" description="Stop VelocityView Test"> |
| <ant antfile="${basedir}/test.xml" target="stop-showcase-webapp" /> |
| </target> |
| |
| </project> |