fixed build console
[groovy.git] / build.xml
blob8ed304b2c45392386bd7a13faf131f9bd0b1a2d1
1 <?xml version="1.0" encoding="UTF-8"?>
3 <!--
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
19 Author : Paul King
20 $Revision$ ($LastChangedBy$)
21 $Date$
22 -->
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_">
37         <or>
38             <equals arg1="${test}" arg2="false"/>
39             <istrue value="${skipTests}"/>
40         </or>
41     </condition>
43     <condition property="_forceRetro_">
44         <and>
45             <isset property="jdk14home"/>
46             <istrue value="${forceRetro}"/>
47         </and>
48     </condition>
50     <condition property="_skipExamples_">
51         <istrue value="${skipExamples}"/>
52     </condition>
54     <condition property="_skipFetch_">
55         <istrue value="${skipFetch}"/>
56     </condition>
58     <condition property="groovy.build.vm5">
59         <not>
60             <contains string="${ant.java.version}" substring="1.4"/>
61         </not>
62     </condition>
64     <target name="-initCoverage">
65         <condition property="_forceCoverage_">
66             <and>
67                 <not>
68                     <istrue value="${skipTests}"/>
69                 </not>
70                 <istrue value="${forceCoverage}"/>
71             </and>
72         </condition>
73     </target>
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"/>
79         </antlr>
80         <antlr target="${javaParserDirectory}/java.g" outputdirectory="${javaParserDirectory}">
81             <classpath refid="compilePath"/>
82         </antlr>
83     </target>
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"/>
89             <filterset>
90                 <filter token="relativePathToRealBasedir" value="${relativePathToRealBasedir}"/>
91             </filterset>
92         </copy>
93     </target>
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}"/>
106     </target>
108     <target name="-jvm14BuildWarning" unless="groovy.build.vm5">
109         <fail>Aborting!
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 =================================================================
115         </fail>
116     </target>
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}+">
125             <condition>
126                 <or>
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>
132                     <and>
133                         <contains string="${ant.version}" substring="1.6"></contains>
134                         <not>
135                             <contains string="${ant.version}" substring="${ant.requiredVersion}"></contains>
136                         </not>
137                     </and>
138                 </or>
139             </condition>
140         </fail>
141     </target>
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>
147            </fail>
148         </target>
149     -->
151     <target name="dgmConvert" depends="ubercompile,stagedcompile">
152         <java classname="org.codehaus.groovy.tools.DgmConverter"
153               fork="yes"
154               failonerror="true">
155             <classpath refid="compilePath"/>
156             <classpath path="${mainClassesDirectory}"/>
157         </java>
158     </target>
160     <target name="compileMain" depends="ubercompile,stagedcompile,dgmConvert"
161             description="Compile the Java and Groovy code in the main source.">
162     </target>
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"/>
171         </javac>
172         <antcall inheritall="true" target="-stagedcompile-groovy"/>
173     </target>
175     <target name="-stagedcompile-groovy" depends="-initGroovyc">
176         <groovyc srcdir="${mainSourceDirectory}" destdir="${mainClassesDirectory}" fork="true" memorymaximumsize="${groovycMain_mx}">
177             <classpath>
178                 <pathelement path="${mainClassesDirectory}"/>
179                 <path refid="compilePath"/>
180             </classpath>
181             <javac deprecation="on" debug="yes" source="1.5" target="1.5"/>
182         </groovyc>
183     </target>
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}"/>
193             <!--
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.
197             -->
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"/>
209         </javac>
211         <taskdef name="ubercompile" classname="org.codehaus.groovy.ant.UberCompileTask">
212             <classpath>
213                 <pathelement location="${mainClassesDirectory}"/>
214                 <path refid="compilePath"/>
215             </classpath>
216         </taskdef>
217     </target>
219     <target name="ubercompile" depends="-ubercompile:bootstrap" if="uber">
220         <mkdir dir="${mainStubsDirectory}"/>
222         <ubercompile destdir="${mainClassesDirectory}">
223             <classpath>
224                 <pathelement location="${mainClassesDirectory}"/>
225                 <path refid="compilePath"/>
226             </classpath>
227             <src location="${mainSourceDirectory}"/>
229             <generatestubs destdir="${mainStubsDirectory}" includes="**/*.groovy">
230                 <configuration targetBytecode="1.5"/>
231             </generatestubs>
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"/>
236             </groovyc>
237         </ubercompile>
238     </target>
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"/>
248         </path>
249         <taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc" classpathref="groovyMainClasses"/>
250     </target>
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}"/>
256         </condition>
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 =================================================================
268         </fail>
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"/>
274             </fileset>
275             <path refid="runtimePath"/>
276         </path>
277         <taskdef name="groovyc" classname="org.codehaus.groovy.ant.Groovyc" classpathref="groovyMainClasses"/>
278     </target>
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}"/>
285     </target>
287     <target name="compileTestOnly" unless="_skipTests_">
288         <mkdir dir="${testClassesDirectory}"/>
289         <antcall inheritall="true" target="-compileTest"/>
290     </target>
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}"
297                  stacktrace="true"
298                  fork="true"
299                  memorymaximumsize="${groovycTest_mx}">
300             <classpath>
301                 <pathelement path="${testClassesDirectory}"/>
302                 <path refid="groovyMainClasses"/>
303                 <path refid="testLibPath"/>
304                 <path refid="jdk14ExtrasPath"/>
305             </classpath>
306             <javac source="1.4" target="1.4" nowarn="true"/>
307         </groovyc>
308     </target>
310     <target name="-compileTest" depends="-initGroovyc,-compileTest_vm4" if="groovy.build.vm5">
311         <groovyc srcdir="${testSourceDirectory}"
312                  destdir="${testClassesDirectory}"
313                  includes="${vm5GroovySourceFiles},${vm5JavaSourceFiles}"
314                  fork="true"
315                  memorymaximumsize="${groovycTest_mx}">
316             <classpath>
317                 <pathelement path="${testClassesDirectory}"/>
318                 <path refid="groovyMainClasses"/>
319                 <path refid="testLibPath"/>
320             </classpath>
321             <javac source="1.5" target="1.5" nowarn="on"/>
322         </groovyc>
323     </target>
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}"
332                  fork="true"
333                  memorymaximumsize="${groovycExamples_mx}">
334             <classpath>
335                 <pathelement path="${mainClassesDirectory}"/>
336                 <path refid="compilePath"/>
337                 <path refid="examplesPath"/>
338             </classpath>
339         </groovyc>
340         <javac srcdir="${examplesSourceDirectory}"
341                 destdir="${examplesClassesDirectory}"
342                 source="1.5"
343                 target="1.5"
344                 fork="true">
345             <classpath>
346                 <pathelement path="${mainClassesDirectory}"/>
347                 <pathelement path="${examplesClassesDirectory}"/>
348                 <path refid="compilePath"/>
349                 <path refid="examplesPath"/>
350             </classpath>
351             <include name="org/codehaus/groovy/grails/compiler/injection/*.java" if="groovy.build.vm5"/>
352         </javac>
353         <groovyc srcdir="${examplesSourceDirectory}"
354                 destdir="${examplesClassesDirectory}"
355                  fork="true"
356                  memorymaximumsize="${groovycExamples_mx}"
357                  excludes="webapps/groovlet-examples/WEB-INF/groovy/**/*.groovy,org/codehaus/groovy/grails/compiler/injection/**/*.java">
358             <classpath>
359                 <pathelement path="${mainClassesDirectory}"/>
360                 <pathelement path="${examplesClassesDirectory}"/>
361                 <path refid="compilePath"/>
362                 <path refid="examplesPath"/>
363             </classpath>
364             <javac source="1.4" target="1.4"/>
365         </groovyc>
367     </target>
369     <target name="-initializeReports">
370         <mkdir dir="${reportsDirectory}"/>
371     </target>
373     <condition property="_shouldBeHeadless_">
374         <or>
375             <istrue value="${java.awt.headless}"/>
376             <os name="Mac OS X"/>
377         </or>
378     </condition>
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}"/>
384     </target>
386     <target name="-initHeadless" if="_shouldBeHeadless_">
387         <property name="headlessArg" value="-Djava.awt.headless=true"/>
388         <echo message="Setting headless mode ..."/>
389     </target>
391     <target name="test"
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_">
402         <and>
403             <not>
404                 <istrue value="${_skipTests_}"/>
405             </not>
406             <isset property="testCase"/>
407         </and>
408     </condition>
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"/>
416             <classpath>
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"/>
425             </classpath>
426         </junit>
427     </target>
429     <condition property="_testAll_">
430         <and>
431             <not>
432                 <istrue value="${_skipTests_}"/>
433             </not>
434             <not>
435                 <isset property="_testOne_"/>
436             </not>
437         </and>
438     </condition>
440     <target name="-collect14tests" unless="groovy.build.vm5">
441         <fileset id="ubertests.fileset" dir="${testClassesDirectory}" includes="UberTest*.class" excludes="Uber*VM5.class"/>
442     </target>
444     <target name="-collect15tests" if="groovy.build.vm5">
445         <fileset id="ubertests.fileset" dir="${testClassesDirectory}" includes="UberTest*.class"/>
446     </target>
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"/>
456             </batchtest>
457             <classpath>
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"/>
466             </classpath>
467         </junit>
468         <mkdir dir="${junitReportsDirectory}"/>
469         <junitreport tofile="${junitRawDirectory}/Results.xml">
470             <fileset dir="${junitRawDirectory}" includes="TEST-*.xml"/>
471             <report format="frames" todir="${junitReportsDirectory}"/>
472         </junitreport>
473     </target>
475     <target name="-reportTestFailed" depends="-coverageReport" if="testFailed">
476         <fail message="Test failed, not processing further targets."/>
477     </target>
479     <target name="-coverageInstrument" depends="-initCoverage,-coberturaInit" if="_forceCoverage_">
480         <mkdir dir="${instrumentedClassesDirectory}"/>
481         <coberturaInstrument classesDirectory="${mainClassesDirectory}"/>
482     </target>
484     <target name="-coverageReport" depends="-initCoverage" if="_forceCoverage_">
485         <coberturaReport reportDirectory="${reportsDirectory}/cobertura" sourceDirectory="${mainSourceDirectory}"/>
486     </target>
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"/>
496         </target>
498     <macrodef name="makeManifest">
499         <attribute name="file"/>
500         <attribute name="bundleEnvironment" default="J2SE-1.5"/>
501         <sequential>
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"/>
520             </manifest>
521         </sequential>
522     </macrodef>
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"/>
531             </fileset>
532         </copy>
533     </target>
535     <target name="-includeExamplesResources" depends="-includeGroovyDocTemplates">
536         <copy todir="${examplesClassesDirectory}">
537             <fileset dir="${examplesSourceDirectory}">
538                 <include name="/swing/binding/caricature/resources/*.gif"/>
539             </fileset>
540         </copy>
541     </target>
543     <target name="-includeGroovyDocTemplates">
544         <copy todir="${mainClassesDirectory}">
545             <fileset dir="${mainSourceDirectory}">
546                 <include name="org/codehaus/groovy/tools/groovydoc/gstring-templates/**/*.*"/>
547             </fileset>
548         </copy>
549     </target>
551     <target name="-initializeJars" depends="test">
552         <delete dir="${targetDistDirectory}" quiet="true"/>
553         <mkdir dir="${targetDistDirectory}"/>
554     </target>
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"/>
561     </target>
563     <target name="-createBaseJarRetro" if="_forceRetro_">
564         <copy file="${targetDistDirectory}/groovy-${groovyVersion}-sources.jar"
565               tofile="${targetDistDirectory}/groovy-jdk14-${groovyVersion}-sources.jar"/>
566     </target>
568     <target name="-jarjarInit">
569         <taskdef name="jarjar" classname="com.tonicsystems.jarjar.JarJarTask">
570             <classpath>
571                 <fileset dir="${bootstrapDirectory}" includes="jarjar-*.jar"/>
572             </classpath>
573         </taskdef>
574     </target>
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"/>
586             </fileset>
587         </unzip>
588         <unzip dest="${stagingDirectory}">
589             <fileset dir="${targetDistDirectory}">
590                 <include name="groovy.jar"/>
591             </fileset>
592         </unzip>
593         <copy toDir="${stagingDirectory}/META-INF">
594             <fileset dir="${basedir}/config/build">
595                 <include name="ANTLR-LICENSE.txt"/>
596                 <include name="ASM-LICENSE.txt"/>
597             </fileset>
598         </copy>
599         <!-- add commons-cli -->
600         <unzip dest="${stagingDirectory}">
601             <patternset>
602                 <!-- no need for the manifest file, we have our own -->
603                 <exclude name="META-INF/MANIFEST.MF"/>
604             </patternset>
605             <globmapper from="META-INF/LICENSE.txt" to="META-INF/CLI-LICENSE.txt"/>
606             <fileset dir="${runtimeLibDirectory}">
607                 <include name="commons-cli-*.jar"/>
608             </fileset>
609         </unzip>
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"/>
618         </jarjar>
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"/>
626     </target>
627     
628     <target name="-createEmbeddableJarRetro" if="_forceRetro_">
629         <copy file="${targetDistDirectory}/groovy-all-${groovyVersion}-sources.jar"
630               tofile="${targetDistDirectory}/groovy-all-jdk14-${groovyVersion}-sources.jar"/>
631     </target>
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"/>
642             </fileset>
643         </unzip>
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}">
651             <patternset>
652                 <!-- we already have this -->
653                 <exclude name="ASM-LICENSE.txt"/>
654                 <!-- we don't need this -->
655                 <exclude name="META-INF/maven/**/*"/>
656             </patternset>
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" />
661             </fileset>
662         </unzip>
663         <unzip dest="${stagingDirectory}">
664             <fileset dir="${targetDistDirectory}">
665                 <include name="groovy-all-jdk14.jar"/>
666             </fileset>
667         </unzip>
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"/>
674         </jarjar>
675         <delete dir="${stagingDirectory}" quiet="true"/>
676     </target>
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"/>
682             <filterset>
683                 <filter token="GROOVY_BUNDLE_VERSION" value="${groovyBundleVersion}"/>
684             </filterset>
685         </copy>
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}"/>
689         </bndwrap>
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"/>
694         </move>
695         <delete dir="${targetDistDirectory}" includes="groovy*.bnd"/>
696     </target>
698     <target name="install" depends="createJars,translate,updateRetroJars,updateJarsForOsgi" unless="testFailed"
699             description="Create an installation hierarchy in target/install.">
701         <!--
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.
704         -->
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"/>
713             </fileset>
714         </copy>
715         <unzip dest="${installDirectory}">
716             <patternset>
717                 <include name="META-INF/*-LICENSE.txt"/>
718             </patternset>
719             <mapper type="flatten"/>
720             <fileset file="${targetDistDirectory}/groovy-all-${groovyVersion}.jar"/>
721         </unzip>
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"/>
729         </copy>
731         <!-- Install the embeddable bits -->
732         <mkdir dir="${installDirectory}/embeddable"/>
733         <copy todir="${installDirectory}/embeddable">
734             <fileset dir="${targetDistDirectory}" includes="groovy-all-${groovyVersion}.jar"/>
735         </copy>
737         <!-- Install configuration files -->
738         <mkdir dir="${installDirectory}/conf"/>
739         <copy toDir="${installDirectory}/conf">
740             <fileset dir="${sourceDirectory}/conf" includes="*"/>
741         </copy>
743         <!-- Install scripts -->
744         <mkdir dir="${installDirectory}/bin"/>
745         <copy toDir="${installDirectory}/bin">
746             <fileset dir="${sourceDirectory}/bin" includes="*"/>
747             <filterset>
748                 <filter token="GROOVYJAR" value="groovy-${groovyVersion}.jar"/>
749             </filterset>
750         </copy>
752         <!-- Tweak scripts for platform compatibility -->
753         <fixcrlf srcdir="${installDirectory}/bin" eol="lf" excludes="*.bat"/>
754         <fixcrlf srcdir="${installDirectory}/bin" eol="crlf" includes="*.bat"/>
755         <chmod perm="ugo+x">
756             <fileset dir="${installDirectory}/bin" includes="*,*.*"/>
757         </chmod>
758     </target>
760     <target name="translate" depends="-retroInit" if="_forceRetro_">
761         <retroArtifact basedir="${targetDistDirectory}" artifact="groovy"/>
762         <retroArtifact basedir="${targetDistDirectory}" artifact="groovy-all"/>
763     </target>
765     <target name="checkstyle" depends="-init,-initializeReports,-checkstyleInit"
766             description="Create the code style reports.">
767         <checkAndReport
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">
771             <path>
772                 <pathelement path="${mainClassesDirectory}"/>
773                 <path refid="testLibPath"/>
774             </path>
775         </checkAndReport>
776     </target>
778     <target name="-compileTools" depends="-initGroovyc,compileMain">
779         <groovyc srcdir="${toolsSourceDirectory}" destdir="${toolsClassesDirectory}" fork="true">
780             <classpath>
781                 <path refid="toolsPath"/>
782                 <pathelement path="${mainClassesDirectory}"/>
783                 <path refid="compilePath"/>
784             </classpath>
785         </groovyc>
786         <copy todir="${toolsClassesDirectory}">
787             <fileset dir="${toolsSourceDirectory}">
788                 <include name="**/*.html"/>
789             </fileset>
790         </copy>
791     </target>
793     <target name="cruiseReportExtras">
794         <mkdir dir="${cruiseReportRootDirectory}"/>
795         <copy todir="${cruiseReportRootDirectory}">
796             <fileset dir="cruise/html"/>
797         </copy>
798     </target>
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"/>
805     </target>
807     <target name="cruise" depends="cruiseInit,distribution,compileExamples,checkstyle,cruiseReportExtras"/>
809     <target name="-docInit">
810         <mkdir dir="${docsDirectory}"/>
811     </target>
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 &amp;copy; 2003-2008 The Codehaus. All rights reserved.">
822             <classpath>
823                 <path path="${mainClassesDirectory}"/>
824                 <path refid="compilePath"/>
825             </classpath>
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"/>
832         </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"/>
836         </copy>
837         <antcall target="-javadocRetro"/>
838     </target>
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"/>
843         </copy>
844         <copy toFile="${targetDistDirectory}/groovy-jdk14-${groovyVersion}-javadoc.jar">
845             <fileset file="${targetDistDirectory}/groovy-${groovyVersion}-javadoc.jar"/>
846         </copy>
847     </target>
849     <target name="groovydoc" depends="-fetchDependencies,-docInit,-includeGroovyDocTemplates,docGDK">
850         <path id="groovydocpath">
851             <path path="${mainClassesDirectory}"/>
852             <path refid="runtimePath"/>
853         </path>
854         <antforked target="realgroovydoc" maxmemory="512m" classpathref="groovydocpath"/>
855     </target>
857     <target name="realgroovydoc">
858         <taskdef name="groovydoc" classname="org.codehaus.groovy.ant.Groovydoc">
859             <classpath>
860                 <path path="${mainClassesDirectory}"/>
861                 <path refid="compilePath"/>
862             </classpath>
863         </taskdef>
864         <groovydoc
865                 destdir="${docsDirectory}/gapi"
866                 sourcepath="${mainSourceDirectory}"
867                 packagenames="**.*"
868                 use="true"
869                 windowtitle="groovydoc"
870                 private="false">
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/"/>
875         </groovydoc>
876     </target>
878     <target name="docGDK" depends="-fetchDependencies,-compileTools" description="Create the GDK documentation">
879         <java classname="org.codehaus.groovy.tools.DocGenerator" fork="yes" failonerror="true">
880             <classpath>
881                 <pathelement path="${toolsClassesDirectory}"/>
882                 <path refid="toolsPath"/>
883                 <pathelement path="${mainClassesDirectory}"/>
884             </classpath>
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"/>
888         </java>
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"/>
891     </target>
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"/>
899         </delete>
900     </target>
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"/>
908     </target>
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"/>
920     </target>
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"/>
927     </target>
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"/>
934     </target>
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*"/>
945             </zipfileset>
947             <!-- Include the other scripts as is -->
948             <zipfileset dir="${installDirectory}" prefix="groovy-${groovyVersion}">
949                 <include name="bin/*.*"/>
950                 <include name="bin/startGroovy*"/>
951             </zipfileset>
953             <!-- Include everything else as is too -->
954             <zipfileset dir="${installDirectory}" prefix="groovy-${groovyVersion}">
955                 <exclude name="bin/**"/>
956                 <include name="**"/>
957             </zipfileset>
958         </zip>
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"/>
964         </zip>
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"/>
977             </zipfileset>
978         </zip>
979     </target>
981     <target name="dist" depends="distribution" description="Alias to distribution for the lazy."/>
983 </project>