Mega Code Archive

 
Categories / Java / Ant
 

GWT ant script

<project name="GWT" default="dist" basedir=".">   <property name="gwt.root" location="." />   <property name="project.tail" value="" />   <import file="${gwt.root}/common.ant.xml" />   <!-- "build" is the default when subprojects are directly targetted  -->   <property name="target" value="build" />   <property name="emma.merged.out" value="${project.build}/emma-coverage" />   <!--       Convenience for the lateral calls we make.  Use gwt.ant to      descend into another directory, and this to call in the same build.xml.      NOTE THE USE OF $TARGET, here and in common's gwt.ant.  This has the      effect of dividing rules into subdirectory rules (using gwt.ant and      sensitive to $target) and action rules (using call-subproject and      setting $target)... but it is Bad for a subdirectory rule to depend      on another one, as they are both sensitive to $target, but you probably      mean that subdirB needed subdirA to be _built_, not $target'ed (tested,      etc.)      In other words, DO NOT USE DEPENDS=... IN A TARGET WITH GWT.ANT.         -->   <macrodef name="call-subproject">     <attribute name="subproject" />     <attribute name="subtarget" />     <sequential>       <antcall target="@{subproject}">         <param name="target" value="@{subtarget}" />       </antcall>     </sequential>   </macrodef>   <property name="gwt.apicheck.config"      location="tools/api-checker/config/gwt16_20userApi.conf"/>   <target name="buildonly"           description="[action] Minimal one-platform devel build, without distro packaging">     <call-subproject subproject="dev" subtarget="build" />     <call-subproject subproject="user" subtarget="build" />     <call-subproject subproject="servlet" subtarget="build" />     <call-subproject subproject="jni" subtarget="build" />   </target>   <target name="dist" depends="build, doc" description="[action] Make all the distributions">     <gwt.ant dir="distro-source" />   </target>   <target name="dist-dev" depends="buildonly" description="[action] Make this platform's distribution, minus doc and samples">     <gwt.ant dir="distro-source" target="build" />   </target>   <target name="dev" description="[subdir] Builds (or runs ${target} if set) all the dev libraries">     <call-subproject subproject="buildtools" subtarget="build" />     <gwt.ant dir="dev" />   </target>   <target name="user" description="[subdir] Builds (or runs ${target} if set) only the user library">     <call-subproject subproject="dev" subtarget="build"/>     <gwt.ant dir="user" />   </target>   <target name="tools" description="[subdir] Builds (or runs ${target} if set) only the tools">     <call-subproject subproject="user" subtarget="build"/>     <gwt.ant dir="tools" />   </target>   <target name="servlet" description="[subdir] Builds (or runs ${target} if set) only the servlet jar">     <call-subproject subproject="user" subtarget="build" />     <gwt.ant dir="servlet" />   </target>   <target name="jni" description="[subdir] Builds (or runs ${target} if set) jni for all platforms">     <gwt.ant dir="jni" />   </target>   <target name="doc" description="[subdir] Builds (or runs ${target} if set) the doc">     <call-subproject subproject="user" subtarget="build" />     <gwt.ant dir="doc" />   </target>   <target name="samples" description="[subdir] Builds (or runs ${target} if set) the samples">     <call-subproject subproject="user" subtarget="build" />     <gwt.ant dir="samples" />   </target>   <target name="buildtools" description="[subdir] Build (or runs ${target} if set) the build tools">     <gwt.ant dir="build-tools" />   </target>   <target name="build" description="[action] Builds GWT, including samples, but without distro packaging">      <call-subproject subproject="dev" subtarget="build"/>      <call-subproject subproject="user" subtarget="build"/>      <call-subproject subproject="servlet" subtarget="build"/>      <call-subproject subproject="tools" subtarget="build"/>      <call-subproject subproject="jni" subtarget="build"/>      <call-subproject subproject="samples" subtarget="build"/>   </target>   <target name="checkstyle" description="[action] Does static analysis of GWT source">     <call-subproject subproject="buildtools" subtarget="checkstyle" />     <call-subproject subproject="dev" subtarget="checkstyle" />     <call-subproject subproject="user" subtarget="checkstyle" />     <call-subproject subproject="servlet" subtarget="checkstyle" />     <call-subproject subproject="tools" subtarget="checkstyle" />     <call-subproject subproject="samples" subtarget="checkstyle" />   </target>   <target name="test" depends="dist-dev,apicheck,checkstyle"            description="[action] Runs all the GWT tests, including checkstyle and apicheck">     <call-subproject subproject="buildtools" subtarget="test" />     <call-subproject subproject="dev" subtarget="test" />     <call-subproject subproject="user" subtarget="test" />     <call-subproject subproject="servlet" subtarget="test" />     <call-subproject subproject="tools" subtarget="test" />   </target>   <path id="emma.classpath.src">     <pathelement location="${gwt.root}/user/src" />     <pathelement location="${gwt.root}/dev/**/src/com/google" />     <pathelement location="${gwt.root}/build-tools/**/src/com/google" />     <pathelement location="${gwt.root}/tools/**/src/com/google" />   </path>   <target name="emma.merge" description="Merges coverage data for all projects">     <delete dir="${emma.merged.out}" />     <mkdir dir="${emma.merged.out}" />     <emma>       <merge outfile="${emma.merged.out}/merged.emma" >         <fileset dir="${project.build}">           <include name="**/*.emma" />           <exclude name="**/merged.emma" />         </fileset>       </merge>     </emma>     <emma>       <report sourcepath="${emma.classpath.src}">         <fileset dir="${project.build}">           <patternset>             <include name="**/metadata.emma"/>           </patternset>         </fileset>         <fileset file="${emma.merged.out}/merged.emma" />         <txt outfile="${emma.merged.out}/coverage.txt" />         <html outfile="${emma.merged.out}/coverage.html" />         <xml outfile="${emma.merged.out}/coverage.xml" />       </report>     </emma>   </target>   <target name="clean" description="[action] Cleans the entire GWT build">     <delete dir="${gwt.build}" />   </target>   <target name ="presubmit" description="[action] Deprecated for test, which now does checkstyle and apicheck"           depends="test">   </target>   <target name="apicheck-nobuild"      description="[action] Checks API compatibility to prior GWT revision">     <java failonerror="true" fork="true"           classname="com.google.gwt.tools.apichecker.ApiCompatibilityChecker">       <jvmarg line="-Xmx512m" />       <classpath>         <pathelement location="${gwt.build.out}/tools/api-checker/bin"/>         <fileset dir="${gwt.build.lib}" includes="gwt-user.jar,gwt-dev.jar" />         <pathelement path="${java.class.path}"/>         <pathelement location="${gwt.tools.lib}/apache/ant-1.6.5.jar" />       </classpath>       <arg value="-refJar"/>       <arg path="${gwt.root}/tools/api-checker/reference/gwt-dev-modified.jar:${gwt.root}/tools/api-checker/reference/gwt-user-modified.jar"/>       <arg value="-configFile"/>       <arg file="${gwt.apicheck.config}"/>       <arg value="-logLevel"/>       <arg value="ERROR"/>     </java>   </target>   <target name="apicheck" depends="buildonly,tools,apicheck-nobuild"            description="[action] Builds GWT and checks API compatiblity to prior release"/> </project> File: common.ant.xml <project name="common">   <!-- it's okay for this not to exist, but it gives a place to store        personal property settings, if any, persistently.  For example, you        might use it to set gwt.junit.testcase.includes to a narrower subset        of test cases to exercise. -->   <property file="local.ant.properties" />   <!-- gwt.build.iscasesensitivefs is true if the filesystem of the     build machine is case-sensitive, false otherwise.  Update with     new lines for any supported platforms with case-insensitive     filesystems   -->   <condition property="gwt.build.iscasesensitivefs" else="false">     <not>       <or>         <os family="windows"/>       </or>     </not>   </condition>   <property name="test.ant.file" location="${gwt.root}/${project.tail}/build.xml" />   <condition property="project.valid">     <equals arg1="${ant.file}" arg2="${test.ant.file}"       casesensitive="${gwt.build.iscasesensitivefs}"/>   </condition>   <fail unless="project.valid" message="This build file is in an inconsistent state (${ant.file} != ${test.ant.file})." />   <!-- Global Properties -->   <property environment="env" />   <condition property="gwt.version" value="${env.GWT_VERSION}" else="0.0.0">     <isset property="env.GWT_VERSION" />   </condition>   <condition property="gwt.tools.check" value="${env.GWT_TOOLS}" else="${gwt.root}/../tools">     <isset property="env.GWT_TOOLS" />   </condition>   <property name="gwt.tools" location="${gwt.tools.check}" />   <property name="gwt.tools.lib" location="${gwt.tools}/lib" />   <property name="gwt.tools.antlib" location="${gwt.tools}/antlib" />   <property name="gwt.tools.redist" location="${gwt.tools}/redist" />   <property name="gwt.build" location="${gwt.root}/build" />   <property name="gwt.build.out" location="${gwt.build}/out" />   <property name="gwt.build.lib" location="${gwt.build}/lib" />   <property name="gwt.build.jni" location="${gwt.build}/jni" />   <property name="gwt.build.staging" location="${gwt.build}/staging" />   <property name="gwt.build.dist" location="${gwt.build}/dist" />   <!-- gwt.threadsPerProcessor supercedes gwt.threadCount unless set to 0 -->    <property name="gwt.threadsPerProcessor" value="1" />   <property name="gwt.threadCount" value="1" />   <property name="project.build" location="${gwt.build.out}/${project.tail}" />   <property name="project.lib" location="${gwt.build.lib}/gwt-${ant.project.name}.jar" />   <property name="project.jni" location="${gwt.build}/${project.tail}" />   <property name="javac.out" location="${project.build}/bin" />   <property name="javac.junit.out" location="${project.build}/bin-test" />   <property name="javac.emma.out" location="${project.build}/bin-emma" />   <property name="javac.debug" value="true" />   <property name="javac.debuglevel" value="lines,vars,source" />   <property name="javac.encoding" value="utf-8" />   <property name="javac.source" value="1.5" />   <property name="javac.target" value="1.5" />   <property name="javac.nowarn" value="true" />   <property name="junit.out" location="${project.build}/test" />   <property name="emma.dir" value="${gwt.tools.redist}/emma" />   <property name="emma.filter.exclude" value="" />      <!-- Sanity check -->   <available file="${gwt.tools}" type="dir" property="gwt.tools.exists" />   <fail unless="gwt.tools.exists" message="Cannot find '${gwt.tools}' tools directory; perhaps you should define the GWT_TOOLS environment variable" />   <!-- Platform identification -->   <condition property="build.host.islinux">     <and>       <os family="unix" />       <not>         <contains string="${os.name}" substring="mac" casesensitive="false" />       </not>     </and>   </condition>   <condition property="build.host.platform" value="linux">     <isset property="build.host.islinux" />   </condition>   <condition property="build.host.ismac">     <and>       <os family="unix" />       <contains string="${os.name}" substring="mac" casesensitive="false" />     </and>   </condition>   <condition property="build.host.platform" value="mac">     <isset property="build.host.ismac" />   </condition>   <condition property="build.host.iswindows">     <os family="windows" />   </condition>   <condition property="build.host.platform" value="windows">     <isset property="build.host.iswindows" />   </condition>   <fail unless="build.host.platform" message="Building on ${os.name} is not supported" />   <!-- JUnit support -->   <property name="gwt.dev.staging.jar" location="${gwt.build.staging}/gwt-${gwt.version}/gwt-dev.jar" />   <property name="gwt.junit.port" value="8888" />   <property name="gwt.junit.testcase.includes" value="**/*Suite.class"/>   <!-- Shared class paths -->   <path id="project.classpath.class">     <pathelement location="${javac.out}" />   </path>   <path id="project.classpath.src">     <pathelement location="${gwt.root}/${project.tail}/src" />   </path>   <!-- Pulls in tasks defined in ant-contrib, i.e. foreach -->   <taskdef resource="net/sf/antcontrib/antlib.xml">     <classpath>       <pathelement location="${gwt.tools.antlib}/ant-contrib-1.0b3.jar" />     </classpath>   </taskdef>   <!-- Global Custom Tasks -->   <presetdef name="gwt.ant">     <ant inheritall="false" target="${target}">       <propertyset>         <propertyref name="gwt.version" />         <propertyref name="gwt.junit.port" />         <propertyref name="gwt.remote.browsers" />         <propertyref name="emma.enabled" />         <propertyref name="emma.compiled" />       </propertyset>     </ant>   </presetdef>   <presetdef name="gwt.javac">     <javac srcdir="src" destdir="${javac.out}" debug="${javac.debug}" debuglevel="${javac.debuglevel}" source="${javac.source}" target="${javac.target}" nowarn="${javac.nowarn}" encoding="${javac.encoding}" />   </presetdef>   <macrodef name="gwt.jar">     <attribute name="destfile" default="${project.lib}"/>     <attribute name="duplicate" default="fail"/>     <attribute name="update" default="true"/>     <element name="jarcontents" implicit="true"/>     <sequential>       <taskdef name="jar.bydate"           classname="com.google.gwt.ant.taskdefs.LatestTimeJar"           classpath="${gwt.build.lib}/ant-gwt.jar" />       <jar.bydate destfile="@{destfile}" duplicate="@{duplicate}" filesonly="false"           index="true" update="@{update}">         <jarcontents/>       </jar.bydate>     </sequential>   </macrodef>   <macrodef name="gwt.junit">     <!-- TODO: Because dev has core, oophm splits, the "common pattern" here doesn't work          for it (and we use extraclasspaths entries instead).  Once we lose SWT, we can          consolidate dev/core and dev/oophm, and that can instead more to the normal          pattern.  Note also special casing regarding (dev/) core/test. -->     <attribute name="test.args" default="" />     <attribute name="test.out" default="" />     <attribute name="test.reports" default="@{test.out}/reports" />     <attribute name="test.emma.coverage" default="@{test.out}/emma-coverage" />     <attribute name="test.cases" default="" />     <attribute name="test.name" default="" />     <attribute name="haltonfailure" default="true" />     <element name="extraclasspaths" optional="true" />     <sequential>       <taskdef name="junit" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask">         <classpath>           <pathelement location="${gwt.tools.lib}/junit/junit-3.8.1.jar" />           <pathelement location="${gwt.tools.antlib}/ant-junit-1.6.5.jar" />           <pathelement location="${gwt.tools.lib}/selenium/selenium-java-client-driver.jar" />         </classpath>       </taskdef>       <echo message="Writing test results to @{test.reports} for @{test.cases}" />       <mkdir dir="@{test.reports}" />       <antcall target="-create.emma.coverage.if.enabled">         <param name="test.emma.coverage" value="@{test.emma.coverage}"/>       </antcall>       <condition property="emma.lib" value="${emma.dir}/emma-2.0.5312-patched.jar"             else="${emma.dir}/no-emma-requested">         <isset property="emma.enabled" />       </condition>       <junit dir="@{test.out}" fork="yes" printsummary="yes"              failureproperty="junit.failure" tempdir="@{test.out}">         <jvmarg line="-Xmx768m" />         <jvmarg line="-Xss512k" />         <jvmarg value="-Demma.coverage.out.file=@{test.emma.coverage}/coverage.emma" />         <jvmarg value="-Demma.coverage.out.merge=true" />         <sysproperty key="gwt.args" value="@{test.args}" />         <sysproperty key="java.awt.headless" value="true" />         <classpath>           <path refid="project.classpath.src" />           <pathelement location="${gwt.root}/${project.tail}/super" />           <pathelement location="${gwt.root}/${project.tail}/test" />           <!-- TODO: this is here because e.g. ClassPathEntryTest otherwise fails,                expecting the src entry (core/test) to be earlier than the bin entry                (${javac.junit.out}). -->           <pathelement location="${gwt.root}/${project.tail}/core/test" />           <pathelement location="${javac.junit.out}" />           <!-- javac.emma.out is empty unless emma is enabled. -->           <pathelement location="${javac.emma.out}" />           <path refid="project.classpath.class" />           <pathelement location="${emma.lib}" />           <pathelement location="${gwt.dev.staging.jar}" />           <pathelement location="${gwt.tools.lib}/junit/junit-3.8.1.jar" />           <pathelement location="${gwt.tools.lib}/selenium/selenium-java-client-driver.jar" />           <pathelement location="${gwt.tools.lib}/w3c/sac/sac-1.3.jar" />           <pathelement location="${gwt.tools.lib}/w3c/flute/flute-1.3-gg1.jar" />           <extraclasspaths />         </classpath>         <formatter type="plain" />         <formatter type="xml" />         <batchtest todir="@{test.reports}">           <fileset refid="@{test.cases}" />         </batchtest>       </junit>       <emma enabled="${emma.enabled}">         <report sourcepath="${project.classpath.src}">           <fileset file="${javac.emma.out}/metadata.emma" />           <fileset dir="@{test.emma.coverage}">             <include name="*.emma" />           </fileset>           <txt outfile="@{test.emma.coverage}/coverage.txt" />           <html outfile="@{test.emma.coverage}/coverage.html" />           <xml outfile="@{test.emma.coverage}/coverage.xml" />         </report>       </emma>       <condition property="junit.stop.build" value="true">          <and>           <istrue value="@{haltonfailure}"/>           <isset property="junit.failure"/>         </and>       </condition>       <fail           message="One or more junit tests failed for target: @{test.name} @{test.args}"           if="junit.stop.build" status="2" />     </sequential>   </macrodef>   <macrodef name="gwt.tgz.cat">     <attribute name="destfile" />     <attribute name="compression" default="gzip" />     <element name="tar.elements" implicit="true" optional="true" />     <sequential>       <taskdef name="tar.cat" classname="com.google.gwt.ant.taskdefs.TarCat" classpath="${gwt.build.lib}/ant-gwt.jar" />       <tar.cat destfile="@{destfile}" compression="@{compression}" longfile="gnu">         <tar.elements />       </tar.cat>     </sequential>   </macrodef>   <macrodef name="gwt.getsvninfo" description="Identifies the SVN info of a workspace">     <sequential>       <taskdef name="svninfo"          classname="com.google.gwt.ant.taskdefs.SvnInfo"          classpath="${gwt.build.lib}/ant-gwt.jar" />       <svninfo directory="${gwt.root}" outputproperty="gwt.svnrev"           outputfileproperty="gwt.svnrev.filename" />       <!-- Generally, filtering requires a sentinel file so that changes to svn rev will          be noticed as invalidating the previously-generated filter output.  This property          names where such a sentinel lives; it is tested with <available/> and created          with <touch/> -->       <mkdir dir="${project.build}/sentinels" />        <property name="filter.sentinel"            location="${project.build}/sentinels/gwt-${gwt.version}-svn-${gwt.svnrev.filename}" />      </sequential>   </macrodef>      <macrodef name="gwt.revfilter" description="Filters files for versioning">     <attribute name="todir" description="Destination for the filtered copy"/>          <element name="src.fileset" implicit="true"        description="Source for the filtered copy"/>     <sequential>       <!-- These files must be filtered for versioning -->       <echo message="Branding as GWT version ${gwt.version}, SVN rev ${gwt.svnrev}"/>       <mkdir dir="@{todir}" />       <copy todir="@{todir}" overwrite="true">         <src.fileset/>         <filterset>           <filter token="GWT_VERSION" value="${gwt.version}" />           <filter token="GWT_SVNREV" value="${gwt.svnrev}" />         </filterset>       </copy>     </sequential>   </macrodef>   <macrodef name="gwt.timer">     <attribute name="name"/>     <element name="timer.elements" implicit="true" optional="false"/>     <sequential>       <taskdef name="timer"          classname="com.google.gwt.ant.taskdefs.Timer"         classpath="${gwt.build.lib}/ant-gwt.jar" />       <timer name="@{name}">         <timer.elements/>       </timer>     </sequential>   </macrodef>   <macrodef name="gwt.checkstyle">     <attribute name="outputdirectory" default="${project.build}"/>     <element name="sourcepath" implicit="yes" optional="true" />     <sequential>       <taskdef resource="checkstyletask.properties" classpath="${gwt.tools.antlib}/checkstyle-all-4.2.jar;${gwt.build.lib}/gwt-customchecks.jar" />       <mkdir dir="@{outputdirectory}"/>       <checkstyle config="${gwt.root}/eclipse/settings/code-style/gwt-checkstyle.xml" maxErrors="0" failOnViolation="false" failureProperty="gwt.checkstyle.failed">         <formatter type="xml" toFile="@{outputdirectory}/checkstyle_log.xml"/>         <property key="checkstyle.header.file" file="${gwt.root}/eclipse/settings/code-style/google.header" />         <sourcepath />       </checkstyle>       <fail message="Checkstyle errors exist, and are reported at @{outputdirectory}/checkstyle_log.xml" if="gwt.checkstyle.failed" />     </sequential>   </macrodef>   <macrodef name="gwt.checkstyle.tests">     <attribute name="outputdirectory" default="${project.build}"/>     <element name="sourcepath" implicit="yes" optional="true" />     <sequential>       <taskdef resource="checkstyletask.properties" classpath="${gwt.tools.antlib}/checkstyle-all-4.2.jar;${gwt.build.lib}/gwt-customchecks.jar" />       <mkdir dir="@{outputdirectory}"/>       <checkstyle config="${gwt.root}/eclipse/settings/code-style/gwt-checkstyle-tests.xml" maxErrors="0" failOnViolation="false" failureProperty="gwt.checkstyle-tests.failed">         <formatter type="xml" toFile="@{outputdirectory}/checkstyle_tests_log.xml"/>         <property key="checkstyle.header.file" file="${gwt.root}/eclipse/settings/code-style/google.header" />         <sourcepath />       </checkstyle>       <fail message="Checkstyle errors exist in tests, and are reported at @{outputdirectory}/checkstyle_tests_log.xml" if="gwt.checkstyle-tests.failed" />     </sequential>   </macrodef>   <macrodef name="property.ensure">     <attribute name="name" />     <attribute name="location" />     <attribute name="message" default="Cannot find dependency ${@{name}}" />     <attribute name="unless" default="__nonexistent_property__" />     <sequential>       <property name="@{name}" location="@{location}" />       <condition property="@{name}.exists">         <or>           <available file="${@{name}}" />           <isset property="@{unless}" />         </or>       </condition>       <fail unless="@{name}.exists" message="@{message}" />     </sequential>   </macrodef>   <!-- Targets for emma support.  To run tests with emma enabled, use         ant <test-target> -Demma.enabled=true -->   <path id="emma.taskdef.lib">     <pathelement location="${emma.dir}/emma-2.0.5312-patched.jar" />     <pathelement location="${emma.dir}/emma_ant-2.0.5312.jar" />   </path>   <taskdef resource="emma_ant.properties" classpathref="emma.taskdef.lib" />   <!-- Instruments emma classes -->   <target name="compile.emma.if.enabled" unless="emma.compiled">     <delete dir="${javac.emma.out}" />     <property name="emma.compiled" value="true" />     <antcall target="-compile.emma.if.enabled" />   </target>   <!-- Instruments emma classes -->   <target name="-compile.emma.if.enabled" if="emma.enabled">     <mkdir dir="${javac.emma.out}" />     <path id="emma.classpath">       <pathelement location="${javac.out}" />     </path>     <emma enabled="${emma.enabled}" >       <instr instrpathref="emma.classpath" destdir="${javac.emma.out}" metadatafile="${javac.emma.out}/metadata.emma" merge="false">         <filter includes="com.google.*" />         <filter excludes="${emma.filter.exclude}" />       </instr>     </emma>   </target>   <!-- Create the emma coverage directory -->   <target name="-create.emma.coverage.if.enabled" if="emma.enabled">     <delete dir="${test.emma.coverage}" />     <mkdir dir="${test.emma.coverage}" />   </target>   <!-- Default implementations of the required targets; projects should   override the ones that matter -->   <target name="all" depends="verify" />   <target name="verify" depends="checkstyle, test"       description="Runs tests and checkstyle static analysis" />   <target name="checkstyle" />   <target name="test" depends="build" />   <target name="build" />   <target name="clean">     <delete dir="${project.build}" />   </target> </project> File: platforms.ant.xml <project name="platforms">   <import file="${gwt.root}/common.ant.xml" />   <!-- "build" is the default when subprojects are directly targetted -->   <property name="target" value="build" />   <available file="core/build.xml" type="file" property="core.exists" />   <target name="core" description="Run core" if="core.exists">     <gwt.ant dir="core" />   </target>   <target name="-do" depends="core" description="Run all platforms" />   <target name="build" description="Build each platforms">     <antcall target="-do">       <param name="target" value="build" />     </antcall>   </target>   <target name="checkstyle" description="Static analysis of source for each platform">     <antcall target="-do">       <param name="target" value="checkstyle" />     </antcall>   </target>   <target name="test" description="Test each platform">     <antcall target="-do">       <param name="target" value="test" />     </antcall>   </target> </project>