blob: 16e29d29070ec0d768144212f26cb5197feee905 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!--
Ant build script for Groovy.
Licensed 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
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is
distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied. See the License for the specific language governing permissions and limitations under the License.
This work is copyright by the author(s) and is part of a greater work collectively copyright by Codehaus on
behalf of the Groovy community. See the NOTICE.txt file distributed with this work for additional information.
Author : Russel Winder
Author : Paul King
$Revision$ ($LastChangedBy$)
$Date$
-->
<project name="Groovy" default="createJars" basedir=".">
<property file="local.build.properties"/>
<property file="build.properties"/>
<property name="ant.requiredVersion" value="1.6.5"/>
<!-- config/ant/build-maven.xml imports config/ant/build-setup.xml where all the paths are defined. -->
<import file="config/ant/build-maven.xml"/>
<import file="config/ant/build-checkstyle.xml"/>
<import file="config/ant/build-cobertura.xml"/>
<import file="config/ant/build-retro.xml"/>
<condition property="_skipTests_">
<or>
<equals arg1="${test}" arg2="false"/>
<istrue value="${skipTests}"/>
</or>
</condition>
<condition property="_forceRetro_">
<and>
<isset property="jdk14home"/>
<istrue value="${forceRetro}"/>
</and>
</condition>
<condition property="_skipExamples_">
<istrue value="${skipExamples}"/>
</condition>
<condition property="_skipFetch_">
<istrue value="${skipFetch}"/>
</condition>
<condition property="_skipEmbeddable_">
<istrue value="${skipEmbeddable}"/>
</condition>
<condition property="groovy.build.vm5">
<not>
<contains string="${ant.java.version}" substring="1.4"/>
</not>
</condition>
<condition property="groovy.build.vm6">
<contains string="${ant.java.version}" substring="1.6"/>
</condition>
<target name="-initCoverage">
<condition property="_forceCoverage_">
<and>
<not>
<istrue value="${skipTests}"/>
</not>
<istrue value="${forceCoverage}"/>
</and>
</condition>
</target>
<target name="ensureGrammars" description="Ensure all the Antlr generated files are up to date.">
<mkdir dir="${groovyParserDirectory}"/>
<antlr target="${antlrDirectory}/groovy.g" outputdirectory="${groovyParserDirectory}">
<classpath refid="compilePath"/>
</antlr>
<antlr target="${javaParserDirectory}/java.g" outputdirectory="${javaParserDirectory}">
<classpath refid="compilePath"/>
</antlr>
</target>
<target name="updatePolicy">
<move file="security/groovy.policy" tofile="security/groovy.policy.template"/>
<copy tofile="security/groovy.policy">
<fileset file="security/groovy.policy.template"/>
<filterset>
<filter token="relativePathToRealBasedir" value="${relativePathToRealBasedir}"/>
</filterset>
</copy>
</target>
<target name="-init" depends="-fetchDependencies"/>
<target name="-banner">
<echo message="Java Runtime Environment version: ${java.version}"/>
<echo message="Java Runtime Environment vendor: ${java.vendor}"/>
<echo message="Ant version: ${ant.version}"/>
<echo message="Operating system name: ${os.name}"/>
<echo message="Operating system architecture: ${os.arch}"/>
<echo message="Operating system version: ${os.version}"/>
<echo message="Base directory: ${basedir}"/>
<echo message="Java Home: ${java.home}"/>
</target>
<target name="-jvm14BuildWarning" unless="groovy.build.vm5">
<fail>Aborting!
=================================================================
ERROR: You must build Groovy with a 1.5+ JDK - but you can
run the 'testOnly' target using Java 1.4.
=================================================================
</fail>
</target>
<target name="-checkAntVersion" depends="-excludeLegacyAntVersion"
description="Check that we are running on the required version of Ant."/>
<target name="-excludeLegacyAntVersion">
<!-- antversion didn't exist in early versions of ant so we have
a legacy check to provide a nicer error message in this case -->
<fail message="You are using ant ${ant.version}, please build using ant ${ant.requiredVersion}+">
<condition>
<or>
<contains string="${ant.version}" substring="1.1"></contains>
<contains string="${ant.version}" substring="1.2"></contains>
<contains string="${ant.version}" substring="1.3"></contains>
<contains string="${ant.version}" substring="1.4"></contains>
<contains string="${ant.version}" substring="1.5"></contains>
<and>
<contains string="${ant.version}" substring="1.6"></contains>
<not>
<contains string="${ant.version}" substring="${ant.requiredVersion}"></contains>
</not>
</and>
</or>
</condition>
</fail>
</target>
<!-- add back in if we make 1.7+ minimal required version for build again
<target name="-ensureRequiredAntVersion">
<fail message="You are using ant ${ant.version}, please install using ant ${ant.requiredVersion}+"/>
<condition><not><antversion atleast="${ant.requiredVersion}"/></not></condition>
</fail>
</target>
-->
<target name="dgmConvert" depends="stagedcompile">
<java classname="org.codehaus.groovy.tools.DgmConverter"
fork="yes"
failonerror="true">
<classpath refid="compilePath"/>
<classpath path="${mainClassesDirectory}"/>
</java>
</target>
<target name="compileMain" depends="stagedcompile,dgmConvert"
description="Compile the Java and Groovy code in the main source.">
</target>
<target name="stagedcompile" depends="-init,ensureGrammars,-jvm14BuildWarning" unless="uber">
<mkdir dir="${mainClassesDirectory}"/>
<mkdir dir="${toolsClassesDirectory}"/>
<javac srcdir="${mainSourceDirectory}" destdir="${mainClassesDirectory}"
includeantruntime="false" deprecation="on" debug="yes"
memorymaximumsize="${groovycMain_mx}"
source="1.5" target="1.5" fork="true"
classpathref="compilePath">
<exclude name="groovy/ui/**/*.java"/>
</javac>
<antcall inheritrefs="true" target="-stagedcompile-groovy"/>
<antcall target="-includeResources"/>
</target>
<target name="-stagedcompile-groovy" depends="-initGroovyc">
<groovyc srcdir="${mainSourceDirectory}" destdir="${mainClassesDirectory}" fork="true" memorymaximumsize="${groovycMain_mx}">
<classpath>
<pathelement path="${mainClassesDirectory}"/>
<path refid="compilePath"/>
</classpath>
<javac deprecation="on" debug="yes" source="1.5" target="1.5"/>
</groovyc>
</target>
<property name="vm5GroovySourceFiles" value="gls/**/vm5/*Test.groovy,org/codehaus/groovy/**/vm5/*.groovy,groovy/**/vm5/*.groovy"/>
<property name="vm5JavaSourceFiles" value="org/codehaus/groovy/**/vm5/**/*.java,groovy/**/vm5/*.java,gls/**/vm5/*.java,*_VM5.java"/>
<property name="vm6GroovySourceFiles" value="groovy/**/vm6/*Test.groovy"/>
<property name="antGroovySourceFiles" value="org/codehaus/groovy/ant/**/GroovyTest*.groovy"/>
<target name="-initGroovyc" if="groovy.build.vm5">
<path id="groovyMainClasses">
<pathelement path="${mainClassesDirectory}"/>
<path refid="compilePath"/>
</path>
<taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc" classpathref="groovyMainClasses"/>
</target>
<target name="-initGroovyc_vm4" unless="groovy.build.vm5">
<property name="groovyJar14path" location="${basedir}/${relativePathToRealBasedir}/target/dist/groovy-jdk14-${groovyVersion}.jar"/>
<condition property="groovyJar14Found">
<available file="${groovyJar14path}"/>
</condition>
<fail unless="groovyJar14Found">Aborting!
Not found: ${groovyJar14path}
=================================================================
ERROR: First build Groovy with a 1.5+ JDK:
use the 'install' target
set the flag: -DforceRetro=true
set the -Djdk14home variable your 1.4 JDK basedir
then you can run the 'testOnly' target on a 1.4 jvm.
=================================================================
</fail>
<path id="groovyMainClasses">
<pathelement path="${basedir}/${relativePathToRealBasedir}/target/dist/groovy-jdk14-${groovyVersion}.jar"/>
<fileset dir="${toolsLibDirectory}">
<include name="backport-util-concurrent-*.jar"/>
<include name="retrotranslator-runtime-*.jar"/>
</fileset>
<path refid="runtimePath"/>
</path>
<taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc" classpathref="groovyMainClasses"/>
</target>
<target name="compileTest" depends="compileMain,compileTestOnly"
description="Compile the Java and Groovy code in the test source."/>
<target name="-cleanTest">
<delete dir="${testClassesDirectory}"/>
</target>
<target name="compileTestOnly" unless="_skipTests_">
<mkdir dir="${testClassesDirectory}"/>
<antcall inheritrefs="true" target="-compileTest"/>
</target>
<target name="-compileTest_vm4" depends="-initGroovyc_vm4">
<!-- compile Groovy test files excluding ones which we want to pick up from the file system -->
<groovyc srcdir="${testSourceDirectory}"
destdir="${testClassesDirectory}"
excludes="${antGroovySourceFiles},${vm5GroovySourceFiles},${vm5JavaSourceFiles},${vm6GroovySourceFiles}"
stacktrace="true"
fork="true"
memorymaximumsize="${groovycTest_mx}">
<classpath>
<pathelement path="${testClassesDirectory}"/>
<path refid="groovyMainClasses"/>
<path refid="testLibPath"/>
<path refid="jdk14ExtrasPath"/>
</classpath>
<javac source="1.4" target="1.4" nowarn="true"/>
</groovyc>
</target>
<target name="-compileTest" depends="-initGroovyc,-compileTest_vm4,-compileTest_vm6" if="groovy.build.vm5">
<groovyc srcdir="${testSourceDirectory}"
destdir="${testClassesDirectory}"
includes="${vm5GroovySourceFiles},${vm5JavaSourceFiles}"
fork="true"
memorymaximumsize="${groovycTest_mx}">
<classpath>
<pathelement path="${testClassesDirectory}"/>
<path refid="groovyMainClasses"/>
<path refid="testLibPath"/>
</classpath>
<javac source="1.5" target="1.5" nowarn="on"/>
</groovyc>
</target>
<target name="-compileTest_vm6" if="groovy.build.vm6">
<groovyc srcdir="${testSourceDirectory}"
destdir="${testClassesDirectory}"
includes="${vm6GroovySourceFiles}"
fork="true"
memorymaximumsize="${groovycTest_mx}">
<classpath>
<pathelement path="${testClassesDirectory}"/>
<path refid="groovyMainClasses"/>
<path refid="testLibPath"/>
</classpath>
<!-- currently not needed, add in if/when required -->
<!--<javac source="1.5" target="1.5" nowarn="on"/>-->
</groovyc>
</target>
<target name="compileExamples" depends="-initGroovyc,compileMain,-includeExamplesResources" unless="_skipExamples_"
description="Compile the Java and Groovy code in the examples source directory.">
<mkdir dir="${examplesClassesDirectory}"/>
<echo message="Compiling example code."/>
<groovyc srcdir="${examplesSourceDirectory}/webapps/groovlet-examples/WEB-INF/groovy"
destdir="${examplesClassesDirectory}"
fork="true"
memorymaximumsize="${groovycExamples_mx}">
<classpath>
<pathelement path="${mainClassesDirectory}"/>
<path refid="compilePath"/>
<path refid="examplesPath"/>
</classpath>
</groovyc>
<javac srcdir="${examplesSourceDirectory}"
destdir="${examplesClassesDirectory}"
source="1.5"
target="1.5"
fork="true">
<classpath>
<pathelement path="${mainClassesDirectory}"/>
<pathelement path="${examplesClassesDirectory}"/>
<path refid="compilePath"/>
<path refid="examplesPath"/>
</classpath>
<include name="org/codehaus/groovy/grails/compiler/injection/*.java" if="groovy.build.vm5"/>
</javac>
<groovyc srcdir="${examplesSourceDirectory}"
destdir="${examplesClassesDirectory}"
fork="true"
memorymaximumsize="${groovycExamples_mx}"
excludes="webapps/groovlet-examples/WEB-INF/groovy/**/*.groovy,org/codehaus/groovy/grails/compiler/injection/**/*.java">
<classpath>
<pathelement path="${mainClassesDirectory}"/>
<pathelement path="${examplesClassesDirectory}"/>
<path refid="compilePath"/>
<path refid="examplesPath"/>
</classpath>
<javac source="1.4" target="1.4"/>
</groovyc>
</target>
<target name="-initializeReports">
<mkdir dir="${reportsDirectory}"/>
</target>
<condition property="_shouldBeHeadless_">
<or>
<istrue value="${java.awt.headless}"/>
<os name="Mac OS X"/>
</or>
</condition>
<target name="-testInit" depends="-initHeadless">
<property name="headlessArg" value=""/>
<property name="junitJvmArgs"
value="-Xms${groovyJUnit_ms} -XX:PermSize=${groovyJUnit_permSize} -XX:MaxPermSize=${groovyJUnit_maxPermSize} ${headlessArg}"/>
</target>
<target name="-initHeadless" if="_shouldBeHeadless_">
<property name="headlessArg" value="-Djava.awt.headless=true"/>
<echo message="Setting headless mode ..."/>
</target>
<target name="test"
depends="-banner,-checkAntVersion,-initializeReports,compileTest,-coverageInstrument,-testInit,-testOne,-testAll,-reportTestFailed"
description="Compile and test all the classes (or just one class if testCase property is defined)."/>
<target name="testOnly"
depends="-init,-checkAntVersion,-initializeReports,-cleanTest,compileTestOnly,-coverageInstrument,-testInit,-testOne,-testAll,-reportTestFailed"/>
<target name="clean-test" depends="clean,test"
description="Clean and compile and test all the classes (or just one class if testCase property is defined)."/>
<condition property="_testOne_">
<and>
<not>
<istrue value="${_skipTests_}"/>
</not>
<isset property="testCase"/>
</and>
</condition>
<target name="-testOne" if="_testOne_" depends="-initGroovyc_vm4,-initGroovyc">
<mkdir dir="${junitRawDirectory}"/>
<junit printsummary="true" fork="true" includeantruntime="false" failureproperty="testFailed" maxmemory="${groovyJUnit_mx}" dir="${basedir}">
<jvmarg line="${junitJvmArgs}"/>
<test name="${testCase}" todir="${junitRawDirectory}"/>
<formatter type="brief" usefile="false"/>
<classpath>
<pathelement path="${instrumentedClassesDirectory}"/>
<pathelement path="src/test"/>
<path refid="groovyMainClasses"/>
<path refid="testLibPath"/>
<!-- TODO: extras only for JDK14 -->
<path refid="jdk14ExtrasPath"/>
<pathelement path="${testClassesDirectory}"/>
<path refid="coberturaPath"/>
</classpath>
<assertions>
<enable/>
</assertions>
</junit>
</target>
<condition property="_testAll_">
<and>
<not>
<istrue value="${_skipTests_}"/>
</not>
<not>
<isset property="_testOne_"/>
</not>
</and>
</condition>
<target name="-collectOptionalTests">
<condition property="networkTests.fileset.includes" value="groovy/grape/*Test.class" else="-nothing-">
<istrue value="${junit.network}"/>
</condition>
<fileset id="optionalTests.fileset" dir="${testClassesDirectory}" includes="${networkTests.fileset.includes}"/>
</target>
<target name="-collect14tests" unless="groovy.build.vm5">
<fileset id="ubertests.fileset" dir="${testClassesDirectory}" includes="UberTest*.class" excludes="Uber*VM5.class,Uber*VM6.class,Java*Suite_VM5.class,groovy/grape/*Test.class"/>
</target>
<target name="-collect15tests" if="groovy.build.vm5" unless="groovy.build.vm6">
<fileset id="ubertests.fileset" dir="${testClassesDirectory}" includes="UberTest*.class" excludes="Uber*VM6.class,groovy/grape/*Test.class"/>
</target>
<target name="-collect16tests" if="groovy.build.vm6">
<fileset id="ubertests.fileset" dir="${testClassesDirectory}" includes="UberTest*.class" excludes="groovy/grape/*Test.class"/>
</target>
<target name="-testAll" if="_testAll_" depends="-collect14tests,-collect15tests,-collect16tests,-collectOptionalTests,-initGroovyc_vm4,-initGroovyc">
<mkdir dir="${junitRawDirectory}"/>
<junit printsummary="true" fork="true" includeantruntime="false" failureproperty="testFailed" maxmemory="${groovyJUnit_mx}" dir="${basedir}">
<jvmarg line="${junitJvmArgs}"/>
<formatter type="xml"/>
<formatter type="plain" unless="noTextReports"/>
<batchtest todir="${junitRawDirectory}">
<fileset refid="ubertests.fileset"/>
<fileset refid="optionalTests.fileset"/>
</batchtest>
<classpath>
<pathelement path="${instrumentedClassesDirectory}"/>
<pathelement path="src/test"/>
<path refid="groovyMainClasses"/>
<path refid="testLibPath"/>
<!-- TODO: extras only for JDK14 -->
<path refid="jdk14ExtrasPath"/>
<pathelement path="${testClassesDirectory}"/>
<path refid="coberturaPath"/>
</classpath>
<assertions>
<enable/>
</assertions>
</junit>
<mkdir dir="${junitReportsDirectory}"/>
<junitreport tofile="${junitRawDirectory}/Results.xml">
<fileset dir="${junitRawDirectory}" includes="TEST-*.xml"/>
<report format="frames" todir="${junitReportsDirectory}"/>
</junitreport>
</target>
<target name="-reportTestFailed" depends="-coverageReport" if="testFailed">
<fail message="Test failed, not processing further targets."/>
</target>
<target name="-coverageInstrument" depends="-initCoverage,-coberturaInit" if="_forceCoverage_">
<mkdir dir="${instrumentedClassesDirectory}"/>
<coberturaInstrument classesDirectory="${mainClassesDirectory}"/>
</target>
<target name="-coverageReport" depends="-initCoverage" if="_forceCoverage_">
<coberturaReport reportDirectory="${reportsDirectory}/cobertura" sourceDirectory="${mainSourceDirectory}"/>
</target>
<target name="-actuallyCreateJars"
depends="-makeManifest,-initializeJars,-createBaseJar,-createEmbeddableJar"
unless="testFailed"/>
<target name="-makeManifest">
<mkdir dir="${mainClassesDirectory}/META-INF"/>
<copy todir="${mainClassesDirectory}/META-INF" file="LICENSE.txt"/>
<makeManifest file="${mainClassesDirectory}/META-INF/MANIFEST.MF"/>
</target>
<macrodef name="makeManifest">
<attribute name="file"/>
<attribute name="bundleEnvironment" default="J2SE-1.5"/>
<sequential>
<manifest file="@{file}">
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Extension-Name" value="groovy"/>
<attribute name="Specification-Title" value="Groovy: a powerful, dynamic language for the JVM"/>
<attribute name="Specification-Version" value="${groovyVersion}"/>
<attribute name="Specification-Vendor" value="The Codehaus"/>
<attribute name="Implementation-Title" value="Groovy: a powerful, dynamic language for the JVM"/>
<attribute name="Implementation-Version" value="${groovyVersion}"/>
<attribute name="Implementation-Vendor" value="The Codehaus"/>
<attribute name="Bundle-ManifestVersion" value="2" />
<attribute name="Bundle-Name" value="Groovy Runtime" />
<attribute name="Bundle-Description" value="Groovy Runtime" />
<attribute name="Bundle-Version" value="${groovyBundleVersion}" />
<attribute name="Bundle-Vendor" value="The Codehaus" />
<attribute name="Bundle-ClassPath" value="." />
<attribute name="Bundle-RequiredExecutionEnvironment" value="@{bundleEnvironment}" />
<attribute name="Eclipse-BuddyPolicy" value="dependent"/>
<attribute name="Eclipse-LazyStart" value="true"/>
<attribute name="DynamicImport-Package" value="*"/>
</manifest>
</sequential>
</macrodef>
<target name="-includeResources" depends="-includeGroovyDocTemplates">
<copy todir="${mainClassesDirectory}">
<fileset dir="${mainSourceDirectory}">
<include name="META-INF/services/*"/>
<include name="groovy/grape/*.xml"/>
<include name="groovy/ui/*.properties"/>
<include name="groovy/ui/**/*.png"/>
<include name="org/codehaus/groovy/tools/shell/**/*.properties"/>
<include name="org/codehaus/groovy/tools/shell/**/*.xml"/>
<include name="org/codehaus/groovy/antlib.xml"/>
</fileset>
</copy>
<antcall target="-includeReleaseInfo"/>
</target>
<target name="-includeReleaseInfo">
<copy file="${mainSourceDirectory}/META-INF/groovy-release-info.properties"
todir="${mainClassesDirectory}/META-INF" overwrite="true">
</copy>
<tstamp>
<format property="release.date" pattern="dd-MMM-yyyy"/>
<format property="release.time" pattern="hh:mm aa"/>
</tstamp>
<replace file="${mainClassesDirectory}/META-INF/groovy-release-info.properties">
<replacefilter token="##ImplementationVersion##" value="${groovyVersion}"/>
<replacefilter token="##BundleVersion##" value="${groovyBundleVersion}"/>
<replacefilter token="##BuildDate##" value="${release.date}"/>
<replacefilter token="##BuildTime##" value="${release.time}"/>
</replace>
</target>
<target name="-includeExamplesResources" depends="-includeGroovyDocTemplates">
<copy todir="${examplesClassesDirectory}">
<fileset dir="${examplesSourceDirectory}">
<include name="/swing/binding/caricature/resources/*.gif"/>
</fileset>
</copy>
</target>
<target name="-includeGroovyDocTemplates">
<copy todir="${mainClassesDirectory}">
<fileset dir="${mainSourceDirectory}">
<include name="org/codehaus/groovy/tools/groovydoc/gstringTemplates/**/*.*"/>
</fileset>
<fileset dir="${toolsSourceDirectory}">
<include name="org/codehaus/groovy/tools/groovy.ico"/>
</fileset>
</copy>
</target>
<target name="-initializeJars" depends="test">
<delete dir="${targetDistDirectory}" quiet="true"/>
<mkdir dir="${targetDistDirectory}"/>
</target>
<target name="-createBaseJar" unless="testFailed">
<jar destfile="${targetDistDirectory}/groovy.jar" basedir="${mainClassesDirectory}"
excludes="*.groovy" manifest="${mainClassesDirectory}/META-INF/MANIFEST.MF"/>
<jar destfile="${targetDistDirectory}/groovy-${groovyVersion}-sources.jar" basedir="${mainSourceDirectory}"/>
<antcall inheritrefs="true" target="-createBaseJarRetro"/>
</target>
<target name="-createBaseJarRetro" if="_forceRetro_">
<copy file="${targetDistDirectory}/groovy-${groovyVersion}-sources.jar"
tofile="${targetDistDirectory}/groovy-jdk14-${groovyVersion}-sources.jar"/>
</target>
<target name="-jarjarInit" unless="_skipEmbeddable_">
<taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask" classpathref="toolsPath"/>
</target>
<target name="-createEmbeddableJar" depends="-jarjarInit,-actuallyCreateEmbeddableJar" unless="testFailed"/>
<target name="-actuallyCreateEmbeddableJar" unless="_skipEmbeddable_">
<delete dir="${stagingDirectory}" quiet="true"/>
<mkdir dir="${stagingDirectory}"/>
<unzip dest="${stagingDirectory}">
<fileset dir="${runtimeLibDirectory}">
<include name="antlr*.jar"/>
<include name="asm*.jar"/>
<exclude name="asm-attr*.jar"/>
<exclude name="asm-util*.jar"/>
<exclude name="asm-analysis*.jar"/>
</fileset>
</unzip>
<unzip dest="${stagingDirectory}">
<fileset dir="${targetDistDirectory}">
<include name="groovy.jar"/>
</fileset>
</unzip>
<copy toDir="${stagingDirectory}/META-INF">
<fileset dir="${basedir}/config/build">
<include name="*LICENSE.txt"/>
</fileset>
</copy>
<!-- add commons-cli -->
<unzip dest="${stagingDirectory}">
<patternset>
<!-- no need for the manifest file, we have our own -->
<exclude name="META-INF/MANIFEST.MF"/>
</patternset>
<globmapper from="META-INF/LICENSE.txt" to="META-INF/CLI-LICENSE.txt"/>
<fileset dir="${runtimeLibDirectory}">
<include name="commons-cli-*.jar"/>
</fileset>
</unzip>
<makeManifest file="${stagingDirectory}/META-INF/MANIFEST.MF" />
<!-- TODO try to make use of jarjar keep ability -->
<jarjar jarfile="${targetDistDirectory}/groovy-all.jar"
manifest="${stagingDirectory}/META-INF/MANIFEST.MF">
<fileset dir="${stagingDirectory}" excludes="groovy/util/CliBuilder*.class,groovy/util/OptionAccessor*.class,org/codehaus/groovy/tools/shell/util/HelpFormatter*.class"/>
<rule pattern="antlr.**" result="groovyjarjarantlr.@1"/>
<rule pattern="org.objectweb.**" result="groovyjarjarasm.@1"/>
<rule pattern="org.apache.commons.cli.**" result="groovyjarjarcommonscli.@1"/>
</jarjar>
<jar destfile="${targetDistDirectory}/groovy-all.jar" update="true"
basedir="${stagingDirectory}" includes="groovy/util/CliBuilder*.class,groovy/util/OptionAccessor*.class,org/codehaus/groovy/tools/shell/util/HelpFormatter*.class"/>
<copy file="${targetDistDirectory}/groovy-${groovyVersion}-sources.jar"
tofile="${targetDistDirectory}/groovy-all-${groovyVersion}-sources.jar"/>
<delete dir="${stagingDirectory}" quiet="true"/>
<antcall inheritrefs="true" target="-createEmbeddableJarRetro"/>
</target>
<target name="-createEmbeddableJarRetro" if="_forceRetro_">
<copy file="${targetDistDirectory}/groovy-all-${groovyVersion}-sources.jar"
tofile="${targetDistDirectory}/groovy-all-jdk14-${groovyVersion}-sources.jar"/>
</target>
<target name="createJars" depends="-checkAntVersion,test,-actuallyCreateJars"
description="Build Groovy and create the jarfiles."/>
<target name="updateRetroJars" if="_forceRetro_">
<delete dir="${stagingDirectory}" quiet="true"/>
<mkdir dir="${stagingDirectory}"/>
<unzip dest="${stagingDirectory}">
<fileset dir="${targetDistDirectory}">
<include name="groovy-jdk14.jar"/>
</fileset>
</unzip>
<makeManifest file="${stagingDirectory}/META-INF/MANIFEST.MF" bundleEnvironment="J2SE-1.4" />
<jar basedir="${stagingDirectory}" manifest="${stagingDirectory}/META-INF/MANIFEST.MF"
destfile="${targetDistDirectory}/groovy-jdk14.jar"/>
<delete dir="${stagingDirectory}" quiet="true"/>
<mkdir dir="${stagingDirectory}"/>
<unzip dest="${stagingDirectory}">
<patternset>
<!-- we already have this -->
<exclude name="ASM-LICENSE.txt"/>
<!-- we don't need this -->
<exclude name="META-INF/maven/**/*"/>
</patternset>
<globmapper from="RETROTRANSLATOR-LICENSE.txt" to="META-INF/RETROTRANSLATOR-LICENSE.txt"/>
<fileset dir="${toolsLibDirectory}">
<include name="retrotranslator-runtime-*.jar" />
<include name="backport-util-concurrent-*.jar" />
</fileset>
</unzip>
<unzip dest="${stagingDirectory}">
<fileset dir="${targetDistDirectory}">
<include name="groovy-all-jdk14.jar"/>
</fileset>
</unzip>
<makeManifest file="${stagingDirectory}/META-INF/MANIFEST.MF" bundleEnvironment="J2SE-1.4" />
<jarjar jarfile="${targetDistDirectory}/groovy-all-jdk14.jar"
manifest="${stagingDirectory}/META-INF/MANIFEST.MF" duplicate="preserve">
<fileset dir="${stagingDirectory}"/>
<rule pattern="net.sf.retrotranslator.runtime.**" result="groovyjarjarretroruntime.@1"/>
<rule pattern="edu.emory.mathcs.backport.**" result="groovyjarjarbackport.@1"/>
</jarjar>
<delete dir="${stagingDirectory}" quiet="true"/>
</target>
<target name="updateJarsForOsgi">
<taskdef resource="aQute/bnd/ant/taskdef.properties" classpathref="toolsPath"/>
<copy todir="${targetDistDirectory}">
<fileset dir="config/bnd" includes="groovy*.bnd"/>
<filterset>
<filter token="GROOVY_BUNDLE_VERSION" value="${groovyBundleVersion}"/>
</filterset>
</copy>
<property name="jarsToWrap" value="groovy.jar,groovy-all.jar,groovy-jdk14.jar,groovy-all-jdk14.jar" />
<bndwrap definitions="${targetDistDirectory}" output="${targetDistDirectory}" failok="true">
<fileset dir="${targetDistDirectory}" includes="${jarsToWrap}"/>
</bndwrap>
<delete dir="${targetDistDirectory}" includes="${jarsToWrap}"/>
<move todir="${targetDistDirectory}">
<fileset dir="${targetDistDirectory}" includes="groovy*.bar"/>
<globmapper from="groovy*.bar" to="groovy*-${groovyVersion}.jar"/>
</move>
<delete dir="${targetDistDirectory}" includes="groovy*.bnd"/>
</target>
<target name="install" depends="createJars,translate,updateRetroJars,updateJarsForOsgi" unless="testFailed"
description="Create an installation hierarchy in target/install.">
<!--
FIXME: It's not really a good idea to delete stuff, as it tends to negate Ant's (or other tools)
ability to run faster incremental builds.
-->
<delete dir="${installDirectory}" quiet="true"/>
<mkdir dir="${installDirectory}"/>
<!-- Install license files -->
<copy todir="${installDirectory}">
<fileset dir="${basedir}">
<include name="LICENSE.txt"/>
<include name="NOTICE.txt"/>
</fileset>
</copy>
<unzip dest="${installDirectory}">
<patternset>
<include name="META-INF/*-LICENSE.txt"/>
</patternset>
<mapper type="flatten"/>
<fileset file="${targetDistDirectory}/groovy-all-${groovyVersion}.jar"/>
</unzip>
<fixcrlf srcdir="${installDirectory}" eol="crlf" includes="*.txt"/>
<!-- Install generated artifacts and runtime dependencies -->
<mkdir dir="${installDirectory}/lib"/>
<copy todir="${installDirectory}/lib">
<fileset dir="${targetDistDirectory}" includes="groovy-${groovyVersion}.jar"/>
<fileset dir="${runtimeLibDirectory}" includes="*.jar"/>
</copy>
<!-- Install the embeddable bits -->
<mkdir dir="${installDirectory}/embeddable"/>
<copy todir="${installDirectory}/embeddable">
<fileset dir="${targetDistDirectory}" includes="groovy-all-${groovyVersion}.jar"/>
</copy>
<!-- Install configuration files -->
<mkdir dir="${installDirectory}/conf"/>
<copy toDir="${installDirectory}/conf">
<fileset dir="${sourceDirectory}/conf" includes="*"/>
</copy>
<!-- Install scripts -->
<mkdir dir="${installDirectory}/bin"/>
<copy toDir="${installDirectory}/bin">
<fileset dir="${sourceDirectory}/bin" includes="*"/>
<filterset>
<filter token="GROOVYJAR" value="groovy-${groovyVersion}.jar"/>
</filterset>
</copy>
<!-- Tweak scripts for platform compatibility -->
<fixcrlf srcdir="${installDirectory}/bin" eol="lf" excludes="*.bat"/>
<fixcrlf srcdir="${installDirectory}/bin" eol="crlf" includes="*.bat"/>
<chmod perm="ugo+x">
<fileset dir="${installDirectory}/bin" includes="*,*.*"/>
</chmod>
</target>
<target name="translate" depends="-retroInit" if="_forceRetro_">
<retroArtifact basedir="${targetDistDirectory}" artifact="groovy"/>
<retroArtifact basedir="${targetDistDirectory}" artifact="groovy-all"/>
</target>
<target name="checkstyle" depends="-init,-initializeReports,-checkstyleInit"
description="Create the code style reports.">
<checkAndReport
reportDirectory="${reportsDirectory}/checkstyle"
sourceDirectory="${mainSourceDirectory}"
excludes="org/codehaus/groovy/antlr/parser/*,org/codehaus/groovy/antlr/java/*,org/codehaus/groovy/syntax/Types.java">
<path>
<pathelement path="${mainClassesDirectory}"/>
<path refid="testLibPath"/>
</path>
</checkAndReport>
</target>
<target name="-compileTools" depends="-initGroovyc,compileMain">
<groovyc srcdir="${toolsSourceDirectory}" destdir="${toolsClassesDirectory}" fork="true">
<classpath>
<path refid="toolsPath"/>
<pathelement path="${mainClassesDirectory}"/>
<path refid="compilePath"/>
</classpath>
</groovyc>
<copy todir="${toolsClassesDirectory}">
<fileset dir="${toolsSourceDirectory}">
<include name="**/*.html"/>
</fileset>
</copy>
</target>
<target name="cruiseReportExtras">
<mkdir dir="${cruiseReportRootDirectory}"/>
<copy todir="${cruiseReportRootDirectory}">
<fileset dir="cruise/html"/>
</copy>
</target>
<target name="cruiseInit">
<property name="noTextReports" value="true"/>
<property name="forceCoverage" value="true"/>
<delete dir="${reportsDirectory}" quiet="true" failonerror="false"/>
<delete dir="${junitRawDirectory}" quiet="true" failonerror="false"/>
</target>
<target name="cruise" depends="cruiseInit,dist,compileExamples,checkstyle,cruiseReportExtras"/>
<target name="-docInit">
<mkdir dir="${docsDirectory}"/>
<property name="docFooter" value="Copyright &amp;copy; 2003-2010 The Codehaus. All rights reserved."/>
<property name="title" value="Groovy ${groovyVersion}"/>
</target>
<target name="doc" depends="javadoc, groovydoc" description="Create the documentation."/>
<target name="javadoc" depends="-fetchDependencies,-docInit,-jvm14BuildWarning,ensureGrammars"
description="Create the javadoc documentation.">
<javadoc destdir="${docsDirectory}/api" author="true" version="true"
windowtitle="${title}" doctitle="${title}"
encoding="ISO-8859-1" useexternalfile="true" source="1.5"
footer="${docFooter}"
overview="src/main/overviewj.html"
maxmemory="${javaDoc_mx}"
>
<classpath>
<path path="${mainClassesDirectory}"/>
<path refid="compilePath"/>
</classpath>
<fileset dir="${mainSourceDirectory}" includes="**/*.java"/>
<link href="http://java.sun.com/j2se/1.5.0/docs/api"/>
<link href="http://www.dpml.net/api/ant/1.7.0"/>
<link href="http://junit.sourceforge.net/junit3.8.1/javadoc/"/>
<link href="http://java.sun.com/j2ee/1.4/docs/api"/>
<link href="http://www.antlr2.org/javadoc"/>
</javadoc>
<mkdir dir="${targetDistDirectory}"/>
<jar basedir="${docsDirectory}/api" destfile="${targetDistDirectory}/groovy-${groovyVersion}-javadoc.jar"/>
<copy toFile="${targetDistDirectory}/groovy-all-${groovyVersion}-javadoc.jar">
<fileset file="${targetDistDirectory}/groovy-${groovyVersion}-javadoc.jar"/>
</copy>
<antcall inheritrefs="true" target="-javadocRetro"/>
</target>
<target name="-javadocRetro" if="_forceRetro_">
<copy toFile="${targetDistDirectory}/groovy-all-jdk14-${groovyVersion}-javadoc.jar">
<fileset file="${targetDistDirectory}/groovy-all-${groovyVersion}-javadoc.jar"/>
</copy>
<copy toFile="${targetDistDirectory}/groovy-jdk14-${groovyVersion}-javadoc.jar">
<fileset file="${targetDistDirectory}/groovy-${groovyVersion}-javadoc.jar"/>
</copy>
</target>
<target name="groovydoc" depends="-fetchDependencies">
<path id="groovydocpath">
<path path="${mainClassesDirectory}"/>
<path refid="runtimePath"/>
<path path="${java.class.path}"/>
</path>
<antforked target="realgroovydoc" maxmemory="${groovyDoc_mx}" classpathref="groovydocpath"/>
</target>
<target name="realgroovydoc" depends="-fetchDependencies,-docInit,-includeGroovyDocTemplates,docGDK">
<taskdef name="groovydoc" classname="org.codehaus.groovy.ant.Groovydoc">
<classpath>
<path path="${mainClassesDirectory}"/>
<path refid="compilePath"/>
</classpath>
</taskdef>
<groovydoc
destdir="${docsDirectory}/gapi"
sourcepath="${mainSourceDirectory}"
packagenames="**.*"
use="true"
windowtitle="${title}"
doctitle="${title}"
header="${title}"
footer="${docFooter}"
overview="src/main/overview.html"
private="false">
<link packages="javax.servlet.,javax.management." href="http://java.sun.com/j2ee/1.4/docs/api"/>
<link packages="java.,org.xml.,javax.,org.xml." href="http://java.sun.com/javase/6/docs/api/"/>
<link packages="org.apache.ant.,org.apache.tools.ant." href="http://www.dpml.net/api/ant/1.7.0"/>
<link packages="org.junit.,junit." href="http://junit.sourceforge.net/junit3.8.1/javadoc/"/>
<link packages="antlr." href="http://www.antlr2.org/javadoc/"/>
</groovydoc>
</target>
<target name="docGDK" depends="-fetchDependencies,-compileTools" description="Create the GDK documentation">
<java classname="org.codehaus.groovy.tools.DocGenerator" fork="yes" failonerror="true">
<classpath>
<pathelement path="${toolsClassesDirectory}"/>
<path refid="toolsPath"/>
<pathelement path="${mainClassesDirectory}"/>
</classpath>
<arg value="org.codehaus.groovy.runtime.DefaultGroovyMethods"/>
<arg value="org.codehaus.groovy.runtime.DefaultGroovyStaticMethods"/>
<arg value="org.codehaus.groovy.vmplugin.v5.PluginDefaultGroovyMethods"/>
</java>
<copy todir="target/html/groovy-jdk" file="src/tools/org/codehaus/groovy/tools/groovy.ico"/>
<copy todir="target/html/groovy-jdk" file="src/tools/org/codehaus/groovy/tools/stylesheet.css"/>
</target>
<target name="clean" description="Clean up build artifacts.">
<delete dir="${targetDirectory}" quiet="true"/>
<delete file="cobertura.ser" quiet="true" failonerror="false"/>
<delete quiet="true">
<fileset dir="." includes="**/*~"/>
<fileset dir="${groovyParserDirectory}" includes="Groovy*.*"/>
<fileset dir="${javaParserDirectory}" includes="JavaLexer.java,JavaRecognizer.java,JavaTokenTypes.java,JavaTokenTypes.txt,*.smap"/>
</delete>
</target>
<target name="deploy" depends="-mavenDeployInit,install,doc,-deployPlainOnly,-deployPlainAndRetro"
description="Deploy jars to maven repository."/>
<target name="-deployPlainOnly" unless="_forceRetro_">
<mavenDeploy version="${groovyVersion}" prefix="groovy"/>
<mavenDeploy version="${groovyVersion}" prefix="groovy-all"/>
</target>
<target name="-deployPlainAndRetro" if="_forceRetro_">
<!-- these were overwritten, so set them again -->
<maven.pom file="${targetDirectory}/groovy-jdk14.pom" id="groovy-jdk14.pom"/>
<maven.pom file="${targetDirectory}/groovy-all-jdk14.pom" id="groovy-all-jdk14.pom"/>
<!-- do them all in one hit like this because the maven ant libs like it that way -->
<mavenDeploy version="${groovyVersion}" prefix="groovy"/>
<mavenDeploy version="${groovyVersion}" prefix="groovy-all"/>
<mavenDeploy version="${groovyVersion}" prefix="groovy-jdk14"/>
<mavenDeploy version="${groovyVersion}" prefix="groovy-all-jdk14"/>
</target>
<target name="installRepo" depends="-mavenInit,install,doc"
description="Deploy artifacts to local maven repository.">
<mavenInstallRepo version="${groovyVersion}" prefix="groovy"/>
<mavenInstallRepo version="${groovyVersion}" prefix="groovy-all"/>
<antcall inheritrefs="true" target="-installRepoRetro"/>
</target>
<target name="-installRepoRetro" if="_forceRetro_">
<maven.pom file="${targetDirectory}/groovy-jdk14.pom" id="groovy-jdk14.pom"/>
<mavenInstallRepo version="${groovyVersion}" prefix="groovy-jdk14"/>
<maven.pom file="${targetDirectory}/groovy-all-jdk14.pom" id="groovy-all-jdk14.pom"/>
<mavenInstallRepo version="${groovyVersion}" prefix="groovy-all-jdk14"/>
</target>
<target name="dist" depends="install,doc" description="Create everything needed for a distribution.">
<zip destfile="${targetDistDirectory}/groovy-binary-${groovyVersion}.zip"
comment="The Groovy ${groovyVersion} binary distribution.">
<!-- Make unix scripts executable -->
<zipfileset dir="${installDirectory}" prefix="groovy-${groovyVersion}" filemode="775">
<include name="bin/*"/>
<exclude name="bin/*.*"/>
<exclude name="bin/startGroovy*"/>
</zipfileset>
<!-- Include the other scripts as is -->
<zipfileset dir="${installDirectory}" prefix="groovy-${groovyVersion}">
<include name="bin/*.*"/>
<include name="bin/startGroovy*"/>
</zipfileset>
<!-- Include everything else as is too -->
<zipfileset dir="${installDirectory}" prefix="groovy-${groovyVersion}">
<exclude name="bin/**"/>
<include name="**"/>
</zipfileset>
</zip>
<zip destfile="${targetDistDirectory}/groovy-docs-${groovyVersion}.zip"
comment="The Groovy ${groovyVersion} documentation distribution.">
<zipfileset dir="${wikiPdfDirectory}" includes="wiki-snapshot.pdf" prefix="groovy-${groovyVersion}/pdf"/>
<zipfileset dir="${docsDirectory}" prefix="groovy-${groovyVersion}/html"/>
</zip>
<zip destfile="${targetDistDirectory}/groovy-src-${groovyVersion}.zip"
comment="The Groovy ${groovyVersion} source distribution.">
<zipfileset dir="${basedir}" prefix="groovy-${groovyVersion}">
<!-- Exclude generated bits as well as any other bits that shouldn't make it in -->
<exclude name="${targetDirectory}/**"/>
<exclude name="classes/**"/>
<exclude name="cruise/**"/>
<exclude name=".clover/*"/>
<exclude name="local.build.properties"/>
<exclude name="cobertura.ser"/>
<exclude name="junitvmwatcher*.properties"/>
</zipfileset>
</zip>
<antcall inheritrefs="true" target="-distRetro"/>
</target>
<target name="-distRetro" if="_forceRetro_">
<mkdir dir="${stagingDirectory}" />
<mkdir dir="${stagingDirectory}/lib" />
<mkdir dir="${stagingDirectory}/embeddable" />
<copy todir="${stagingDirectory}/lib">
<fileset file="${targetDistDirectory}/groovy-jdk14-${groovyVersion}.jar"/>
<globmapper from="groovy-jdk14-${groovyVersion}.jar" to="groovy-${groovyVersion}.jar"/>
</copy>
<copy todir="${stagingDirectory}/embeddable">
<fileset file="${targetDistDirectory}/groovy-all-jdk14-${groovyVersion}.jar"/>
<globmapper from="groovy-all-jdk14-${groovyVersion}.jar" to="groovy-all-${groovyVersion}.jar"/>
</copy>
<copy todir="${stagingDirectory}/lib">
<fileset dir="${toolsLibDirectory}">
<include name="backport-util-concurrent-*.jar"/>
<include name="retrotranslator-runtime-*.jar"/>
</fileset>
</copy>
<copy todir="${stagingDirectory}/lib">
<fileset dir="${extrasLibDirectory}"/>
</copy>
<zip destfile="${targetDistDirectory}/groovy-binary-jdk14-${groovyVersion}.zip"
comment="The Groovy jdk14 ${groovyVersion} binary distribution.">
<!-- Make unix scripts executable -->
<zipfileset dir="${installDirectory}" prefix="groovy-${groovyVersion}" filemode="775">
<include name="bin/*"/>
<exclude name="bin/*.*"/>
<exclude name="bin/startGroovy*"/>
</zipfileset>
<!-- Include the other scripts as is -->
<zipfileset dir="${installDirectory}" prefix="groovy-${groovyVersion}">
<include name="bin/*.*"/>
<include name="bin/startGroovy*"/>
</zipfileset>
<!-- Include everything else as is too -->
<zipfileset dir="${installDirectory}" prefix="groovy-${groovyVersion}">
<exclude name="bin/**"/>
<exclude name="**/groovy*.jar"/>
<include name="**"/>
</zipfileset>
<!-- now the differences to normal zip -->
<zipfileset dir="${stagingDirectory}" prefix="groovy-${groovyVersion}"/>
</zip>
</target>
</project>