<project name="xoosent" xmlns:ivy="antlib:org.apache.ivy.ant">
<property environment="env"/>
<property file="version.properties"/>
<property file="build.properties"/>
<!-- dependency management -->
<condition property="ivy.home" value="${env.IVY_HOME}">
<isset property="env.IVY_HOME" />
</condition>
<property name="ivy.home" value="${user.home}/.ivy" />
<property name="ivy.jar.dir" value="${ivy.home}/jars" />
<property name="ivy.jar.file" value="${ivy.jar.dir}/ivy.jar" />
<target name="init-ivy">
<!-- try to load ivy here from local ivy dir, in case the user has not already dropped
it into ant's lib dir (note that the latter copy will always take precedence).
We will not fail as long as local lib dir exists (it may be empty) and
ivy is in at least one of ant's lib dir or the local lib dir. -->
<path id="ivy.lib.path">
<fileset dir="${ivy.jar.dir}" includes="*.jar"/>
</path>
<taskdef resource="org/apache/ivy/ant/antlib.xml"
uri="antlib:org.apache.ivy.ant" classpathref="ivy.lib.path"/>
<ivy:configure file="${basedir}/src/build/ivy/ivysettings.xml" />
</target>
<target name="resolve" depends="init-ivy" unless="no.resolve">
<ivy:resolve />
<ivy:retrieve conf="default,test" pattern="${lib.dir}/[conf]/[artifact].[ext]" sync="true" />
</target>
<target name="init-path">
<path id="compile.classpath">
<fileset dir="${lib.dir}/default">
<include name="*.jar"/>
</fileset>
</path>
<path id="run.classpath">
<path refid="compile.classpath"/>
<pathelement location="${target.main.classes.dir}"/>
</path>
<path id="compile.test.classpath">
<fileset dir="${lib.dir}/test">
<include name="*.jar"/>
</fileset>
<path refid="run.classpath"/>
</path>
<path id="test.classpath">
<path refid="compile.test.classpath"/>
<pathelement path="${target.test.classes.dir}"/>
</path>
</target>
<target name="clean"
description="--> cleans project">
<delete dir="${target.dir}" />
</target>
<!-- compilation -->
<target name="compile" depends="resolve, init-path" unless="no.compile"
description="--> compile main classes">
<mkdir dir="${target.main.classes.dir}" />
<javac srcdir="${src.main.java.dir}"
destdir="${target.main.classes.dir}"
classpathref="compile.classpath"
source="${java.source.version}"
target="${java.target.version}"
debug="${debug.mode}"
includeantruntime="no"/>
</target>
<!-- jar -->
<target name="jar" depends="compile" unless="no.jar"
description="--> package main jar">
<mkdir dir="${target.artifact.dir}" />
<!-- copy resources -->
<copy todir="${target.main.classes.dir}">
<fileset dir="${src.main.java.dir}">
<exclude name="**/*.java"/>
<exclude name="**/package.html"/>
<exclude name="data/*.xml"/>
</fileset>
</copy>
<!-- jar -->
<jar destfile="${target.artifact.dir}/${artifact.main.name}"
basedir="${target.main.classes.dir}">
<manifest>
<attribute name="Build-Version" value="${build.version}"/>
</manifest>
</jar>
</target>
<!-- tests -->
<target name="init-tests">
<fileset id="test.fileset" dir="${src.test.java.dir}">
<include name="**/${test.class.pattern}.java"/>
<exclude name="**/Abstract*Test.java"/>
</fileset>
</target>
<target name="emma" depends="init-ivy, jar" unless="no.test">
<ivy:cachepath organisation="emma" module="emma-ant" revision="2.0.5312"
inline="true" conf="default" pathid="emma.classpath"/>
<taskdef resource="emma_ant.properties" classpathref="emma.classpath" />
<property name="emma.enabled" value="true" />
<mkdir dir="${target.report.coverage.dir}" />
<emma enabled="${emma.enabled}" >
<instr instrpath="${target.main.classes.dir}"
mode="overwrite"
metadatafile="${target.report.coverage.dir}/metadata.emma"
/>
</emma>
<delete file="${target.report.coverage.dir}/coverage.emma" />
<!-- add emma path to test path, because emma jars need to be available when running
instrumented classes -->
<ivy:addpath topath="test.classpath">
<path refid="emma.classpath"/>
</ivy:addpath>
</target>
<target name="compile-test" depends="jar">
<mkdir dir="${target.test.classes.dir}" />
<javac srcdir="${src.test.java.dir}"
destdir="${target.test.classes.dir}"
classpathref="compile.test.classpath"
source="${java.source.version}"
target="${java.target.version}"
debug="${debug.mode}"
includeantruntime="no"/>
<copy todir="${target.test.classes.dir}">
<fileset dir="${src.test.java.dir}">
<exclude name="**/*.java"/>
</fileset>
</copy>
</target>
<target name="test-internal" depends="compile-test, init-tests" unless="no.test">
<mkdir dir="${target.report.test.xml.dir}" />
<junit
haltonfailure="off"
haltonerror="off"
errorproperty="test.failed"
failureproperty="test.failed"
showoutput="no"
printsummary="yes"
fork="true">
<classpath>
<path refid="test.classpath"/>
</classpath>
<jvmarg value="-Demma.coverage.out.file=${target.report.coverage.dir}/coverage.emma" />
<jvmarg value="-Demma.coverage.out.merge=true" />
<formatter type="xml"/>
<batchtest todir="${target.report.test.xml.dir}">
<fileset refid="test.fileset" />
</batchtest>
</junit>
</target>
<target name="test" depends="test-internal">
<fail if="test.failed"
message="At least one test has failed. See logs for details"/>
</target>
<!-- =================================================================
REPORTS AND DOCUMENTATION
================================================================= -->
<target name="test-report" depends="test-internal" unless="no.test">
<mkdir dir="${target.report.test.html.dir}" />
<junitreport todir="${target.report.test.xml.dir}">
<fileset dir="${target.report.test.xml.dir}">
<include name="TEST-*.xml" />
</fileset>
<report format="frames" todir="${target.report.test.html.dir}" />
</junitreport>
<fail if="test.failed"
message="At least one test has failed. See logs or report"/>
</target>
<target name="coverage-report" depends="emma, test-report" unless="no.test"
description="--> run tests with instrumentation and generate coverage report">
<mkdir dir="${target.report.coverage.dir}" />
<emma>
<report sourcepath="${src.main.java.dir}" >
<fileset dir="${target.report.coverage.dir}" >
<include name="*.emma" />
</fileset>
<txt outfile="${target.report.coverage.dir}/coverage.txt" />
<html outfile="${target.report.coverage.dir}/coverage.html" />
</report>
</emma>
</target>
<target name="javadoc">
<mkdir dir="${target.report.api.dir}" />
<javadoc destdir="${target.report.api.dir}">
<fileset dir="${src.main.java.dir}"/>
</javadoc>
</target>
<target name="distrib" depends="jar">
<input addproperty="build.version" message="version?"/>
<input addproperty="build.status" message="status?"/>
<ivy:info file="${basedir}/ivy.xml" />
<ivy:retrieve conf="default"
ivypattern="${target.distrib.dir}/lib/[organisation]-[module]-[revision].[ext]"
pattern="${target.distrib.dir}/lib/[organisation]-[artifact]-[revision].[ext]"
sync="true" />
<copy file="${target.artifact.dir}/${artifact.main.name}"
tofile="${target.distrib.dir}/lib/${ivy.organisation}-${ivy.module}-${build.version}.jar" />
<ivy:deliver deliverpattern="${target.distrib.dir}/lib/[organisation]-[module]-[revision].[ext]"
pubrevision="${build.version}" status="${build.status}" />
<copy file="${ivy.jar.file}"
todir="${target.distrib.dir}" />
<ivy:retrieve inline="true" transitive="false"
organisation="commons-cli" module="commons-cli" revision="1.0" conf="default"
pattern="${target.distrib.dir}/[artifact]-[revision].[ext]" />
<copy todir="${target.distrib.dir}" >
<fileset dir="${src.distrib.dir}" />
<filterchain>
<replacetokens>
<token key="VERSION" value="${build.version}"/>
</replacetokens>
</filterchain>
</copy>
<copy todir="${target.distrib.dir}/webapp" >
<fileset dir="${src.main.webapp.dir}" />
</copy>
<copy todir="${target.distrib.dir}/webapp/WEB-INF/classes">
<fileset dir="${src.main.java.dir}">
<include name="**/*.properties"/>
<include name="**/*.html"/>
<include name="**/*.css"/>
<include name="**/*.xml"/>
<exclude name="logback-test.xml"/>
</fileset>
</copy>
</target>
<target name="generate-doc">
<!-- requires java 6 jdk in path and Apache Ant 1.7 -->
<copy todir="${target.doc.dir}">
<fileset dir="${doc.dir}" includes="images/**,**/*.css,xooki/tree/**" />
</copy>
<script language="javascript"><![CDATA[
importClass(java.io.File);
fs = project.createDataType("fileset");
fs.setDir( new File(project.getProperty("doc.dir")) );
fs.setIncludes("**/*.html");
fs.setExcludes("template.html,"
+"*Template.html,"
+"reports/**,"
+"xooki/**");
// Get the files (array) of that fileset
ds = fs.getDirectoryScanner(project);
srcFiles = ds.getIncludedFiles();
// iterate over that array
for (i=0; i<srcFiles.length; i++) {
// get the values via Java API
var file = new File(fs.getDir(project), srcFiles[i]);
var basedir = file.getParent();
var filename = file.getName();
var filepath = srcFiles[i].substring(0, srcFiles[i].lastIndexOf(project.getProperty("file.separator"))+1);
exec = project.createTask("exec");
exec.setDir(new File(basedir));
exec.setExecutable("jrunscript");
exec.createArg().setValue(project.getProperty("doc.dir")+"/xooki/xooki.js");
// exec.createArg().setValue("-noddtree");
exec.createArg().setValue(filename);
exec.createArg().setValue(project.getProperty("target.doc.dir")+"/"+filepath);
exec.perform();
}
]]></script>
</target>
<target name="publish-site" depends="generate-doc">
<property name="host.name" value="xoocode.org" />
<echo message="Preparing to upload site to ${host.name}..." />
<input addproperty="username" message="Please enter username:" />
<input addproperty="password" message="Please enter password:" />
<scp todir="${username}:${password}@${host.name}:/var/www/xoosent/"
trust="true" verbose="true" sftp="true">
<fileset dir="${target.doc.dir}"/>
</scp>
</target>
</project>
Generated by GNU enscript 1.6.4. |