1 <?xml version="1.0" encoding="UTF-8"?>
4 Ant build script for Groovy.
6 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
7 compliance with the License. You may obtain a copy of the License at
9 http://www.apache.org/licenses/LICENSE-2.0
11 Unless required by applicable law or agreed to in writing, software distributed under the License is
12 distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13 implied. See the License for the specific language governing permissions and limitations under the License.
15 This work is copyright by the author(s) and is part of a greater work collectively copyright by Codehaus on
16 behalf of the Groovy community. See the NOTICE.txt file distributed with this work for additional information.
18 Author : Russel Winder
20 $Revision$ ($LastChangedBy$)
24 <project name="Groovy" default="createJars" basedir=".">
26 <property file="local.build.properties"/>
27 <property file="build.properties"/>
28 <property name="ant.requiredVersion" value="1.6.5"/>
30 <!-- config/ant/build-maven.xml imports config/ant/build-setup.xml where all the paths are defined. -->
31 <import file="config/ant/build-maven.xml"/>
32 <import file="config/ant/build-checkstyle.xml"/>
33 <import file="config/ant/build-cobertura.xml"/>
34 <import file="config/ant/build-retro.xml"/>
36 <condition property="_skipTests_">
38 <equals arg1="${test}" arg2="false"/>
39 <istrue value="${skipTests}"/>
43 <condition property="_forceRetro_">
45 <isset property="jdk14home"/>
46 <istrue value="${forceRetro}"/>
50 <condition property="_skipExamples_">
51 <istrue value="${skipExamples}"/>
54 <condition property="_skipFetch_">
55 <istrue value="${skipFetch}"/>
58 <condition property="groovy.build.vm5">
60 <contains string="${ant.java.version}" substring="1.4"/>
64 <target name="-initCoverage">
65 <condition property="_forceCoverage_">
68 <istrue value="${skipTests}"/>
70 <istrue value="${forceCoverage}"/>
75 <target name="ensureGrammars" description="Ensure all the Antlr generated files are up to date.">
76 <mkdir dir="${groovyParserDirectory}"/>
77 <antlr target="${antlrDirectory}/groovy.g" outputdirectory="${groovyParserDirectory}">
78 <classpath refid="compilePath"/>
80 <antlr target="${javaParserDirectory}/java.g" outputdirectory="${javaParserDirectory}">
81 <classpath refid="compilePath"/>
85 <target name="updatePolicy">
86 <move file="security/groovy.policy" tofile="security/groovy.policy.template"/>
87 <copy tofile="security/groovy.policy">
88 <fileset file="security/groovy.policy.template"/>
90 <filter token="relativePathToRealBasedir" value="${relativePathToRealBasedir}"/>
95 <target name="-init" depends="-fetchDependencies"/>
97 <target name="-banner">
98 <echo message="Java Runtime Environment version: ${java.version}"/>
99 <echo message="Java Runtime Environment vendor: ${java.vendor}"/>
100 <echo message="Ant version: ${ant.version}"/>
101 <echo message="Operating system name: ${os.name}"/>
102 <echo message="Operating system architecture: ${os.arch}"/>
103 <echo message="Operating system version: ${os.version}"/>
104 <echo message="Base directory: ${basedir}"/>
105 <echo message="Java Home: ${java.home}"/>
108 <target name="-jvm14BuildWarning" unless="groovy.build.vm5">
111 =================================================================
112 ERROR: You must build Groovy with a 1.5+ JDK - but you can
113 run the 'testOnly' target using Java 1.4.
114 =================================================================
118 <target name="-checkAntVersion" depends="-excludeLegacyAntVersion"
119 description="Check that we are running on the required version of Ant."/>
121 <target name="-excludeLegacyAntVersion">
122 <!-- antversion didn't exist in early versions of ant so we have
123 a legacy check to provide a nicer error message in this case -->
124 <fail message="You are using ant ${ant.version}, please build using ant ${ant.requiredVersion}+">
127 <contains string="${ant.version}" substring="1.1"></contains>
128 <contains string="${ant.version}" substring="1.2"></contains>
129 <contains string="${ant.version}" substring="1.3"></contains>
130 <contains string="${ant.version}" substring="1.4"></contains>
131 <contains string="${ant.version}" substring="1.5"></contains>
133 <contains string="${ant.version}" substring="1.6"></contains>
135 <contains string="${ant.version}" substring="${ant.requiredVersion}"></contains>
143 <!-- add back in if we make 1.7+ minimal required version for build again
144 <target name="-ensureRequiredAntVersion">
145 <fail message="You are using ant ${ant.version}, please install using ant ${ant.requiredVersion}+"/>
146 <condition><not><antversion atleast="${ant.requiredVersion}"/></not></condition>
151 <target name="dgmConvert" depends="ubercompile,stagedcompile">
152 <java classname="org.codehaus.groovy.tools.DgmConverter"
155 <classpath refid="compilePath"/>
156 <classpath path="${mainClassesDirectory}"/>
160 <target name="compileMain" depends="ubercompile,stagedcompile,dgmConvert"
161 description="Compile the Java and Groovy code in the main source.">
164 <target name="stagedcompile" depends="-init,-includeResources,ensureGrammars,-jvm14BuildWarning" unless="uber">
165 <mkdir dir="${mainClassesDirectory}"/>
166 <mkdir dir="${toolsClassesDirectory}"/>
168 <javac srcdir="${mainSourceDirectory}" includeantruntime="false" destdir="${mainClassesDirectory}"
169 deprecation="on" debug="yes" source="1.5" target="1.5" fork="true" classpathref="compilePath">
170 <exclude name="groovy/ui/**/*.java"/>
172 <antcall inheritall="true" target="-stagedcompile-groovy"/>
175 <target name="-stagedcompile-groovy" depends="-initGroovyc">
176 <groovyc srcdir="${mainSourceDirectory}" destdir="${mainClassesDirectory}" fork="true" memorymaximumsize="${groovycMain_mx}">
178 <pathelement path="${mainClassesDirectory}"/>
179 <path refid="compilePath"/>
181 <javac deprecation="on" debug="yes" source="1.5" target="1.5"/>
185 <target name="-ubercompile:bootstrap" depends="-init,-includeResources,ensureGrammars" if="uber">
186 <mkdir dir="${mainClassesDirectory}"/>
188 <javac destdir="${mainClassesDirectory}" deprecation="on" debug="yes" source="1.5"
189 target="1.5" fork="true" includeantruntime="false">
190 <classpath refid="compilePath"/>
191 <src location="${mainSourceDirectory}"/>
194 NOTE: This list includes *most* of the classes which are required for the ubercompile
195 bits to work, adding them here to allow for more incremental compilation when
196 required support classes change.
199 <include name="groovy/lang/**/*.java"/>
200 <include name="org/codehaus/groovy/ant/**/*.java"/>
201 <include name="org/codehaus/groovy/antlr/**/*.java"/>
202 <include name="org/codehaus/groovy/ast/**/*.java"/>
203 <include name="org/codehaus/groovy/classgen/**/*.java"/>
204 <include name="org/codehaus/groovy/control/**/*.java"/>
205 <include name="org/codehaus/groovy/reflection/**/*.java"/>
206 <include name="org/codehaus/groovy/runtime/**/*.java"/>
207 <include name="org/codehaus/groovy/syntax/**/*.java"/>
208 <include name="org/codehaus/groovy/tools/javac/**/*.java"/>
211 <taskdef name="ubercompile" classname="org.codehaus.groovy.ant.UberCompileTask">
213 <pathelement location="${mainClassesDirectory}"/>
214 <path refid="compilePath"/>
219 <target name="ubercompile" depends="-ubercompile:bootstrap" if="uber">
220 <mkdir dir="${mainStubsDirectory}"/>
222 <ubercompile destdir="${mainClassesDirectory}">
224 <pathelement location="${mainClassesDirectory}"/>
225 <path refid="compilePath"/>
227 <src location="${mainSourceDirectory}"/>
229 <generatestubs destdir="${mainStubsDirectory}" includes="**/*.groovy">
230 <configuration targetBytecode="1.5"/>
233 <javac includeantruntime="false" deprecation="on" debug="yes" source="1.5" target="1.5" fork="true"/>
234 <groovyc includes="**/*.groovy">
235 <configuration debug="true" verbose="true"/>
240 <property name="vm5GroovySourceFiles" value="gls/**/vm5/*Test.groovy,org/codehaus/groovy/**/vm5/**/*.groovy,groovy/**/vm5/**/*.groovy"/>
241 <property name="vm5JavaSourceFiles" value="org/codehaus/groovy/**/vm5/**/*.java,groovy/**/vm5/**/*.java"/>
242 <property name="antGroovySourceFiles" value="org/codehaus/groovy/ant/**/GroovyTest*.groovy"/>
244 <target name="-initGroovyc" if="groovy.build.vm5">
245 <path id="groovyMainClasses">
246 <pathelement path="${mainClassesDirectory}"/>
247 <path refid="compilePath"/>
249 <taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc" classpathref="groovyMainClasses"/>
252 <target name="-initGroovyc_vm4" unless="groovy.build.vm5">
253 <property name="groovyJar14path" location="${basedir}/${relativePathToRealBasedir}/target/dist/groovy-jdk14-${groovyVersion}.jar"/>
254 <condition property="groovyJar14Found">
255 <available file="${groovyJar14path}"/>
257 <fail unless="groovyJar14Found">Aborting!
259 Not found: ${groovyJar14path}
261 =================================================================
262 ERROR: First build Groovy with a 1.5+ JDK:
263 use the 'install' target
264 set the flag: -DforceRetro=true
265 set the -Djdk14home variable your 1.4 JDK basedir
266 then you can run the 'testOnly' target on a 1.4 jvm.
267 =================================================================
269 <path id="groovyMainClasses">
270 <pathelement path="${basedir}/${relativePathToRealBasedir}/target/dist/groovy-jdk14-${groovyVersion}.jar"/>
271 <fileset dir="${toolsLibDirectory}">
272 <include name="backport-util-concurrent-3.1.jar"/>
273 <include name="retrotranslator-runtime-1.2.4.jar"/>
275 <path refid="runtimePath"/>
277 <taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc" classpathref="groovyMainClasses"/>
280 <target name="compileTest" depends="compileMain,compileTestOnly"
281 description="Compile the Java and Groovy code in the test source."/>
283 <target name="-cleanTest">
284 <delete dir="${testClassesDirectory}"/>
287 <target name="compileTestOnly" unless="_skipTests_">
288 <mkdir dir="${testClassesDirectory}"/>
289 <antcall inheritall="true" target="-compileTest"/>
292 <target name="-compileTest_vm4" depends="-initGroovyc_vm4">
293 <!-- compile Groovy test files excluding ones which we want to pick up from the file system -->
294 <groovyc srcdir="${testSourceDirectory}"
295 destdir="${testClassesDirectory}"
296 excludes="${antGroovySourceFiles},${vm5GroovySourceFiles},${vm5JavaSourceFiles}"
299 memorymaximumsize="${groovycTest_mx}">
301 <pathelement path="${testClassesDirectory}"/>
302 <path refid="groovyMainClasses"/>
303 <path refid="testLibPath"/>
304 <path refid="jdk14ExtrasPath"/>
306 <javac source="1.4" target="1.4" nowarn="true"/>
310 <target name="-compileTest" depends="-initGroovyc,-compileTest_vm4" if="groovy.build.vm5">
311 <groovyc srcdir="${testSourceDirectory}"
312 destdir="${testClassesDirectory}"
313 includes="${vm5GroovySourceFiles},${vm5JavaSourceFiles}"
315 memorymaximumsize="${groovycTest_mx}">
317 <pathelement path="${testClassesDirectory}"/>
318 <path refid="groovyMainClasses"/>
319 <path refid="testLibPath"/>
321 <javac source="1.5" target="1.5" nowarn="on"/>
325 <target name="compileExamples" depends="-initGroovyc,compileMain,-includeExamplesResources" unless="_skipExamples_"
326 description="Compile the Java and Groovy code in the examples source directory.">
327 <mkdir dir="${examplesClassesDirectory}"/>
328 <echo message="Compiling example code."/>
330 <groovyc srcdir="${examplesSourceDirectory}/webapps/groovlet-examples/WEB-INF/groovy"
331 destdir="${examplesClassesDirectory}"
333 memorymaximumsize="${groovycExamples_mx}">
335 <pathelement path="${mainClassesDirectory}"/>
336 <path refid="compilePath"/>
337 <path refid="examplesPath"/>
340 <javac srcdir="${examplesSourceDirectory}"
341 destdir="${examplesClassesDirectory}"
346 <pathelement path="${mainClassesDirectory}"/>
347 <pathelement path="${examplesClassesDirectory}"/>
348 <path refid="compilePath"/>
349 <path refid="examplesPath"/>
351 <include name="org/codehaus/groovy/grails/compiler/injection/*.java" if="groovy.build.vm5"/>
353 <groovyc srcdir="${examplesSourceDirectory}"
354 destdir="${examplesClassesDirectory}"
356 memorymaximumsize="${groovycExamples_mx}"
357 excludes="webapps/groovlet-examples/WEB-INF/groovy/**/*.groovy,org/codehaus/groovy/grails/compiler/injection/**/*.java">
359 <pathelement path="${mainClassesDirectory}"/>
360 <pathelement path="${examplesClassesDirectory}"/>
361 <path refid="compilePath"/>
362 <path refid="examplesPath"/>
364 <javac source="1.4" target="1.4"/>
369 <target name="-initializeReports">
370 <mkdir dir="${reportsDirectory}"/>
373 <condition property="_shouldBeHeadless_">
375 <istrue value="${java.awt.headless}"/>
376 <os name="Mac OS X"/>
380 <target name="-testInit" depends="-initHeadless">
381 <property name="headlessArg" value=""/>
382 <property name="junitJvmArgs"
383 value="-Xms${groovyJUnit_ms} -XX:PermSize=${groovyJUnit_permSize} -XX:MaxPermSize=${groovyJUnit_maxPermSize} ${headlessArg}"/>
386 <target name="-initHeadless" if="_shouldBeHeadless_">
387 <property name="headlessArg" value="-Djava.awt.headless=true"/>
388 <echo message="Setting headless mode ..."/>
392 depends="-banner,-checkAntVersion,-initializeReports,compileTest,-coverageInstrument,-testInit,-testOne,-testAll,-reportTestFailed"
393 description="Compile and test all the classes (or just one class if testCase property is defined)."/>
395 <target name="testOnly"
396 depends="-init,-checkAntVersion,-initializeReports,-cleanTest,compileTestOnly,-coverageInstrument,-testInit,-testOne,-testAll,-reportTestFailed"/>
398 <target name="clean-test" depends="clean,test"
399 description="Clean and compile and test all the classes (or just one class if testCase property is defined)."/>
401 <condition property="_testOne_">
404 <istrue value="${_skipTests_}"/>
406 <isset property="testCase"/>
410 <target name="-testOne" if="_testOne_" depends="-initGroovyc_vm4,-initGroovyc">
411 <mkdir dir="${junitRawDirectory}"/>
412 <junit printsummary="true" fork="true" includeantruntime="false" failureproperty="testFailed" maxmemory="${groovyJUnit_mx}" dir="${basedir}">
413 <jvmarg line="${junitJvmArgs}"/>
414 <test name="${testCase}" todir="${junitRawDirectory}"/>
415 <formatter type="brief" usefile="false"/>
417 <pathelement path="${instrumentedClassesDirectory}"/>
418 <pathelement path="src/test"/>
419 <path refid="groovyMainClasses"/>
420 <path refid="testLibPath"/>
421 <!-- TODO: extras only for JDK14 -->
422 <path refid="jdk14ExtrasPath"/>
423 <pathelement path="${testClassesDirectory}"/>
424 <path refid="coberturaPath"/>
429 <condition property="_testAll_">
432 <istrue value="${_skipTests_}"/>
435 <isset property="_testOne_"/>
440 <target name="-collect14tests" unless="groovy.build.vm5">
441 <fileset id="ubertests.fileset" dir="${testClassesDirectory}" includes="UberTest*.class" excludes="Uber*VM5.class"/>
444 <target name="-collect15tests" if="groovy.build.vm5">
445 <fileset id="ubertests.fileset" dir="${testClassesDirectory}" includes="UberTest*.class"/>
448 <target name="-testAll" if="_testAll_" depends="-collect14tests,-collect15tests,-initGroovyc_vm4,-initGroovyc">
449 <mkdir dir="${junitRawDirectory}"/>
450 <junit printsummary="true" fork="true" includeantruntime="false" failureproperty="testFailed" maxmemory="${groovyJUnit_mx}" dir="${basedir}">
451 <jvmarg line="${junitJvmArgs}"/>
452 <formatter type="xml"/>
453 <formatter type="plain" unless="noTextReports"/>
454 <batchtest todir="${junitRawDirectory}">
455 <fileset refid="ubertests.fileset"/>
458 <pathelement path="${instrumentedClassesDirectory}"/>
459 <pathelement path="src/test"/>
460 <path refid="groovyMainClasses"/>
461 <path refid="testLibPath"/>
462 <!-- TODO: extras only for JDK14 -->
463 <path refid="jdk14ExtrasPath"/>
464 <pathelement path="${testClassesDirectory}"/>
465 <path refid="coberturaPath"/>
468 <mkdir dir="${junitReportsDirectory}"/>
469 <junitreport tofile="${junitRawDirectory}/Results.xml">
470 <fileset dir="${junitRawDirectory}" includes="TEST-*.xml"/>
471 <report format="frames" todir="${junitReportsDirectory}"/>
475 <target name="-reportTestFailed" depends="-coverageReport" if="testFailed">
476 <fail message="Test failed, not processing further targets."/>
479 <target name="-coverageInstrument" depends="-initCoverage,-coberturaInit" if="_forceCoverage_">
480 <mkdir dir="${instrumentedClassesDirectory}"/>
481 <coberturaInstrument classesDirectory="${mainClassesDirectory}"/>
484 <target name="-coverageReport" depends="-initCoverage" if="_forceCoverage_">
485 <coberturaReport reportDirectory="${reportsDirectory}/cobertura" sourceDirectory="${mainSourceDirectory}"/>
488 <target name="-actuallyCreateJars"
489 depends="-makeManifest,-initializeJars,-createBaseJar,-createEmbeddableJar"
490 unless="testFailed"/>
492 <target name="-makeManifest">
493 <mkdir dir="${mainClassesDirectory}/META-INF"/>
494 <copy todir="${mainClassesDirectory}/META-INF" file="LICENSE.txt"/>
495 <makeManifest file="${mainClassesDirectory}/META-INF/MANIFEST.MF"/>
498 <macrodef name="makeManifest">
499 <attribute name="file"/>
500 <attribute name="bundleEnvironment" default="J2SE-1.5"/>
502 <manifest file="@{file}">
503 <attribute name="Built-By" value="${user.name}"/>
504 <attribute name="Extension-Name" value="groovy"/>
505 <attribute name="Specification-Title" value="Groovy: a powerful, dynamic language for the JVM"/>
506 <attribute name="Specification-Version" value="${groovyVersion}"/>
507 <attribute name="Specification-Vendor" value="The Codehaus"/>
508 <attribute name="Implementation-Title" value="Groovy: a powerful, dynamic language for the JVM"/>
509 <attribute name="Implementation-Version" value="${groovyVersion}"/>
510 <attribute name="Implementation-Vendor" value="The Codehaus"/>
511 <attribute name="Bundle-ManifestVersion" value="2" />
512 <attribute name="Bundle-Name" value="Groovy Runtime" />
513 <attribute name="Bundle-Description" value="Groovy Runtime" />
514 <attribute name="Bundle-Version" value="${groovyBundleVersion}" />
515 <attribute name="Bundle-Vendor" value="The Codehaus" />
516 <attribute name="Bundle-ClassPath" value="." />
517 <attribute name="Bundle-RequiredExecutionEnvironment" value="@{bundleEnvironment}" />
518 <attribute name="Eclipse-BuddyPolicy" value="dependent"/>
519 <attribute name="Eclipse-LazyStart" value="true"/>
524 <target name="-includeResources" depends="-includeGroovyDocTemplates">
525 <copy todir="${mainClassesDirectory}">
526 <fileset dir="${mainSourceDirectory}">
527 <include name="groovy/ui/*.properties"/>
528 <include name="groovy/ui/**/*.png"/>
529 <include name="org/codehaus/groovy/tools/shell/**/*.properties"/>
530 <include name="org/codehaus/groovy/tools/shell/**/*.xml"/>
535 <target name="-includeExamplesResources" depends="-includeGroovyDocTemplates">
536 <copy todir="${examplesClassesDirectory}">
537 <fileset dir="${examplesSourceDirectory}">
538 <include name="/swing/binding/caricature/resources/*.gif"/>
543 <target name="-includeGroovyDocTemplates">
544 <copy todir="${mainClassesDirectory}">
545 <fileset dir="${mainSourceDirectory}">
546 <include name="org/codehaus/groovy/tools/groovydoc/gstring-templates/**/*.*"/>
551 <target name="-initializeJars" depends="test">
552 <delete dir="${targetDistDirectory}" quiet="true"/>
553 <mkdir dir="${targetDistDirectory}"/>
556 <target name="-createBaseJar" unless="testFailed">
557 <jar destfile="${targetDistDirectory}/groovy.jar" basedir="${mainClassesDirectory}"
558 excludes="*.groovy" manifest="${mainClassesDirectory}/META-INF/MANIFEST.MF"/>
559 <jar destfile="${targetDistDirectory}/groovy-${groovyVersion}-sources.jar" basedir="${mainSourceDirectory}"/>
560 <antcall target="-createBaseJarRetro"/>
563 <target name="-createBaseJarRetro" if="_forceRetro_">
564 <copy file="${targetDistDirectory}/groovy-${groovyVersion}-sources.jar"
565 tofile="${targetDistDirectory}/groovy-jdk14-${groovyVersion}-sources.jar"/>
568 <target name="-jarjarInit">
569 <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask">
571 <fileset dir="${bootstrapDirectory}" includes="jarjar-*.jar"/>
576 <target name="-createEmbeddableJar" depends="-jarjarInit" unless="testFailed">
577 <delete dir="${stagingDirectory}" quiet="true"/>
578 <mkdir dir="${stagingDirectory}"/>
579 <unzip dest="${stagingDirectory}">
580 <fileset dir="${runtimeLibDirectory}">
581 <include name="antlr*.jar"/>
582 <include name="asm*.jar"/>
583 <exclude name="asm-attr*.jar"/>
584 <exclude name="asm-util*.jar"/>
585 <exclude name="asm-analysis*.jar"/>
588 <unzip dest="${stagingDirectory}">
589 <fileset dir="${targetDistDirectory}">
590 <include name="groovy.jar"/>
593 <copy toDir="${stagingDirectory}/META-INF">
594 <fileset dir="${basedir}/config/build">
595 <include name="ANTLR-LICENSE.txt"/>
596 <include name="ASM-LICENSE.txt"/>
599 <!-- add commons-cli -->
600 <unzip dest="${stagingDirectory}">
602 <!-- no need for the manifest file, we have our own -->
603 <exclude name="META-INF/MANIFEST.MF"/>
605 <globmapper from="META-INF/LICENSE.txt" to="META-INF/CLI-LICENSE.txt"/>
606 <fileset dir="${runtimeLibDirectory}">
607 <include name="commons-cli-*.jar"/>
610 <makeManifest file="${stagingDirectory}/META-INF/MANIFEST.MF" />
611 <!-- TODO try to make use of jarjar keep ability -->
612 <jarjar jarfile="${targetDistDirectory}/groovy-all.jar"
613 manifest="${stagingDirectory}/META-INF/MANIFEST.MF">
614 <fileset dir="${stagingDirectory}" excludes="groovy/util/CliBuilder*.class,groovy/util/OptionAccessor*.class"/>
615 <rule pattern="antlr.**" result="groovyjarjarantlr.@1"/>
616 <rule pattern="org.objectweb.**" result="groovyjarjarasm.@1"/>
617 <rule pattern="org.apache.commons.cli.**" result="groovyjarjarcommonscli.@1"/>
619 <jar destfile="${targetDistDirectory}/groovy-all.jar" update="true"
620 basedir="${stagingDirectory}" includes="groovy/util/CliBuilder*.class,groovy/util/OptionAccessor*.class"/>
622 <copy file="${targetDistDirectory}/groovy-${groovyVersion}-sources.jar"
623 tofile="${targetDistDirectory}/groovy-all-${groovyVersion}-sources.jar"/>
624 <delete dir="${stagingDirectory}" quiet="true"/>
625 <antcall target="-createEmbeddableJarRetro"/>
628 <target name="-createEmbeddableJarRetro" if="_forceRetro_">
629 <copy file="${targetDistDirectory}/groovy-all-${groovyVersion}-sources.jar"
630 tofile="${targetDistDirectory}/groovy-all-jdk14-${groovyVersion}-sources.jar"/>
633 <target name="createJars" depends="-checkAntVersion,test,-actuallyCreateJars"
634 description="Build Groovy and create the jarfiles."/>
636 <target name="updateRetroJars" if="_forceRetro_">
637 <delete dir="${stagingDirectory}" quiet="true"/>
638 <mkdir dir="${stagingDirectory}"/>
639 <unzip dest="${stagingDirectory}">
640 <fileset dir="${targetDistDirectory}">
641 <include name="groovy-jdk14.jar"/>
644 <makeManifest file="${stagingDirectory}/META-INF/MANIFEST.MF" bundleEnvironment="J2SE-1.4" />
645 <jar basedir="${stagingDirectory}" manifest="${stagingDirectory}/META-INF/MANIFEST.MF"
646 destfile="${targetDistDirectory}/groovy-jdk14.jar"/>
648 <delete dir="${stagingDirectory}" quiet="true"/>
649 <mkdir dir="${stagingDirectory}"/>
650 <unzip dest="${stagingDirectory}">
652 <!-- we already have this -->
653 <exclude name="ASM-LICENSE.txt"/>
654 <!-- we don't need this -->
655 <exclude name="META-INF/maven/**/*"/>
657 <globmapper from="RETROTRANSLATOR-LICENSE.txt" to="META-INF/RETROTRANSLATOR-LICENSE.txt"/>
658 <fileset dir="${toolsLibDirectory}">
659 <include name="retrotranslator-runtime-*.jar" />
660 <include name="backport-util-concurrent-*.jar" />
663 <unzip dest="${stagingDirectory}">
664 <fileset dir="${targetDistDirectory}">
665 <include name="groovy-all-jdk14.jar"/>
668 <makeManifest file="${stagingDirectory}/META-INF/MANIFEST.MF" bundleEnvironment="J2SE-1.4" />
669 <jarjar jarfile="${targetDistDirectory}/groovy-all-jdk14.jar"
670 manifest="${stagingDirectory}/META-INF/MANIFEST.MF">
671 <fileset dir="${stagingDirectory}"/>
672 <rule pattern="net.sf.retrotranslator.runtime.**" result="groovyjarjarretroruntime.@1"/>
673 <rule pattern="edu.emory.mathcs.backport.**" result="groovyjarjarbackport.@1"/>
675 <delete dir="${stagingDirectory}" quiet="true"/>
678 <target name="updateJarsForOsgi">
679 <taskdef resource="aQute/bnd/ant/taskdef.properties" classpathref="toolsPath"/>
680 <copy todir="${targetDistDirectory}">
681 <fileset dir="config/bnd" includes="groovy*.bnd"/>
683 <filter token="GROOVY_BUNDLE_VERSION" value="${groovyBundleVersion}"/>
686 <property name="jarsToWrap" value="groovy.jar,groovy-all.jar,groovy-jdk14.jar,groovy-all-jdk14.jar" />
687 <bndwrap definitions="${targetDistDirectory}" output="${targetDistDirectory}" failok="true">
688 <fileset dir="${targetDistDirectory}" includes="${jarsToWrap}"/>
690 <delete dir="${targetDistDirectory}" includes="${jarsToWrap}"/>
691 <move todir="${targetDistDirectory}">
692 <fileset dir="${targetDistDirectory}" includes="groovy*.bar"/>
693 <globmapper from="groovy*.bar" to="groovy*-${groovyVersion}.jar"/>
695 <delete dir="${targetDistDirectory}" includes="groovy*.bnd"/>
698 <target name="install" depends="createJars,translate,updateRetroJars,updateJarsForOsgi" unless="testFailed"
699 description="Create an installation hierarchy in target/install.">
702 FIXME: It's not really a good idea to delete stuff, as it tends to negate Ant's (or other tools)
703 ability to run faster incremental builds.
705 <delete dir="${installDirectory}" quiet="true"/>
706 <mkdir dir="${installDirectory}"/>
708 <!-- Install license files -->
709 <copy todir="${installDirectory}">
710 <fileset dir="${basedir}">
711 <include name="LICENSE.txt"/>
712 <include name="NOTICE.txt"/>
715 <unzip dest="${installDirectory}">
717 <include name="META-INF/*-LICENSE.txt"/>
719 <mapper type="flatten"/>
720 <fileset file="${targetDistDirectory}/groovy-all-${groovyVersion}.jar"/>
722 <fixcrlf srcdir="${installDirectory}" eol="crlf" includes="*.txt"/>
724 <!-- Install generated artifacts and runtime dependencies -->
725 <mkdir dir="${installDirectory}/lib"/>
726 <copy todir="${installDirectory}/lib">
727 <fileset dir="${targetDistDirectory}" includes="groovy-${groovyVersion}.jar"/>
728 <fileset dir="${runtimeLibDirectory}" includes="*.jar"/>
731 <!-- Install the embeddable bits -->
732 <mkdir dir="${installDirectory}/embeddable"/>
733 <copy todir="${installDirectory}/embeddable">
734 <fileset dir="${targetDistDirectory}" includes="groovy-all-${groovyVersion}.jar"/>
737 <!-- Install configuration files -->
738 <mkdir dir="${installDirectory}/conf"/>
739 <copy toDir="${installDirectory}/conf">
740 <fileset dir="${sourceDirectory}/conf" includes="*"/>
743 <!-- Install scripts -->
744 <mkdir dir="${installDirectory}/bin"/>
745 <copy toDir="${installDirectory}/bin">
746 <fileset dir="${sourceDirectory}/bin" includes="*"/>
748 <filter token="GROOVYJAR" value="groovy-${groovyVersion}.jar"/>
752 <!-- Tweak scripts for platform compatibility -->
753 <fixcrlf srcdir="${installDirectory}/bin" eol="lf" excludes="*.bat"/>
754 <fixcrlf srcdir="${installDirectory}/bin" eol="crlf" includes="*.bat"/>
756 <fileset dir="${installDirectory}/bin" includes="*,*.*"/>
760 <target name="translate" depends="-retroInit" if="_forceRetro_">
761 <retroArtifact basedir="${targetDistDirectory}" artifact="groovy"/>
762 <retroArtifact basedir="${targetDistDirectory}" artifact="groovy-all"/>
765 <target name="checkstyle" depends="-init,-initializeReports,-checkstyleInit"
766 description="Create the code style reports.">
768 reportDirectory="${reportsDirectory}/checkstyle"
769 sourceDirectory="${mainSourceDirectory}"
770 excludes="org/codehaus/groovy/antlr/parser/*,org/codehaus/groovy/antlr/java/*,org/codehaus/groovy/syntax/Types.java">
772 <pathelement path="${mainClassesDirectory}"/>
773 <path refid="testLibPath"/>
778 <target name="-compileTools" depends="-initGroovyc,compileMain">
779 <groovyc srcdir="${toolsSourceDirectory}" destdir="${toolsClassesDirectory}" fork="true">
781 <path refid="toolsPath"/>
782 <pathelement path="${mainClassesDirectory}"/>
783 <path refid="compilePath"/>
786 <copy todir="${toolsClassesDirectory}">
787 <fileset dir="${toolsSourceDirectory}">
788 <include name="**/*.html"/>
793 <target name="cruiseReportExtras">
794 <mkdir dir="${cruiseReportRootDirectory}"/>
795 <copy todir="${cruiseReportRootDirectory}">
796 <fileset dir="cruise/html"/>
800 <target name="cruiseInit">
801 <property name="noTextReports" value="true"/>
802 <property name="forceCoverage" value="true"/>
803 <delete dir="${reportsDirectory}" quiet="true" failonerror="false"/>
804 <delete dir="${junitRawDirectory}" quiet="true" failonerror="false"/>
807 <target name="cruise" depends="cruiseInit,distribution,compileExamples,checkstyle,cruiseReportExtras"/>
809 <target name="-docInit">
810 <mkdir dir="${docsDirectory}"/>
813 <target name="doc" depends="javadoc, groovydoc" description="Create the documentation."/>
815 <target name="javadoc" depends="-fetchDependencies,-docInit,-jvm14BuildWarning"
816 description="Create the javadoc documentation.">
817 <property name="title" value="Groovy"/>
818 <javadoc destdir="${docsDirectory}/api" author="true" version="true"
819 windowtitle="${title} (${groovyVersion})" doctitle="${title} (${groovyVersion})"
820 encoding="ISO-8859-1" useexternalfile="true" source="1.5"
821 footer="Copyright &copy; 2003-2008 The Codehaus. All rights reserved.">
823 <path path="${mainClassesDirectory}"/>
824 <path refid="compilePath"/>
826 <fileset dir="${mainSourceDirectory}" includes="**/*.java"/>
827 <link href="http://java.sun.com/j2se/1.5.0/docs/api"/>
828 <link href="http://www.dpml.net/api/ant/1.7.0"/>
829 <link href="http://junit.sourceforge.net/junit3.8.1/javadoc/"/>
830 <link href="http://java.sun.com/j2ee/1.4/docs/api"/>
831 <link href="http://www.antlr2.org/javadoc"/>
833 <jar basedir="${docsDirectory}/api" destfile="${targetDistDirectory}/groovy-${groovyVersion}-javadoc.jar"/>
834 <copy toFile="${targetDistDirectory}/groovy-all-${groovyVersion}-javadoc.jar">
835 <fileset file="${targetDistDirectory}/groovy-${groovyVersion}-javadoc.jar"/>
837 <antcall target="-javadocRetro"/>
840 <target name="-javadocRetro" if="_forceRetro_">
841 <copy toFile="${targetDistDirectory}/groovy-all-jdk14-${groovyVersion}-javadoc.jar">
842 <fileset file="${targetDistDirectory}/groovy-all-${groovyVersion}-javadoc.jar"/>
844 <copy toFile="${targetDistDirectory}/groovy-jdk14-${groovyVersion}-javadoc.jar">
845 <fileset file="${targetDistDirectory}/groovy-${groovyVersion}-javadoc.jar"/>
849 <target name="groovydoc" depends="-fetchDependencies,-docInit,-includeGroovyDocTemplates,docGDK">
850 <path id="groovydocpath">
851 <path path="${mainClassesDirectory}"/>
852 <path refid="runtimePath"/>
854 <antforked target="realgroovydoc" maxmemory="512m" classpathref="groovydocpath"/>
857 <target name="realgroovydoc">
858 <taskdef name="groovydoc" classname="org.codehaus.groovy.ant.Groovydoc">
860 <path path="${mainClassesDirectory}"/>
861 <path refid="compilePath"/>
865 destdir="${docsDirectory}/gapi"
866 sourcepath="${mainSourceDirectory}"
869 windowtitle="groovydoc"
871 <link packages="java." href="http://java.sun.com/j2se/1.5.0/docs/api"/>
872 <link packages="org.apache.ant." href="http://www.dpml.net/api/ant/1.7.0"/>
873 <link packages="org.junit.,junit.framework." href="http://junit.sourceforge.net/junit3.8.1/javadoc/"/>
874 <link packages="groovy.,org.codehaus.groovy." href="http://groovy.codehaus.org/api/"/>
878 <target name="docGDK" depends="-fetchDependencies,-compileTools" description="Create the GDK documentation">
879 <java classname="org.codehaus.groovy.tools.DocGenerator" fork="yes" failonerror="true">
881 <pathelement path="${toolsClassesDirectory}"/>
882 <path refid="toolsPath"/>
883 <pathelement path="${mainClassesDirectory}"/>
885 <arg value="org.codehaus.groovy.runtime.DefaultGroovyMethods"/>
886 <arg value="org.codehaus.groovy.runtime.DefaultGroovyStaticMethods"/>
887 <arg value="org.codehaus.groovy.vmplugin.v5.PluginDefaultGroovyMethods"/>
889 <copy todir="target/html/groovy-jdk" file="src/tools/org/codehaus/groovy/tools/groovy.ico"/>
890 <copy todir="target/html/groovy-jdk" file="src/tools/org/codehaus/groovy/tools/stylesheet.css"/>
893 <target name="clean" description="Clean up build artifacts.">
894 <delete dir="${targetDirectory}" quiet="true"/>
895 <delete quiet="true">
896 <fileset dir="." includes="**/*~"/>
897 <fileset dir="${groovyParserDirectory}" includes="Groovy*.*"/>
898 <fileset dir="${javaParserDirectory}" includes="JavaLexer.java,JavaRecognizer.java,JavaTokenTypes.java,JavaTokenTypes.txt,*.smap"/>
902 <target name="deploy" depends="-mavenDeployInit,install,doc,-deployPlainOnly,-deployPlainAndRetro"
903 description="Deploy jars to maven repository."/>
905 <target name="-deployPlainOnly" unless="_forceRetro_">
906 <mavenDeploy version="${groovyVersion}" prefix="groovy"/>
907 <mavenDeploy version="${groovyVersion}" prefix="groovy-all"/>
910 <target name="-deployPlainAndRetro" if="_forceRetro_">
911 <!-- these were overwritten, so set them again -->
912 <maven.pom file="${targetDirectory}/groovy-jdk14.pom" id="groovy-jdk14.pom"/>
913 <maven.pom file="${targetDirectory}/groovy-all-jdk14.pom" id="groovy-all-jdk14.pom"/>
915 <!-- do them all in one hit like this because the maven ant libs like it that way -->
916 <mavenDeploy version="${groovyVersion}" prefix="groovy"/>
917 <mavenDeploy version="${groovyVersion}" prefix="groovy-all"/>
918 <mavenDeploy version="${groovyVersion}" prefix="groovy-jdk14"/>
919 <mavenDeploy version="${groovyVersion}" prefix="groovy-all-jdk14"/>
922 <target name="installRepo" depends="-mavenInit,install,doc"
923 description="Deploy artifacts to local maven repository.">
924 <mavenInstallRepo version="${groovyVersion}" prefix="groovy"/>
925 <mavenInstallRepo version="${groovyVersion}" prefix="groovy-all"/>
926 <antcall target="-installRepoRetro"/>
929 <target name="-installRepoRetro" if="_forceRetro_">
930 <maven.pom file="${targetDirectory}/groovy-jdk14.pom" id="groovy-jdk14.pom"/>
931 <mavenInstallRepo version="${groovyVersion}" prefix="groovy-jdk14"/>
932 <maven.pom file="${targetDirectory}/groovy-all-jdk14.pom" id="groovy-all-jdk14.pom"/>
933 <mavenInstallRepo version="${groovyVersion}" prefix="groovy-all-jdk14"/>
936 <target name="distribution" depends="install,doc" description="Create everything needed for a distribution.">
937 <zip destfile="${targetDistDirectory}/groovy-binary-${groovyVersion}.zip"
938 comment="The Groovy ${groovyVersion} binary distribution.">
940 <!-- Make unix scripts executable -->
941 <zipfileset dir="${installDirectory}" prefix="groovy-${groovyVersion}" filemode="775">
942 <include name="bin/*"/>
943 <exclude name="bin/*.*"/>
944 <exclude name="bin/startGroovy*"/>
947 <!-- Include the other scripts as is -->
948 <zipfileset dir="${installDirectory}" prefix="groovy-${groovyVersion}">
949 <include name="bin/*.*"/>
950 <include name="bin/startGroovy*"/>
953 <!-- Include everything else as is too -->
954 <zipfileset dir="${installDirectory}" prefix="groovy-${groovyVersion}">
955 <exclude name="bin/**"/>
960 <zip destfile="${targetDistDirectory}/groovy-docs-${groovyVersion}.zip"
961 comment="The Groovy ${groovyVersion} documentation distribution.">
962 <zipfileset dir="${wikiPdfDirectory}" includes="wiki-snapshot.pdf" prefix="groovy-${groovyVersion}/pdf"/>
963 <zipfileset dir="${docsDirectory}" prefix="groovy-${groovyVersion}/html"/>
966 <zip destfile="${targetDistDirectory}/groovy-src-${groovyVersion}.zip"
967 comment="The Groovy ${groovyVersion} source distribution.">
968 <zipfileset dir="${basedir}" prefix="groovy-${groovyVersion}">
969 <!-- Exclude generated bits as well as any other bits that shouldn't make it in -->
970 <exclude name="${targetDirectory}/**"/>
971 <exclude name="classes/**"/>
972 <exclude name="cruise/**"/>
973 <exclude name=".clover/*"/>
974 <exclude name="local.build.properties"/>
975 <exclude name="cobertura.ser"/>
976 <exclude name="junitvmwatcher*.properties"/>
981 <target name="dist" depends="distribution" description="Alias to distribution for the lazy."/>