|
Groovy example source code file (build.xml)
This example Groovy source code file (build.xml) is included in the DevDaily.com
"Java Source Code
Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.
The Groovy build.xml source code
<?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: 22620 $ ($LastChangedBy: paulk $)
$Date: 2011-07-20 10:11:37 +0200 (Mi, 20. Jul 2011) $
-->
<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"/>
<condition property="_skipTests_">
<or>
<equals arg1="${test}" arg2="false"/>
<istrue value="${skipTests}"/>
</or>
</condition>
<condition property="_skipExamples_">
<istrue value="${skipExamples}"/>
</condition>
<condition property="_skipDocs_">
<istrue value="${skipDocs}"/>
</condition>
<condition property="_skipOsgi_">
<istrue value="${skipOsgi}"/>
</condition>
<condition property="_skipFetch_">
<istrue value="${skipFetch}"/>
</condition>
<condition property="_skipEmbeddable_">
<istrue value="${skipEmbeddable}"/>
</condition>
<condition property="_forceServerSettings_">
<istrue value="${forceServerSettings}"/>
</condition>
<condition property="groovy.build.vm4">
<contains string="${ant.java.version}" substring="1.4"/>
</condition>
<condition property="groovy.build.vm6">
<contains string="${ant.java.version}" substring="1.6"/>
</condition>
<presetdef name="javac">
<javac memoryMaximumSize="500m"/>
</presetdef>
<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="-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" if="groovy.build.vm4">
<fail>Aborting!
================================================
ERROR: You must build Groovy with a 1.5+ JDK
================================================
</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 string="${ant.version}" substring="1.2">
<contains string="${ant.version}" substring="1.3">
<contains string="${ant.version}" substring="1.4">
<contains string="${ant.version}" substring="1.5">
<and>
<contains string="${ant.version}" substring="1.6">
<not>
<contains string="${ant.version}" substring="${ant.requiredVersion}">
</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>
</fail>
</target>
-->
<target name="compileMain" depends="stagedcompile"
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}"/>
<mkdir dir="${mainClassesDirectory}/META-INF"/>
<javac srcdir="${mainSourcePath}" includeantruntime="false" destdir="${mainClassesDirectory}"
deprecation="on" debug="yes" source="1.5" target="1.5" fork="true" classpathref="compilePath">
<exclude name="groovy/ui/**/*.java"/>
</javac>
<java classname="org.codehaus.groovy.tools.DgmConverter"
fork="yes"
failonerror="true">
<classpath refid="compilePath"/>
<classpath path="${mainClassesDirectory}"/>
</java>
<antcall inheritrefs="true" target="-stagedcompile-groovy"/>
<antcall target="-includeResources"/>
</target>
<target name="-stagedcompile-groovy" depends="-initGroovyc">
<groovyc srcdir="${mainSourcePath}" 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="**/*.groovy"/>
<property name="vm5JavaSourceFiles" value="**/*.java"/>
<property name="anotherGroovyExtTestFiles" value="**/*.foogroovy"/>
<property name="vm6GroovySourceFiles" value="groovy/**/vm6/*Test.groovy,org/codehaus/groovy/**/vm6/*Test.groovy"/>
<target name="-initGroovyc">
<path id="groovyMainClasses">
<pathelement path="${mainClassesDirectory}"/>
<path refid="compilePath"/>
</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" depends="-initGroovyc,-compileTest_vm6">
<copy todir="${testClassesDirectory}">
<fileset dir="${testSourceDirectory}">
<include name="META-INF/services/*"/>
<include name="**/*.html"/>
</fileset>
</copy>
<groovyc srcdir="${testSourcePath}"
destdir="${testClassesDirectory}"
includes="${vm5GroovySourceFiles},${vm5JavaSourceFiles},${anotherGroovyExtTestFiles}"
excludes="${vm6GroovySourceFiles}"
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="${testSourcePath}"
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 -->
<!--
</groovyc>
</target>
<target name="compileExamples" depends="-init,-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>
</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.5" target="1.5"/>
</groovyc>
</target>
<target name="-initializeReports">
<mkdir dir="${reportsDirectory}"/>
</target>
<condition property="_shouldBeHeadless_">
<or>
<istrue value="${java.awt.headless}"/>
<!--
</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} -Dgroovy.testdb.props=${groovy.testdb.props} -DjavadocAssertion.src.dir=./src/main"/>
</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="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">
<mkdir dir="${junitRawDirectory}"/>
<junit printsummary="true" fork="true" includeantruntime="false" failureproperty="testFailed"
maxmemory="${groovyJUnit_mx}" dir="${basedir}">
<sysproperty key="apple.awt.UIElement" value="true"/>
<!-- keeps the dock from showing the AWT startup -->
<jvmarg line="${junitJvmArgs}"/>
<test name="${testCase}" todir="${junitRawDirectory}"/>
<formatter type="brief" usefile="false"/>
<classpath>
<pathelement path="${instrumentedClassesDirectory}"/>
<pathelement path="src/test"/>
<!-- TODO temp hack - remove once modules are in place -->
<pathelement path="${jmxSourceDirectory}/test/groovy"/>
<pathelement path="${jmxSourceDirectory}/test/java"/>
<pathelement path="${bsfSourceDirectory}/test/java"/>
<path refid="groovyMainClasses"/>
<path refid="testLibPath"/>
<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="-collect15tests" unless="groovy.build.vm6">
<fileset id="ubertests.fileset" dir="${testClassesDirectory}" includes="UberTest*.class" excludes="Uber*VM6.class"/>
</target>
<target name="-collect16tests" if="groovy.build.vm6">
<fileset id="ubertests.fileset" dir="${testClassesDirectory}" includes="UberTest*.class"/>
</target>
<target name="-testAll" if="_testAll_" depends="-collect15tests,-collect16tests,-collectOptionalTests,-initGroovyc">
<mkdir dir="${junitRawDirectory}"/>
<junit printsummary="true" fork="true" includeantruntime="false" failureproperty="testFailed"
maxmemory="${groovyJUnit_mx}" dir="${basedir}">
<jvmarg line="${junitJvmArgs}"/>
<sysproperty key="apple.awt.UIElement" value="true"/>
<!-- keeps the dock from showing the AWT startup -->
<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"/>
<!-- TODO temp hack - remove once modules are in place -->
<pathelement path="${jmxSourceDirectory}/test/groovy"/>
<pathelement path="${jmxSourceDirectory}/test/java"/>
<pathelement path="${bsfSourceDirectory}/test/java"/>
<path refid="groovyMainClasses"/>
<path refid="testLibPath"/>
<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"/>
</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="*"/>
<attribute name="Main-class" value="groovy.ui.GroovyMain"/>
</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="groovy/inspect/swingui/AstBrowserProperties.groovy"/>
<include name="org/codehaus/groovy/tools/shell/**/*.properties"/>
<include name="org/codehaus/groovy/tools/groovydoc/**/*.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" unless="_skipDocs_">
<delete dir="${targetDistDirectory}" quiet="true"/>
<mkdir dir="${targetDistDirectory}"/>
</target>
<target name="-createBaseJar" unless="testFailed">
<!-- TODO temp hack - some containers don't correctly handle package-info class files - remove for now -->
<jar destfile="${targetDistDirectory}/groovy.jar" basedir="${mainClassesDirectory}"
excludes="*.groovy,**/package-info.class" manifest="${mainClassesDirectory}/META-INF/MANIFEST.MF"/>
<jar destfile="${targetDistDirectory}/groovy-${groovyVersion}-sources.jar" basedir="${mainSourceDirectory}">
<!-- TODO temp hack - remove once modules are in place -->
<fileset dir="${jmxSourceDirectory}/main/java"/>
<fileset dir="${jmxSourceDirectory}/main/groovy"/>
<fileset dir="${bsfSourceDirectory}/main/java"/>
</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"/>
</target>
<target name="createJars" depends="-checkAntVersion,test,-actuallyCreateJars"
description="Build Groovy and create the jarfiles."/>
<target name="updateJarsForOsgi" unless="_skipOsgi_">
<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"/>
<property name="runtimeJars" refid="runtimePath"/>
<bndwrap definitions="${targetDistDirectory}" output="${targetDistDirectory}" failok="true"
classpath="${runtimeJars}">
<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="skipOsgi" if="_skipOsgi_">
<move todir="${targetDistDirectory}">
<fileset dir="${targetDistDirectory}" includes="groovy*.jar"/>
<globmapper from="groovy*.jar" to="groovy*-${groovyVersion}.jar"/>
</move>
</target>
<target name="install" depends="createJars,updateJarsForOsgi,skipOsgi" 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>
<!-- icon -->
<copy todir="${installDirectory}/bin" flatten="true">
<fileset dir="${toolsSourceDirectory}">
<include name="org/codehaus/groovy/tools/groovy.ico"/>
</fileset>
</copy>
<!-- Tweak scripts for platform compatibility -->
<fixcrlf srcdir="${installDirectory}/bin" eol="lf" excludes="*.bat, *.icns"/>
<fixcrlf srcdir="${installDirectory}/bin" eol="crlf" includes="*.bat"/>
<chmod perm="ugo+x">
<fileset dir="${installDirectory}/bin" includes="*,*.*"/>
</chmod>
</target>
<target name="checkstyle" depends="-init,-initializeReports,-checkstyleInit"
description="Create the code style reports.">
<!-- TODO extend checkstyle to mainSourcePath -->
<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,fulldist,cruiseReportExtras"/>
<target name="-docInit">
<mkdir dir="${docsDirectory}"/>
<property name="docFooter" value="Copyright © 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"
unless="_skipDocs_" 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"/>
<!-- TODO temp hack - remove once modules are in place -->
<fileset dir="${jmxSourceDirectory}/main/java" includes="**/*.java"/>
<fileset dir="${bsfSourceDirectory}/main/java" includes="**/*.java"/>
<link href="http://java.sun.com/javase/6/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"/>
<link href="http://commons.apache.org/cli/api-release"/>
</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>
</target>
<target name="groovydoc" depends="-fetchDependencies" unless="_skipDocs_">
<path id="groovydocpath">
<path path="${mainClassesDirectory}"/>
<path refid="runtimePath"/>
</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="${mainSourcePath}"
packagenames="**.*"
use="true"
windowtitle="${title}"
doctitle="${title}"
header="${title}"
footer="${docFooter}"
overview="src/main/overview.html">
<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="org.apache.commons.cli." href="http://commons.apache.org/cli/api-release"/>
<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.SqlGroovyMethods"/>
<arg value="org.codehaus.groovy.runtime.SwingGroovyMethods"/>
<arg value="org.codehaus.groovy.runtime.XmlGroovyMethods"/>
<arg value="org.codehaus.groovy.runtime.EncodingGroovyMethods"/>
<arg value="org.codehaus.groovy.runtime.DateGroovyMethods"/>
<arg value="org.codehaus.groovy.runtime.ProcessGroovyMethods"/>
<arg value="org.codehaus.groovy.runtime.DefaultGroovyStaticMethods"/>
<arg value="org.codehaus.groovy.vmplugin.v5.PluginDefaultGroovyMethods"/>
<arg value="org.codehaus.groovy.vmplugin.v6.PluginDefaultGroovyMethods"/>
<arg value="org.codehaus.groovy.vmplugin.v6.PluginStaticGroovyMethods"/>
</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,-deployDefault,-deployFromServer"
description="Deploy jars to maven repository."/>
<target name="-deployDefault" unless="_forceServerSettings_">
<mavenDeploy version="${groovyVersion}" prefix="groovy"/>
<mavenDeploy version="${groovyVersion}" prefix="groovy-all"/>
</target>
<target name="-deployFromServer" if="_forceServerSettings_">
<copy tofile="target/settings.xml">
<fileset file="config/maven/settings.xml"/>
<filterset>
<filter token="groovy.deploy.username" value="${groovy.deploy.username}"/>
<filter token="groovy.deploy.password" value="${groovy.deploy.password}"/>
</filterset>
</copy>
<mavenDeploySettings version="${groovyVersion}" prefix="groovy" settings="target/settings.xml"/>
<mavenDeploySettings version="${groovyVersion}" prefix="groovy-all" settings="target/settings.xml"/>
<delete file="target/settings.xml"/>
</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"/>
</target>
<target name="quality" depends="install,checkstyle" description="install plus checkstyle"/>
<target name="release" depends="deploy,compileExamples" description="deploy plus compileExamples"/>
<target name="fulldist" depends="dist,compileExamples,checkstyle" description="dist plus examples plus checkstyle"/>
<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>
</target>
</project>
Other Groovy examples (source code examples)
Here is a short list of links related to this Groovy build.xml source code file:
|