<!-- ========================================================================= --> <!-- Copyright (c) 2003 Contributors. --> <!-- All rights reserved. --> <!-- This program and the accompanying materials are made available --> <!-- under the terms of the Common Public License v1.0 --> <!-- which accompanies this distribution and is available at --> <!-- http://www.eclipse.org/legal/cpl-v10.html --> <!-- --> <!-- Contributors: --> <!-- Wes Isberg initial implementation --> <!-- ========================================================================= --> <project name="build" default="all" basedir="."> <!-- ========================================================================= --> <target name="info" depends="init-variables"> <echo> Build and test the AspectJ source tree. Targets: all (default) install # install distribution build build-release # build distribution build-tests # build test classes test test-sources # - requires only sources test-harness-tests # run tests/{suite}.xml's test-junit-modules # tests/junitModules.xml test-install # - requires distribution test-build-examples # install/docs/examples test-ajc-aspectj # ajc compiles aspectj Normally this builds with Java 1.3 and tests with both Java 1.3 and 1.4, so define both as properties. You can select any target (not prefixed "do-" or "init-"). The leaf targets will run with Java version set in ${java.home.file} When running non-leaf targets, if you want to test only in 1.3 or 1.4, set property "run.1[3|4].only". Properties to consider setting on the command-line: -- required java13.home JAVA_HOME for latest J2SE 1.3 java14.home JAVA_HOME for latest J2SE 1.4 -- flags to control run.13.only only use Java 1.3 run.14.only only use Java 1.4 skip.cvs no CVS checkout (true) skip.build no build (done already) skip.test no tests skip.build.release no build of release skip.build.tests no build of tests version set if not DEVELOPMENT(?) -- locations to re-use existing tree or install aspectj.workspace location for new cvs tree aspectj.modules.dir ... for existing cvs tree aj.build.install.dir ... for installed dist Example command lines for using this script: - define variable for standard properties sp="-Djava13.home=d:/j13 -Djava14.home=d:/j14" sp="$${sp} -Daspectj.modules.dir=../.." - clean first cd build ant clean - test only sources in local tree cd build/release ant test-sources $${sp} - build and install distribution: cd build/release ant install $${sp} - test installation and sources in local tree: cd build/release ant test $${sp} -Dskip.build=true - do everything but checkout from cvs: cd build ant clean cd release ant all $${sp} </echo> </target> <target name="init-variables" > <!-- re-enable when tested --> <property name="skip.cvs" value="true"/> <property name="version" value="DEVELOPMENT"/> <property name="ant.verbose" value=""/> <property name="failonerror" value="true"/> <property name="aspectj.workspace" location="${basedir}/aspectj-workspace"/> <property name="aspectj.modules.dir" location="${aspectj.workspace}/org.aspectj/modules"/> <property name="aspectj.build.dir" location="${aspectj.modules.dir}/build"/> <property name="aspectj.build.release.dir" location="${aspectj.build.dir}/release"/> <property name="aspectj.tests.dir" location="${aspectj.modules.dir}/tests"/> <property name="aspectj.lib.dir" location="${aspectj.modules.dir}/lib"/> <property name="aspectj.ant.home" location="${aspectj.lib.dir}/ant"/> <property name="aspectj.ant.lib.dir" location="${aspectj.ant.home}/lib"/> <property name="aj.build.dir" location="${aspectj.modules.dir}/aj-build"/> <property name="aj.build.jar.dir" location="${aj.build.dir}/jars"/> <property name="aj.build.dist.dir" location="${aj.build.dir}/dist"/> <property name="aj.build.jar.dir" location="${aj.build.dir}/jars"/> <property name="aj.build.install.dir" location="${aj.build.dir}/install"/> <property name="aj.build.log.dir" location="${aj.build.dir}/logs"/> <!-- todo: clean-up file created as side-effect --> <property name="java.home.file" location="${aspectj.build.release.dir}/javahome.props.tmp"/> <property name="aspectj.jar" location="${aj.build.dist.dir}/aspectj-${version}.jar"/> <property name="harness.jar" location="${aj.build.jar.dir}/testing-drivers-all.jar"/> <property name="java13.command" location="${java13.home}/bin/java"/> <property name="java14.command" location="${java14.home}/bin/java"/> <mkdir dir="${aj.build.log.dir}"/> <path id="lib.classpath"> <pathelement location="${aspectj.lib.dir}/eclipse2.0/jdtDepends.jar" /> <pathelement location="${aspectj.lib.dir}/bcel/bcel.jar" /> <pathelement location="${aspectj.lib.dir}/jdiff/jdiff.jar" /> <pathelement location="${aspectj.lib.dir}/commons/commons.jar" /> <pathelement location="${aspectj.lib.dir}/ant/lib/ant.jar" /> <pathelement location="${aspectj.lib.dir}/ant/lib/xml-apis.jar" /> <pathelement location="${aspectj.lib.dir}/ant/lib/xercesImpl.jar" /> <pathelement location="${aspectj.lib.dir}/junit/junit.jar" /> <pathelement location="${aspectj.modules.dir}/org.eclipse.jdt.core/jdtcore-for-aspectj.jar" /> </path> <!-- requires normal build, i.e., with test classes --> <path id="jar.classpath"> <pathelement location="${aj.build.jar.dir}/ajde.jar" /> <pathelement location="${aj.build.jar.dir}/ajbrowser.jar" /> <pathelement location="${aj.build.jar.dir}/asm.jar" /> <pathelement location="${aj.build.jar.dir}/bridge.jar" /> <pathelement location="${aj.build.jar.dir}/build.jar" /> <pathelement location="${aj.build.jar.dir}/org.aspectj.ajdt.core.jar" /> <pathelement location="${aj.build.jar.dir}/runtime.jar" /> <pathelement location="${aj.build.jar.dir}/taskdefs.jar" /> <pathelement location="${aj.build.jar.dir}/testing.jar" /> <pathelement location="${aj.build.jar.dir}/testing-client.jar" /> <pathelement location="${aj.build.jar.dir}/testing-drivers.jar" /> <pathelement location="${aj.build.jar.dir}/testing-util.jar" /> <pathelement location="${aj.build.jar.dir}/util.jar" /> <pathelement location="${aj.build.jar.dir}/weaver.jar" /> <path refid="lib.classpath"/> </path> <available property="jar.path.available" file="${aj.build.jar.dir}/ajbrowser.jar" type="file"/> </target> <target name="init-sources-available" depends="init-variables" unless="sources.available"> <available property="sources.available" file="${aspectj.modules.dir}/build/build.xml"/> <fail unless="sources.available" message="checkout first"/> </target> <target name="init-aspectj-available" depends="init-variables" unless="aspectj.available"> <available property="aspectj.available" file="${aj.build.install.dir}" type="dir"/> <fail unless="aspectj.available" message="install first in ${aj.build.install.dir}"/> </target> <target name="init-harness-available" depends="init-variables" unless="harness.available"> <available property="harness.available" classname="org.aspectj.testing.drivers.Harness" classpath="${harness.jar}"/> <fail unless="harness.available" message="harness not found - first build-tests"/> </target> <target name="init-junitTests-available" depends="init-variables" unless="tests.available"> <available property="tests.available" classname="AjbrowserModuleTests"> <classpath> <path refid="jar.classpath"/> <path location="${aspectj.lib.dir}/junit/junit.jar"/> </classpath> </available> <fail unless="tests.available" message="test classes not found - first build-tests"/> </target> <!-- ========================================================================= --> <target name="all"> <antcall target="install"/> <antcall target="test"/> </target> <target name="build" unless="skip.build" description="build an AspectJ release and tests"> <antcall target="build-release"/> <antcall target="build-tests"/> </target> <target name="test" unless="skip.test" description="test AspectJ source and distribution"> <antcall target="test-sources"/> <antcall target="test-install"/> </target> <target name="install" depends="build,init-variables" description="install AspectJ distribution using current java"> <fail unless="aspectj.jar" message="define aspectj.jar"/> <fail unless="aj.build.install.dir" message="define aj.build.install.dir"/> <mkdir dir="${aj.build.install.dir}"/> <delete dir="${aj.build.install.dir}"/> <mkdir dir="${aj.build.install.dir}"/> <java fork="true" jar="${aspectj.jar}" failonerror="true"> <arg line="-to ${aj.build.install.dir}"/> </java> </target> <target name="create-tree" depends="init-variables" unless="skip.cvs" description="create an AspectJ source tree"> <fail message="testing now - remove when validated"/> <mkdir dir="${aspectj.workspace}"/> <delete dir="${aspectj.workspace}"/> <mkdir dir="${aspectj.workspace}"/> <cvs cvsRoot=":pserver:anonymous@eclipse.org:/home/technology" dest="${aspectj.workspace}" package="org.aspectj/modules" quiet="on" failonerror="on" command="checkout -P" /> </target> <target name="build-release" depends="init-variables,create-tree" description="build an AspectJ release under Java 1.3" unless="skip.build.release"> <!-- release build destroys test build, but not vice-versa --> <antcall target="do-aspectj-build"> <param name="do.ant.target" value="clean"/> <param name="do.ant.props" value=""/> </antcall> <antcall target="do-aspectj-build"> <param name="do.ant.target" value="aspectj"/> <param name="do.ant.props" value=""/> </antcall> </target> <target name="build-tests" depends="init-variables,create-tree" description="build AspectJ tests under Java 13" unless="skip.build.tests"> <antcall target="do-aspectj-build"> <param name="do.ant.target" value="clean-jars"/> <param name="do.ant.props" value=""/> </antcall> <antcall target="do-aspectj-build"> <param name="do.ant.target" value="build-testing-jars"/> <param name="do.ant.props" value="-Dtrim.testing.default=false"/> </antcall> </target> <!-- ==== install tests ==== --> <target name="test-install"> <antcall target="do-13-target"> <param name="do.target" value="do-test-install-sequence"/> </antcall> <antcall target="do-14-target"> <param name="do.target" value="do-test-install-sequence"/> </antcall> </target> <target name="do-test-install-sequence" depends="init-variables,init-aspectj-available"> <antcall target="test-build-examples"/> <antcall target="test-ajc-aspectj"/> </target> <target name="test-build-examples" depends="init-variables,init-aspectj-available"> <antcall target="do-build-installed-example"> <param name="example.target" value="nonGui"/> </antcall> <antcall target="do-build-installed-example"> <param name="example.target" value="tracing-bc"/> </antcall> <echo message="Also setup and run compiler adapter example"/> </target> <target name="test-ajc-aspectj" depends="init-variables,init-aspectj-available,init-sources-available"> <antcall target="do-run-ant"> <param name="ant.dir" location="${aspectj.modules.dir}/tests/product/build-aspectj"/> <param name="run.ant.file" value="build.xml"/> <param name="ant.target" value=""/> <param name="ant.output" location="${aj.build.log.dir}/test-ajc-aspectj"/> </antcall> <delete quiet="on" dir="${aspectj.modules.dir}/tests/product/build-aspectj/output"/> </target> <!-- ==== source tests ==== --> <target name="test-sources"> <antcall target="do-13-target"> <param name="do.target" value="do-test-sources-sequence"/> </antcall> <antcall target="do-14-target"> <param name="do.target" value="do-test-sources-sequence"/> </antcall> </target> <target name="do-test-sources-sequence"> <antcall target="test-harness-tests"/> <antcall target="test-junit-modules"/> </target> <target name="test-junit-modules" depends="init-variables,init-junitTests-available"> <antcall target="do-run-ant"> <param name="run.ant.file" value="junitModules.xml"/> <param name="ant.target" value=""/> <param name="ant.dir" location="${aspectj.modules.dir}/tests"/> <param name="ant.output" location="${aj.build.log.dir}/test-junitModules"/> </antcall> <property file="${java.home.file}"/> <property name="tjm.copy.todir" location="${aj.build.log.dir}/junitXmlOutput-${build.java.version}"/> <mkdir dir="${tjm.copy.todir}"/> <delete quiet="on"> <fileset dir="${tjm.copy.todir}" includes="**/*"/> </delete> <property name="xmlSrcDir" location="${aspectj.tests.dir}/bin/junitXmlOutput"/> <move todir="${tjm.copy.todir}" > <fileset dir="${xmlSrcDir}" includes="**/*"/> </move> </target> <target name="test-harness-tests" depends="init-harness-available"> <!-- we could use harness variants, e.g., "-emacssym-", but separating runs puts each variant in a different output file, which makes them easier to analyze. --> <antcall target="do-run-harness"> <param name="suite.filename" value="ajcHarnessTests"/> <param name="harness.args" value="-ajctestSkipKeywords=expect-fail"/> <param name="harness.suffix" value="-pass"/> </antcall> <antcall target="do-run-harness"> <param name="suite.filename" value="ajcTestsFailing"/> <param name="harness.args" value=""/> <param name="harness.suffix" value=""/> </antcall> <antcall target="do-run-harness"> <param name="suite.filename" value="ajcTestsFailing"/> <param name="harness.args" value="-emacssym"/> <param name="harness.suffix" value="-emacssym"/> </antcall> <antcall target="do-run-harness"> <param name="suite.filename" value="ajcTests"/> <param name="harness.args" value=""/> <param name="harness.suffix" value=""/> </antcall> <antcall target="do-run-harness"> <param name="suite.filename" value="ajcTests"/> <param name="harness.args" value="-emacssym"/> <param name="harness.suffix" value="-emacssym"/> </antcall> <antcall target="do-run-harness"> <param name="suite.filename" value="ajcTests"/> <param name="harness.args" value="-ajctaskCompiler -ajctestSkipKeywords=knownLimitations-ajctaskCompiler"/> <param name="harness.suffix" value="-ajctaskCompiler"/> </antcall> <antcall target="do-run-harness"> <param name="suite.filename" value="ajcTests"/> <param name="harness.args" value="-ajdeCompiler -ajctestSkipKeywords=knownLimitations-ajdeCompiler"/> <param name="harness.suffix" value="-ajdeCompiler"/> </antcall> </target> <!-- ======= do-{...} tasks are called only by other tasks ======== --> <target name="do-run-harness" depends="init-variables,init-harness-available"> <fail unless="suite.filename" message="define suite.filename"/> <fail unless="harness.args" message="define harness.args"/> <fail unless="harness.suffix" message="define harness.suffix"/> <property name="drho.default.options" value="-release -logFail -killTemp"/> <property file="${java.home.file}"/> <fail unless="build.java.home" message="failed to read ${build.java.home} from ${java.home.file}"/> <fail unless="build.java.version" message="failed to read ${build.java.version} from ${java.home.file}"/> <property name="harness.output.file" location="${aj.build.log.dir}/test-${suite.filename}${harness.suffix}-${build.java.version}.txt"/> <echo> do-run-harness ${suite.filename}.xml with options ${drho.default.options} ${harness.args} to ${harness.output.file} </echo> <java fork="true" dir="${aspectj.tests.dir}" jar="${harness.jar}" jvm="${build.java.command}" maxmemory="250m" output="${harness.output.file}"> <arg value="${suite.filename}.xml"/> <arg line="${drho.default.options} ${harness.args}"/> </java> </target> <target name="do-build-installed-example" depends="init-variables"> <antcall target="do-run-ant"> <param name="ant.dir" location="${aj.build.install.dir}/doc/examples"/> <param name="run.ant.file" value="build.xml"/> <param name="ant.target" value="${example.target}"/> <param name="ant.output" location="${aj.build.log.dir}/test-example-${example.target}"/> <param name="ant.properties" value=""/> <!-- XXX getting OOMemory - permit and investigate --> <param name="failonerror" value="false"/> </antcall> </target> <target name="do-aspectj-build" depends="init-variables" description="build targets in ../build.xml using Java 1.3"> <fail unless="do.ant.target" message="caller sets do.ant.target"/> <fail unless="do.ant.props" message="caller sets do.ant.props"/> <antcall target="do-java13-setup"/> <antcall target="do-run-ant"> <param name="ant.dir" location="${aspectj.build.dir}"/> <param name="run.ant.file" value="build.xml"/> <param name="ant.target" value="${do.ant.target}"/> <param name="ant.output" location="${aj.build.log.dir}/build-${do.ant.target}"/> <param name="ant.properties" value="${do.ant.props}"/> </antcall> </target> <target name="do-run-ant" depends="init-variables" description="the ant we use to build"> <!-- we could use normal ant, but we enforce using our ant libraries and the specified java runtime --> <fail unless="ant.target" message="define ant.target"/> <fail unless="run.ant.file" message="define run.ant.file"/> <!-- don't fail - set if not defined --> <property name="ant.properties" value=""/> <property file="${java.home.file}"/> <fail unless="build.java.home" message="failed to read ${build.java.home} from ${java.home.file}"/> <fail unless="build.java.version" message="failed to read ${build.java.version} from ${java.home.file}"/> <property name="ant.output.file" location="${ant.output}-${build.java.version}.txt"/> <echo> do-run-ant dir ${ant.dir} file/target -f ${run.ant.file} ${ant.target} options ${ant.verbose} ${ant.properties} output ${ant.output.file} </echo> <java fork="true" dir="${ant.dir}" jvm="${build.java.command}" classname="org.apache.tools.ant.Main" maxmemory="350m" failonerror="${failonerror}" newenvironment="true" output="${ant.output.file}"> <classpath> <fileset dir="${aspectj.ant.lib.dir}"> <include name="*.jar"/> </fileset> <pathelement location="${aspectj.lib.dir}/junit/junit.jar"/> <pathelement location="${build.java.home}/lib/tools.jar"/> </classpath> <!-- urk - all properties for any client --> <!-- for any build --> <sysproperty key="JAVA_HOME" path="${build.java.home}"/> <sysproperty key="ANT_HOME" path="${aspectj.ant.home}"/> <!-- for tests/junitModules.xml --> <sysproperty key="aspectjrt.path" file="${aj.build.install.dir}/lib/aspectjrt.jar"/> <sysproperty key="test.classpath" value="jar.classpath"/> <!-- for tests/product/build-aspectj/build.xml --> <sysproperty key="ASPECTJ_MODULES" file="${aspectj.modules.dir}"/> <sysproperty key="ASPECTJ_HOME" file="${aj.build.install.dir}"/> <arg line="-f ${run.ant.file} ${ant.target} ${ant.verbose} ${ant.properties}"/> </java> </target> <target name="do-13-target" unless="run.14.only"> <antcall target="do-java13-setup"/> <antcall target="${do.target}"/> </target> <target name="do-14-target" unless="run.13.only"> <antcall target="do-java14-setup"/> <antcall target="${do.target}"/> </target> <target name="do-java14-setup"> <antcall target="do-write-javahome-file"> <param name="build.java.version" value="14"/> <param name="build.java.home" value="${java14.home}"/> </antcall> </target> <target name="do-java13-setup"> <antcall target="do-write-javahome-file"> <param name="build.java.version" value="13"/> <param name="build.java.home" value="${java13.home}"/> </antcall> </target> <target name="do-write-javahome-file" depends="init-variables" description="save global build.java.[version,command,home]"> <fail unless="build.java.version"/> <fail unless="build.java.home"/> <property name="wjf.bjh" location="${build.java.home}"/> <property name="wjf.cmd" location="${wjf.bjh}/bin/java"/> <propertyfile file="${java.home.file}"> <entry key="build.java.version" value="${build.java.version}"/> <entry key="build.java.home" value="${wjf.bjh}"/> <entry key="build.java.command" value="${wjf.cmd}"/> </propertyfile> </target> </project>