blob: 0c01bfc14e7243755c621f264917fbd93b7f28c5 [file] [log] [blame]
* 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
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* Author: (Alex North)
<project name="macros">
<!-- Macro which compiles a set of PST message templates -->
<macrodef name="pstmessage">
<attribute name="proto" description="Protocol buffer class file"/>
<runpst proto="@{proto}"
<!-- Macro which runs the PST compiler.
Don't use this directly, use pstmessage. -->
<macrodef name="runpst">
<attribute name="proto" description="Protocol buffer class file"/>
<attribute name="templates" description="Template files"/>
<attribute name="outputdir" description="Output directory"/>
<java failonerror="true" fork="true" classname="org.waveprotocol.pst.PstMain">
<path refid="libpath"/>
<path location="${dist.dir}/pst.jar"/>
<path location="${build.proto.dir}"/>
<fileset dir="${lib.codegen}">
<include name="*/*.jar"/>
<arg line="-s pst"/>
<arg value="-d"/><arg value="@{outputdir}"/>
<arg value="-f"/><arg value="@{proto}"/>
<arg line="@{templates}"/>
<!-- Macro which builds a collection of sources -->
<macrodef name="buildjava">
<attribute name="srcpattern" description="Pattern id describing files to build"
<!--attribute name="srcdir" description="Source root directory"/-->
<attribute name="destdir" description="Build root directory"/>
<element name="javac-elements" description="Extra elements to pass to javac" implicit="true"/>
<patternset id="default-src-pattern">
<include name="**/*.java"/>
<javac destdir="@{destdir}" debug="true">
<exclude name="org/waveprotocol/pst/**"/>
<patternset refid="@{srcpattern}"/>
<!-- TODO(anorth): enable -Werror after fixing warnings. -->
<compilerarg value="-Werror"/>
<compilerarg value="-Xlint:all"/>
<compilerarg value="-Xlint:-serial"/>
<!-- Deprecation warnings are generated for .class files for some
compilers, e.g. org.hamcrest.Matcher -> org.hamcrest.BaseMatcher. -->
<compilerarg value="-Xlint:-deprecation"/>
<!-- Macro which packages class and source files into jars -->
<macrodef name="distlib">
<attribute name="srcpattern" description="Pattern id describing files to package"/>
<attribute name="libname" description="Name prefix for the jars"/>
<jar destfile="${dist.dir}/@{libname}.jar" basedir="${build.src.dir}">
<patternset refid="@{srcpattern}"/>
<jar destfile="${dist.dir}/@{libname}-src.jar" basedir="${src.dir}">
<patternset refid="@{srcpattern}"/>
<exclude name="**/build.xml"/>
<!-- Macro which runs unit tests with JUnit -->
<macrodef name="runtests">
<attribute name="forkmode" description="How to fork the JVM for each test/batch"/>
<attribute name="coverage" description="Whether to calculate coverage with EMMA"/>
<element name="tests" description="Fileset describing tests to run" implicit="true"/>
<delete dir="${test.out.dir}"/>
<mkdir dir="${test.out.dir}"/>
<!-- Add instrumentation code -->
<emma enabled="@{coverage}">
<instr instrpath="${build.src.dir}" destdir="${coverage.dir}"
metadatafile="${coverage.dir}/metadata.emma" mode="copy"/>
<junit fork="yes" forkmode="@{forkmode}" printsummary="yes"
showoutput="no" haltonfailure="no" failureProperty="test.failed">
<jvmarg value="-Xmx512M"/>
<jvmarg value="-ea"/>
<!-- Emma arguments -->
<jvmarg value="-Demma.coverage.out.file=${coverage.dir}/coverage.emma" />
<jvmarg value="-Demma.coverage.out.merge=true" />
<!-- This classpath includes src folders for the gwt.xml files -->
<path location="${coverage.dir}"/>
<path location="${build.proto.dir}"/>
<path location="${build.messages.dir}"/>
<path location="${build.src.dir}"/>
<path location="${build.test.dir}"/>
<path location="${src.dir}"/>
<path location="${test.dir}"/>
<path refid="libpath"/>
<path refid="test.libpath"/>
<!-- Set formatter so that the output is saved in xml files -->
<formatter type="xml"/>
<batchtest todir="${test.out.dir}">
<!-- Parses the xml files previously saved into readable HTML -->
<junitreport todir="${test.out.dir}">
<fileset dir="${test.out.dir}">
<include name="TEST*.xml"/>
<report format="frames" todir="${test.out.dir}"/>
<!-- Generates the Emma Report -->
<emma enabled="@{coverage}">
<report sourcepath="${src.dir}" depth="method">
<fileset dir="${coverage.dir}" >
<include name="*.emma" />
<html outfile="${coverage.dir}/coverage.html" />
<echo>Test results: file://${test.out.dir}/index.html</echo>
<echo>Coverage results: file://${coverage.dir}/coverage.html</echo>
<fail message="Tests failed. Check log and/or reports: ${test.out.dir}/index.html" if="test.failed"/>
<target name="define-gxpc" depends="get-third-party-runtime">
<!-- Task which compiles GXP templates -->
<taskdef name="gxpc" classname=""
classpath="${lib.runtime}/google-gxp-0.2.4-beta.jar" />