(file) Return to build.xml CVS log (file) (dir) Up to [Development] / infoglueCMS2

File: [Development] / infoglueCMS2 / build.xml (download) / (as text)
Revision: 1.2, Tue Nov 23 20:41:00 2004 UTC (5 years, 9 months ago) by jed
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +292 -293 lines
Added support for filter substitution of config files using build.properties as the fiters file
Added deploy target
Added testing targets.
Dependencies are defined in such a way as to take full advantage of ant's build in dependency checks.
Lots of other miscellaneous improvements.

<?xml version="1.0" encoding="ISO-8859-1"?>

<!-- Build file for infoglueCMS -->

<project name="infoglueCMS" default="clean-deploy" basedir=".">

	<!-- Give user a chance to override without editing this file
		  (and without typing -D each time they invoke a target) -->

	<property file="${user.home}/build.properties"/>
	<property file="${user.home}/.build.properties"/>
	<property file="build.properties"/>

	<!-- Generic project properties -->

	<property name="project.fullname" value="InfoGlue content management system"/>

	<!-- =================================================================== -->
	<!-- Set the properties related to the source tree                       -->
	<!-- =================================================================== -->
	<property name="src.dir" value="src"/>
	<property name="webapp.dir" value="webapps"/>
	<property name="opentree.dir" value="${webapp.dir}/applications/OpenTree"/>
	<property name="templateeditor.dir" value="${webapp.dir}/applications/InfoGlueCodeEditor"/>

	<!-- =================================================================== -->
	<!-- Set the properties related to the build area                        -->
	<!-- Destination locations for the build (relative to the basedir as     -->
	<!-- specified in the 'basedir' attribute of the project tag)            -->
	<!-- =================================================================== -->
	<property name="build.dir" value="build"/>
	<property name="build.dest.dir" value="${build.dir}/classes"/>
	<property name="lib.dir" value="${webapp.dir}/WEB-INF/lib"/>
	<property name="dist.dir" value="dist"/>
	<property name="javadocs.destdir" value="docs/api"/>
	<property name="war.file" value="${dist.dir}/${ant.project.name}.war"/>

	<!-- properties related to unit testing -->
	<property name="src.test" value="test"/>
	<property name="build.test" value="${build.dir}/test-classes"/>
	<property name="testdocs.dir" value="docs/junit"/>

	<!-- Miscellaneous settings -->
	<property name="year" value="2003"/>
	<property name="locale.default" value="en"/>
	<property name="ant.home" value="build"/>
	<property name="debug" value="on"/>
	<property name="optimize" value="off"/>
	<property name="deprecation" value="off"/>

	<!-- =================================================================== -->
	<!-- filesets, filtersets, patternsets, etc.                             -->
	<!-- =================================================================== -->
	<filterset id="project.filters">
		<filtersfile file="build.properties"/>
	</filterset>

	<!-- =================================================================== -->
	<!-- Build Classpath                                                     -->
	<!-- =================================================================== -->
	<path id="classpath">
		<fileset dir="${lib.dir}">
			<!-- Everything in the project's lib dir -->
			<include name="*.jar"/>
		</fileset>
	</path>

	<!-- =================================================================== -->
	<!-- Test Classpath                                                      -->
	<!-- =================================================================== -->
	<path id="test.classpath">
		<pathelement location="${build.dest.dir}"/>
		<pathelement location="${build.test}"/>
		<path refid="classpath"/>
	</path>

	<!-- =================================================================== -->
	<!-- Build Sourcepath                                                    -->
	<!-- =================================================================== -->
	<path id="sourcepath">
		<pathelement location="${src.dir}/"/>
		<pathelement location="${opentree.dir}/"/>
		<pathelement location="${templateeditor.dir}"/>
	</path>

	<!-- =================================================================== -->
	<!-- Initializes the build.                                              -->
	<!-- =================================================================== -->
	<target name="init">
		<tstamp/>
		<mkdir dir="${build.dir}"/>
		<mkdir dir="${build.dest.dir}"/>
		<mkdir dir="${build.test}"/>
		<mkdir dir="${dist.dir}"/>
	</target>

	<!-- ================================================================== -->
	<!-- Displays usage information                                         -->
	<!-- ================================================================== -->
	<target name="usage" description="Displays usage information">
		<echo message="Use -projecthelp to see the available targets"/>
	</target>

	<!-- ================================================================== -->
	<!-- creates infoglueCMS jar                                            -->
	<!-- ================================================================== -->
	<target name="jar" depends="compile">
		<jar destfile="${dist.dir}/${ant.project.name}${project.version}.jar"
					basedir="${build.dest.dir}">
			<exclude name="*.dtd"/>
			<exclude name="*.properties"/>
			<exclude name="*.xml"/>
		</jar>
	</target>

	<!-- =================================================================== -->
	<!-- Compiles java sources of this project                               -->
	<!-- =================================================================== -->
	<target name="compile" depends="init">
		<javac destdir="${build.dest.dir}" classpathref="classpath"
			debug="${debug}" deprecation="${deprecation}"
			optimize="${optimize}" encoding="iso-8859-1">
			<src refid="sourcepath"/>
		</javac>

		<!-- Copy non java files that need to be in the classes directory -->
		<copy todir="${build.dest.dir}">
			<fileset dir="${src.dir}">
				<include name="*.HTML"/>
				<include name="**/*.vm"/>
				<include name="**/*.properties"/>
				<include name="**/*.xml"/>
				<include name="**/*.dtd"/>
			</fileset>
			<filterset refid="project.filters"/>
		</copy>

		<!-- Copy plugin classes to the webapps directory -->
		<copy todir="${templateeditor.dir}/netscape/javascript">
			<fileset dir="${build.dest.dir}/netscape/javascript">
				<include name="**/*.class"/>
			</fileset>
		</copy>
		<copy todir="${templateeditor.dir}/org/infoglue/cms/plugins/codeeditor">
			<fileset dir="${build.dest.dir}/org/infoglue/cms/plugins/codeeditor">
				<include name="**/*.class"/>
			</fileset>
		</copy>
		<copy todir="${opentree.dir}/org/infoglue/cms/net">
			<fileset dir="${build.dest.dir}/org/infoglue/cms/net">
				<include name="**/*.class"/>
			</fileset>
		</copy>
		<copy todir="${opentree.dir}/org/infoglue/cms/plugins/opentree">
			<fileset dir="${build.dest.dir}/org/infoglue/cms/plugins/opentree">
				<include name="**/*.class"/>
			</fileset>
		</copy>
	</target>
	<!-- End of compile -->

	<!-- =================================================================== -->
	<!-- Creates the war file                                                -->
	<!-- =================================================================== -->
	<target name="war" depends="jar" description="Creates the war file">
		<war warfile="${war.file}" webxml="${webapp.dir}/WEB-INF/web.xml">
			<classes dir="${build.dest.dir}"/>
			<fileset dir="${webapp.dir}">
				<exclude name="WEB-INF/web.xml"/>
				<exclude name="**/*.java"/>
				<exclude name="xercesImpl.jar"/>
				<exclude name="xml-apis.jar"/>
			</fileset>
		</war>
	</target>
	<!-- End of war -->

	<!-- =================================================================== -->
	<!-- Deploys after a full build from scratch                             -->
	<!-- =================================================================== -->
	<target name="clean-deploy" depends="clean,deploy"/>

	<!-- =================================================================== -->
	<!-- Deploys the app                                                     -->
	<!-- =================================================================== -->
	<target name="deploy" depends="war" description="Unpacks war to deploy dir">
		<unwar src="${war.file}" dest="${deploy.dir}"/>
	</target>

	<!-- =================================================================== -->
	<!-- Cleans up the distribution                                          -->
	<!-- =================================================================== -->
	<target name="clean">
		<delete dir="${build.dir}" quiet="true"/>
		<delete dir="${dist.dir}" quiet="true"/>
	</target>

	<!-- =================================================================== -->
	<!--Fetches the latest code from cvs                                     -->
	<!-- =================================================================== -->
	<target name="fetchCMS" description="Get updates from cvs for this module">
		<cvs command="update -P -d" cvsRoot=":pserver:anonymous@www.infoglue.org:2401/home/cvsroot"/>
	</target>

	<!-- =================================================================== -->
	<!-- Generates the project's API documentation                           -->
	<!-- =================================================================== -->
	<target name="javadocs" depends="compile" >
		<javadoc sourcepathref="sourcepath" destdir="${javadocs.destdir}"
					packagenames="org.*" author="true" private="false" version="true"
					use="true" windowtitle="${project.fullname} API - ${project.version}"
					doctitle="${project.fullname} - ${project.version}"
					bottom="Copyright &#169; ${year} InfoGlue.org All Rights Reserved.">
			<classpath refid="classpath"/>
		</javadoc>
		<zip destfile="${javadocs.destdir}/${ant.project.name}${project.version}API.zip">
			<zipfileset dir="${javadocs.destdir}" excludes="*.zip" prefix="${ant.project.name}API"/>
		</zip>
	</target>

	<!-- =================================================================== -->
	<!--Execute All major targets                                            -->
	<!-- =================================================================== -->
	<target name="all" depends="fetchCMS,clean-deploy,javadocs"/>

	<!-- =================================================================== -->
	<!-- Compiles test classes                                               -->
	<!-- =================================================================== -->
	<target name="test-compile" depends="compile">
		<javac srcdir="${src.test}" destdir="${build.test}" classpath="${build.dest.dir}" classpathref="classpath" debug="on"/>
	</target>

	<!-- =================================================================== -->
	<!-- Runs all the tests.  Requires junit.jar to be in the Ant lib        -->
	<!-- directory, otherwise the JUnit task will not be able to find the    -->
	<!-- JUnit classes.                                                      -->
	<!-- =================================================================== -->
	<target name="all-tests" depends="test-compile">
		<taskdef name="junit" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"/>
		<mkdir dir="${testdocs.dir}"/>
		<junit printsummary="yes" haltonfailure="yes" haltonerror="yes" fork="yes">
			<classpath>
				<pathelement location="${build.test}"/>
				<pathelement location="${build.dest.dir}"/>
				<path refid="test.classpath"/>
			</classpath>
			<sysproperty key="webapp.dir" value="${basedir}/${webapp.dir}"/>
			<formatter type="xml"/>
			<formatter type="brief" usefile="false"/>
			<batchtest todir="${testdocs.dir}">
				<fileset dir="${src.test}">
					<exclude name="**/Abstract*.java"/>
					<include name="**/*Test.java"/>
				</fileset>
			</batchtest>
		</junit>
	</target>

	<!-- =================================================================== -->
	<!-- Runs a particular test using the text test runner.  Requires        -->
	<!-- junit.jar to be in the Ant lib directory, otherwise the JUnit task  -->
	<!-- will not be able to find the JUnit classes.                         -->
	<!-- =================================================================== -->
	<target name="test" depends="test-compile">
		<fail unless="test.class">Property test.class was not set. Usage: ant -Dtest.class=package.to.some.TestClass test</fail>
		<taskdef name="junit" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"/>
		<mkdir dir="${testdocs.dir}"/>
		<junit printsummary="yes" haltonfailure="yes" haltonerror="yes" fork="yes">
			<classpath refid="test.classpath"/>
			<sysproperty key="webapp.dir" value="${basedir}/${webapp.dir}"/>
			<formatter type="xml"/>
			<formatter type="brief" usefile="false"/>
			<test name="${test.class}"/>
		</junit>
	</target>

	<!-- =================================================================== -->
	<!-- Runs a particular test using the Swing test runner.  Requires       -->
	<!-- junit.jar to be in the Ant lib directory, otherwise the JUnit task  -->
	<!-- will not be able to find the JUnit classes.                         -->
	<!-- =================================================================== -->
	<target name="test-swing" depends="test-compile">
		<fail unless="test.class">Property test.class was not set. Usage: ant -Dtest.class=package.to.some.TestClass test</fail>
		<java classname="${test.class}" classpathref="test.classpath" fork="true">
			<jvmarg line="-enableassertions"/>
		</java>
	</target>

	<!-- ===================================================================
	 * Jars up some of the the test classes for reuse in the deliver
	 *	project.
	 * ===================================================================== -->
	<target name="jar-test" depends="test-compile">
		<jar destfile="${dist.dir}/${ant.project.name}${project.version}-test.jar"
					basedir="${build.test}">
			<include name="org/infoglue/cms/util/*.class"/>
		</jar>
	</target>
</project>

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2