Home | History | Annotate | Download | only in build
      1 <!--
      2 *  2016 and later: Unicode, Inc. and others.
      3 * License & terms of use: http://www.unicode.org/copyright.html#License
      4 *******************************************************************************
      5 * Copyright (C) 2009-2016, International Business Machines Corporation and    *
      6 * others. All Rights Reserved.                                                *
      7 *******************************************************************************
      8 -->
      9 <project name="common-targets" basedir=".">
     10     <dirname property="common-targets.dir" file="${ant.file.common-targets}"/>
     11     <property file="${common-targets.dir}/locations.properties"/>
     12 
     13     <!-- global (top-level) propeties - need locations.properties loaded first -->
     14     <property file="${global.build-local.properties}"/>
     15     <property file="${global.build.properties}"/>
     16 
     17     <property file="${common-targets.dir}/common.properties"/>
     18     <property environment="env"/>
     19 
     20     <!-- common targets -->
     21 
     22     <target name="@clean">
     23         <delete dir="${out.dir}"/>
     24     </target>
     25 
     26     <target name="@compile">
     27         <echo message="build-local:     ${global.build-local.properties}"/>
     28         <!-- set java 6 bootclasspath to empty if not set -->
     29         <property name="java6.bootclasspath" value=""/>
     30 
     31         <condition property="javac.bootclasspath" value="${java6.bootclasspath}" else="">
     32             <equals arg1="${javac.target}" arg2="1.6"/>
     33         </condition>
     34 
     35         <echo message="--- java compiler arguments ------------------------"/>
     36         <echo message="source dir:     ${basedir}/${src.dir}"/>
     37         <echo message="output dir:     ${basedir}/${bin.dir}"/>
     38         <echo message="bootclasspath:  ${javac.bootclasspath}"/>
     39         <echo message="classpath:      ${toString:javac.classpathref}"/>
     40         <echo message="source:         ${javac.source}"/>
     41         <echo message="target:         ${javac.target}"/>
     42         <echo message="debug:          ${javac.debug}"/>
     43         <echo message="encoding:       ${java.src.encoding}"/>
     44         <echo message="compiler arg:   ${javac.compilerarg}"/>
     45         <echo message="----------------------------------------------------"/>
     46 
     47         <mkdir dir="${bin.dir}"/>
     48         <javac
     49             srcdir="${src.dir}"
     50             destdir="${bin.dir}"
     51             bootclasspath="${javac.bootclasspath}"
     52             classpathref="javac.classpathref"
     53             source="${javac.source}"
     54             target="${javac.target}"
     55             debug="${javac.debug}"
     56             encoding="${java.src.encoding}"
     57             includeAntRuntime="no">
     58             <compilerarg value="${javac.compilerarg}"/>
     59         </javac>
     60     </target>
     61 
     62     <target name="@copy">
     63         <mkdir dir="${bin.dir}"/>
     64         <copy todir="${bin.dir}">
     65             <fileset dir="${src.dir}" defaultexcludes="yes">
     66                 <exclude name="**/*.java"/>
     67             </fileset>
     68         </copy>
     69     </target>
     70 
     71     <target name="@jar">
     72         <mkdir dir="${jar.dir}"/>
     73 
     74         <copy file="manifest.stub" todir="${out.dir}">
     75             <filterset>
     76                 <filter token="SPECVERSION" value="${jar.spec.version}"/>
     77                 <filter token="IMPLVERSION" value="${jar.impl.version}"/>
     78                 <filter token="COPYRIGHT" value="${jar.copyright.info}"/>
     79                 <filter token="EXECENV" value="${jar.exec.env}"/>
     80             </filterset>
     81         </copy>
     82 
     83         <jar jarfile="${jar.dir}/${jar.name}" manifest="${out.dir}/manifest.stub" compress="true">
     84             <fileset dir="${bin.dir}" includes="**/*"/>
     85             <fileset dir="${shared.dir}/licenses">
     86                 <include name="LICENSE"/>
     87             </fileset>
     88         </jar>
     89     </target>
     90 
     91     <target name="@src-jar">
     92         <mkdir dir="${jar.dir}"/>
     93         <jar jarfile="${jar.dir}/${src.jar.name}" compress="true">
     94             <fileset dir="${src.dir}" includes="**/*.java"/>
     95             <fileset dir="${shared.dir}/licenses">
     96                 <include name="LICENSE"/>
     97             </fileset>
     98         </jar>
     99     </target>
    100 
    101     <target name="@build-all">
    102         <antcall target="_all.${ant.project.name}"/>
    103     </target>
    104 
    105     <target name="@full-locale-names">
    106         <echo message="Generating ${res.dir}/fullLocaleNames.lst"/>
    107         <pathconvert pathsep="${line.separator}" property="full.locale.names">
    108             <fileset dir="${res.dir}">
    109                 <include name="??.res"/>
    110                 <include name="??_*.res"/>
    111                 <include name="???.res"/>
    112                 <include name="???_*.res"/>
    113                 <include name="root.res"/>
    114                 <exclude name="res_index.res"/>
    115             </fileset>
    116             <chainedmapper>
    117                 <flattenmapper/>
    118                 <globmapper from="*.res" to="*"/>
    119             </chainedmapper>
    120         </pathconvert>
    121         <echo message="${full.locale.names}" file="${res.dir}/fullLocaleNames.lst"/>
    122     </target>
    123 
    124     <!-- FindBugs targets -->
    125     <target name="_findbugs_init">
    126         <property name="findbugs.home" value="${env.FINDBUGS_HOME}"/>
    127         <echo message="----------------------------------------------------"/>
    128         <echo message="findbugs.home:  ${findbugs.home}"/>
    129         <echo message="----------------------------------------------------"/>
    130 
    131         <fail message="FindBugs task not found. Set environment variable FINDBUGS_HOME properly.">
    132             <condition>
    133                 <not>
    134                     <or>
    135                         <available classname="edu.umd.cs.findbugs.anttask.FindBugsTask" property="_findbugs.task.available" />
    136                         <available file="${findbugs.home}/lib/findbugs-ant.jar" />
    137                     </or>
    138                 </not>
    139             </condition>
    140         </fail>
    141         <taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"
    142             classpath="${findbugs.home}/lib/findbugs-ant.jar"/>
    143 
    144         <property name="aux.classpath" value="${toString:javac.classpathref}"/>
    145         <condition property="empty.aux.classpath">
    146             <length string="${aux.classpath}" when="eq" length="0"/>
    147         </condition>
    148     </target>
    149 
    150     <target name="_findbugs_empty_aux_classpath" if="empty.aux.classpath">
    151         <findbugs
    152             home="${findbugs.home}"
    153             output="html"
    154             outputFile="${out.dir}/fb-${ant.project.name}.html"
    155             excludeFilter="findbugs-exclude.xml">
    156  
    157             <sourcePath path="${src.dir}"/>
    158             <class location="${jar.dir}/${jar.name}"/>
    159         </findbugs>
    160     </target>
    161 
    162     <target name="_findbugs_non_empty_aux_classpath" unless="empty.aux.classpath">
    163         <findbugs
    164             home="${findbugs.home}"
    165             output="html"
    166             outputFile="${out.dir}/fb-${ant.project.name}.html"
    167             excludeFilter="findbugs-exclude.xml">
    168  
    169             <sourcePath path="${src.dir}"/>
    170             <class location="${jar.dir}/${jar.name}"/>
    171             <auxClasspath path="${aux.classpath}"/>
    172         </findbugs>
    173     </target>
    174 
    175     <target name="@findbugs" depends="_findbugs_init, @build-all, _findbugs_empty_aux_classpath, _findbugs_non_empty_aux_classpath"/>
    176 
    177     <!-- Dependencies -->
    178 
    179     <!-- collate -->
    180     <path id="javac.classpathref.collate">
    181         <pathelement location="${icu4j.core.jar}"/>
    182     </path>
    183 
    184     <target name="_all.collate" depends="_all.core">
    185         <ant dir="${icu4j.collate.dir}" inheritAll="false"/>
    186     </target>
    187 
    188     <!-- core -->
    189     <path id="javac.classpathref.core"/>
    190 
    191     <target name="_all.core">
    192         <ant dir="${icu4j.core.dir}" inheritAll="false"/>
    193     </target>
    194 
    195     <!-- charset -->
    196     <path id="javac.classpathref.charset">
    197         <pathelement location="${icu4j.core.jar}"/>
    198     </path>
    199 
    200     <target name="_all.charset" depends="_all.core">
    201         <ant dir="${icu4j.charset.dir}" inheritAll="false"/>
    202     </target>
    203 
    204     <!-- currdata -->
    205     <path id="javac.classpathref.currdata">
    206         <pathelement location="${icu4j.core.jar}"/>
    207     </path>
    208 
    209     <target name="_all.currdata" depends="_all.core">
    210         <ant dir="${icu4j.currdata.dir}" inheritAll="false"/>
    211     </target>
    212 
    213     <!-- langdata -->
    214     <path id="javac.classpathref.langdata">
    215         <pathelement location="${icu4j.core.jar}"/>
    216     </path>
    217 
    218     <target name="_all.langdata" depends="_all.core">
    219         <ant dir="${icu4j.langdata.dir}" inheritAll="false"/>
    220     </target>
    221 
    222     <!-- localespi -->
    223     <path id="javac.classpathref.localespi">
    224         <pathelement location="${icu4j.core.jar}"/>
    225         <pathelement location="${icu4j.collate.jar}"/>
    226     </path>
    227 
    228     <target name="_all.localespi" depends="_all.core, _all.collate">
    229         <ant dir="${icu4j.localespi.dir}" inheritAll="false"/>
    230     </target>
    231 
    232     <!-- regiondata -->
    233     <path id="javac.classpathref.regiondata">
    234         <pathelement location="${icu4j.core.jar}"/>
    235     </path>
    236 
    237     <target name="_all.regiondata" depends="_all.core">
    238         <ant dir="${icu4j.regiondata.dir}" inheritAll="false"/>
    239     </target>
    240 
    241     <!-- translit -->
    242     <path id="javac.classpathref.translit">
    243         <pathelement location="${icu4j.core.jar}"/>
    244         <pathelement location="${icu4j.translit.jar}"/>
    245     </path>
    246 
    247     <target name="_all.translit" depends="_all.core">
    248         <ant dir="${icu4j.translit.dir}" inheritAll="false"/>
    249     </target>
    250 
    251     <!-- test-framework -->
    252     <path id="javac.classpathref.test-framework">
    253         <pathelement location="${icu4j.core.jar}"/>
    254     </path>
    255 
    256     <target name="_all.test-framework" depends="_all.core">
    257         <ant dir="${icu4j.test-framework.dir}" inheritAll = "false"/>
    258     </target>
    259 
    260     <!-- core-tests -->
    261     <path id="javac.classpathref.core-tests">
    262         <pathelement location="${icu4j.core.jar}"/>
    263         <pathelement location="${icu4j.test-framework.jar}"/>
    264     </path>
    265 
    266     <target name="_all.core-tests" depends="_all.core, _all.test-framework">
    267         <ant dir="${icu4j.core-tests.dir}" inheritAll="false"/>
    268     </target>
    269 
    270     <!-- collate-tests -->
    271     <path id="javac.classpathref.collate-tests">
    272         <pathelement location="${icu4j.core.jar}"/>
    273         <pathelement location="${icu4j.collate.jar}"/>
    274         <pathelement location="${icu4j.test-framework.jar}"/>
    275     </path>
    276 
    277     <target name="_all.collate-tests" depends="_all.core, _all.collate, _all.test-framework">
    278         <ant dir="${icu4j.collate-tests.dir}" inheritAll="false"/>
    279     </target>
    280 
    281     <!-- charset-tests -->
    282     <path id="javac.classpathref.charset-tests">
    283         <pathelement location="${icu4j.core.jar}"/>
    284         <pathelement location="${icu4j.charset.jar}"/>
    285         <pathelement location="${icu4j.test-framework.jar}"/>
    286     </path>
    287 
    288     <target name="_all.charset-tests" depends="_all.core, _all.charset, _all.test-framework">
    289         <ant dir="${icu4j.charset-tests.dir}" inheritAll="false"/>
    290     </target>
    291 
    292     <!-- localespi-tests -->
    293     <path id="javac.classpathref.localespi-tests">
    294         <pathelement location="${icu4j.core.jar}"/>
    295 	<pathelement location="${icu4j.collate.jar}"/>
    296         <pathelement location="${icu4j.localespi.jar}"/>
    297         <pathelement location="${icu4j.test-framework.jar}"/>
    298     </path>
    299 
    300     <target name="_all.localespi-tests" depends="_all.core, _all.collate, _all.localespi, _all.test-framework">
    301         <ant dir="${icu4j.localespi-tests.dir}" inheritAll="false"/>
    302     </target>
    303 
    304     <!-- packaging-tests -->
    305     <path id="javac.classpathref.packaging-tests">
    306         <pathelement location="${icu4j.core.jar}"/>
    307         <pathelement location="${icu4j.charset.jar}"/>
    308         <pathelement location="${icu4j.test-framework.jar}"/>
    309     </path>
    310 
    311     <target name="_all.packaging-tests" depends="_all.core, _all.charset, _all.test-framework">
    312         <ant dir="${icu4j.packaging-tests.dir}" inheritAll="false"/>
    313     </target>
    314 
    315     <!-- translit-tests -->
    316     <path id="javac.classpathref.translit-tests">
    317         <pathelement location="${icu4j.core.jar}"/>
    318         <pathelement location="${icu4j.translit.jar}"/>
    319         <pathelement location="${icu4j.test-framework.jar}"/>
    320     </path>
    321 
    322     <target name="_all.translit-tests" depends="_all.core, _all.translit, _all.test-framework">
    323         <ant dir="${icu4j.translit-tests.dir}" inheritAll="false"/>
    324     </target>
    325 
    326     <!-- testall -->
    327     <path id="javac.classpathref.testall">
    328         <pathelement location="${icu4j.core.jar}"/>
    329         <pathelement location="${icu4j.test-framework.jar}"/>
    330     </path>
    331 
    332     <target name="_all.testall" depends="_all.core, _all.test-framework">
    333         <ant dir="${icu4j.testall.dir}" inheritAll="false"/>
    334     </target>
    335 
    336 
    337     <!-- build-tools -->
    338     <path id="javac.classpathref.build-tools">
    339         <pathelement location="${env.JAVA_HOME}/lib/tools.jar"/>
    340     </path>
    341 
    342     <target name="_all.build-tools">
    343         <ant dir="${icu4j.build-tools.dir}" inheritAll="false"/>
    344     </target>
    345 
    346     <!-- tools -->
    347     <path id="javac.classpathref.tools">
    348         <pathelement location="${icu4j.core.jar}"/>
    349         <pathelement location="${icu4j.collate.jar}"/>
    350         <pathelement location="${icu4j.translit.jar}"/>
    351         <pathelement location="${icu4j.test-framework.jar}"/>
    352         <pathelement location="${icu4j.core-tests.jar}"/>
    353         <pathelement location="${icu4j.translit-tests.jar}"/>
    354     </path>
    355 
    356     <target name="_all.tools" depends="_all.core, _all.collate, _all.translit, _all.test-framework, _all.core-tests, _all.translit-tests">
    357         <ant dir="${icu4j.tools.dir}" inheritAll="false"/>
    358     </target>
    359 
    360     <!-- demos -->
    361     <path id="javac.classpathref.demos">
    362         <pathelement location="${icu4j.core.jar}"/>
    363         <pathelement location="${icu4j.translit.jar}"/>
    364         <pathelement location="${icu4j.charset.jar}"/>
    365     </path>
    366 
    367     <target name="_all.demos" depends="_all.core, _all.translit, _all.charset">
    368         <ant dir="${icu4j.demos.dir}" inheritAll="false"/>
    369     </target>
    370 
    371     <!-- samples -->
    372     <path id="javac.classpathref.samples">
    373         <pathelement location="${icu4j.core.jar}"/>
    374         <pathelement location="${icu4j.collate.jar}"/>
    375         <pathelement location="${icu4j.translit.jar}"/>
    376         <pathelement location="${icu4j.charset.jar}"/>
    377     </path>
    378 
    379     <target name="_all.samples" depends="_all.core, _all.collate, _all.translit, _all.charset">
    380         <ant dir="${icu4j.samples.dir}" inheritAll="false"/>
    381     </target>
    382 
    383     <!-- perf -->
    384     <path id="javac.classpathref.perf-tests">
    385         <pathelement location="${icu4j.core.jar}"/>
    386         <pathelement location="${icu4j.charset.jar}"/>
    387         <pathelement location="${icu4j.collate.jar}"/>
    388         <pathelement location="${icu4j.tools.jar}"/>
    389     </path>
    390 
    391     <target name="_all.perf-tests" depends="_all.core, _all.charset, _all.collate, _all.tools">
    392         <ant dir="${icu4j.perf-tests.dir}" inheritAll="false"/>
    393     </target>
    394 
    395 </project>
    396