[cvs] / jsr166 / build.xml Repository:
ViewVC logotype

View of /jsr166/build.xml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.43 - (download) (as text) (annotate)
Thu Jun 26 11:54:26 2003 UTC (14 years, 3 months ago) by tim
Branch: MAIN
Changes since 1.42: +10 -0 lines
Exclude 2.1-ea jars from release
<project name="jsr166" default="usage">

  <description>
------------------------------------------------------------------------------
  Build file for JSR-166

  Usage: ant [target]

  User-specific settings are read from user.properties.
  See user.properties.sample for an explanation of some useful settings.
------------------------------------------------------------------------------
  </description>

  <target name="usage" description="Advises user to run with -projecthelp">
    <echo>Run "ant -projecthelp" for full usage information.</echo>
  </target>


  <!-- User-specific settings -->
  <property file="user.properties"/>


  <!-- Compilation options -->
  <property name="build.sourcelevel"    value="1.5"/>
  <property name="build.docsourcelevel" value="1.4"/>
  <property name="build.debug"          value="true"/>
  <property name="build.debuglevel"     value="source,lines,vars"/>
  <property name="build.deprecation"    value="false"/>

  <!-- Build locations -->
  <property name="build.dir"            location="build"/>
  <property name="build.classes.dir"    location="${build.dir}/classes"/>
  <property name="build.emulation.dir"  location="${build.dir}/emulation"/>
  <property name="build.testcases.dir"  location="${build.dir}/testcases"/>
  <property name="build.lib.dir"        location="${build.dir}/lib"/>
  <property name="build.ant.dir"        location="${build.dir}/ant"/>
  <property name="build.javadocs.dir"   location="${build.dir}/javadocs"/>
  <property name="build.stripped.dir"   location="${build.dir}/stripped"/>
  <property name="build.reports.dir"    location="${build.dir}/reports"/>
  <property name="build.doccheck.dir"   location="${build.dir}/doccheck"/>
  <property name="build.filter.src.dir" location="${build.dir}/filtersrc"/>

  <!-- Source locations -->
  <property name="src.dir"              location="${basedir}/src/main"/>
  <property name="emulation.src.dir"    location="${basedir}/src/emulation"/>
  <property name="test.src.dir"         location="${basedir}/src/test"/>
  <property name="ant.src.dir"          location="${basedir}/etc/ant"/>
  <property name="stylesheet.dir"       location="${basedir}/etc/xsl"/>
  <property name="lib.dir"              location="${basedir}/lib"/>
  <property name="dist.dir"             location="${basedir}/dist"/>

  <!-- Distribution locations -->
  <property name="dist.javadocs.dir"    location="${dist.dir}/docs"/>

  <!-- Jar locations -->
  <property name="product.jar"          location="${build.lib.dir}/jsr166.jar"/>
  <property name="junit.jar"            location="${lib.dir}/junit.jar"/>
  <property name="rt.jar"               location="${java.home}/lib/rt.jar"/>



  <!-- Files excluded from dist-docs and emulation jar -->
  <patternset id="unsafe.exclusion">
    <exclude name="java/util/Random.*"/>
    <exclude name="sun/misc/Unsafe.*"/>
  </patternset>

  <!-- Files excludes from emulation jar -->
  <patternset id="atomic.exclusion">
    <exclude name="java/util/concurrent/atomic/AtomicBoolean*"/>
    <exclude name="java/util/concurrent/atomic/AtomicInteger*"/>
    <exclude name="java/util/concurrent/atomic/AtomicLong*"/>
    <exclude name="java/util/concurrent/atomic/AtomicReference*"/>
  </patternset>



  <!-- Main targets -->

  <target name="compile"
          depends="init, configure-compiler, prepare-src"
          description="Compiles main sources to build folder">

    <property name="prepare.src.dir" value="${src.dir}"/>

    <mkdir dir="${build.classes.dir}"/>

<!--
    <echo>javac ${gjc.args}</echo>
    <echo>bootclasspath=${compile.bootclasspath}</echo>
-->

    <javac srcdir="${prepare.src.dir}"
          destdir="${build.classes.dir}"
            debug="${build.debug}"
       debuglevel="${build.debuglevel}"
      deprecation="${build.deprecation}"
           source="${build.sourcelevel}"
             fork="true">

      <compilerarg    line="${gjc.args}"/>
      <bootclasspath refid="compile.bootclasspath"/>

    </javac>

  </target>


  <target name="jar"
          depends="configure-emulation, init-jar, native-jar, emulation-jar"
          description="Builds library jar from compiled sources"/>


  <target name="test"
          depends="init, configure-tests, report-tests"
          description="Runs all tests (requires JUnit 3.8.1 in ${ant.home}/lib)" />


  <target name="checkstyle"
          depends="filter-src"
          description="Reports on style errors in Java source (verbose, mostly chaff)">

    <taskdef resource="checkstyletask.properties"
            classpath="${lib.dir}/checkstyle-all-2.4.jar"/>

    <checkstyle>
      <formatter type="plain"/>  <!-- also available: type="xml" -->
      <fileset dir="${build.filter.src.dir}" includes="**/*.java"/>
    </checkstyle>

  </target>


  <target name="doccheck"
          depends="filter-src"
          description="Reports on javadoc style errors (not working yet)">

    <delete dir="${build.doccheck.dir}"/>
    <mkdir dir="${build.doccheck.dir}"/>

    <javadoc doclet="com.sun.tools.doclets.doccheck.DocCheck"
         docletpath="${lib.dir}/doccheck.jar"
            destdir="${build.doccheck.dir}">
      <packageset dir="${build.filter.src.dir}"/>
    </javadoc>

  </target>


  <target name="docs"
          depends="filter-src"
          description="Builds javadocs with custom tags to build folder">

    <delete dir="${build.javadocs.dir}"/>
    <mkdir dir="${build.javadocs.dir}"/>

    <javadoc destdir="${build.javadocs.dir}"
                link="http://java.sun.com/j2se/1.4.1/docs/api"
            overview="${src.dir}/intro.html"
              source="${build.docsourcelevel}">

      <tag name="revised" description="Last revised:"/>
      <tag name="spec"    description="Specified by:"/>
      <tag name="editor"  description="Last edited by:"/>
      <tag name="fixme"   description="FIX ME:"/>

      <packageset dir="${build.filter.src.dir}"/>

    </javadoc>

  </target>


  <target name="strip"
          depends="init, configure-compiler"
          description="Strip generics from java source (not working yet)">

    <mkdir dir="${build.stripped.dir}"/>

    <!--
     # javac -s doesn't reliably generate compilable code. It generates
     # bridge methods (marked as "synthetic") that can have identical
     # signatures to existing methods except for the return value.
     -->
    <javac srcdir="${src.dir}"
          destdir="${build.stripped.dir}"
            debug="${build.debug}"
       debuglevel="${build.debuglevel}"
      deprecation="${build.deprecation}"
           source="${build.sourcelevel}"
             fork="true">

      <compilerarg    line="${gjc.args} -s"/>
      <bootclasspath refid="compile.bootclasspath"/>

    </javac>

  </target>


  <target name="dist"
          depends="init, dist-clean, dist-jar, dist-docs"
          description="Puts all distributable products in single hierarchy"/>

  <target name="release"
          depends="dist"
          description="Puts entire CVS tree, plus distribution productions, in a jar">

    <delete dir="${build.dir}"/>

    <property name="release.jar" value="dist/jsr166-${version}-dist.jar"/>

    <jar basedir="${basedir}" destfile="${release.jar}">
      <exclude name="${release.jar}"/>
      <exclude name="user.properties"/>
      <exclude name="etc/notes/**"/>
      <exclude name="lib/gjc/2.1/**"/>
    </jar>

  </target>

  <target name="clean"
          description="Removes all build products">

    <delete dir="${build.dir}"/>
    <delete dir="${build.classes.dir}"/>
    <delete dir="${build.lib.dir}"/>

  </target>


  <target name="dist-clean"
          description="Removes all build and distribution products">

    <delete dir="${dist.dir}"/>

  </target>


  <target name="dist-docs"
          depends="filter-src"
          description="Builds javadocs without custom tags to dist folder">

    <delete dir="${dist.javadocs.dir}"/>
    <mkdir dir="${dist.javadocs.dir}"/>

    <javadoc destdir="${dist.javadocs.dir}"
                link="http://java.sun.com/j2se/1.4.1/docs/api"
            overview="${src.dir}/intro.html"
              source="${build.docsourcelevel}">

      <packageset dir="${build.filter.src.dir}"/>

    </javadoc>

  </target>



  <!-- Internal targets -->


  <target name="init">

    <!-- Version is kept in a separate file -->
    <loadfile property="version" srcFile="version.properties"/>
    <echo>Building JSR-166 version ${version}</echo>

  </target>


  <target name="init-jar">

    <mkdir dir="${build.lib.dir}"/>

  </target>


  <target name="native-jar"
          depends="compile"
          unless="build.emulation.true">

    <jar destfile="${product.jar}">
      <fileset dir="${build.classes.dir}"/>
    </jar>

  </target>


  <target name="compile-emulation"
          depends="init, configure-compiler"
          if="build.emulation.true">

    <mkdir dir="${build.emulation.dir}"/>

    <javac srcdir="${emulation.src.dir}"
          destdir="${build.emulation.dir}"
            debug="${build.debug}"
       debuglevel="${build.debuglevel}"
      deprecation="${build.deprecation}"
           source="${build.sourcelevel}"
             fork="true">

      <compilerarg    line="${gjc.args}"/>
      <bootclasspath refid="compile.bootclasspath"/>

    </javac>

  </target>


  <target name="emulation-jar"
          depends="compile-emulation"
          if="build.emulation.true">


    <jar destfile="${product.jar}" duplicate="add">
      <fileset dir="${build.classes.dir}">
        <patternset refid="atomic.exclusion"/>
        <patternset refid="unsafe.exclusion"/>
      </fileset>
      <fileset dir="${build.emulation.dir}"/>
    </jar>

  </target>


  <target name="dist-jar"
          depends="clean, jar">

    <copy file="${product.jar}" todir="${dist.dir}"/>

  </target>


  <target name="compile-ant-filter"
          depends="init">

    <mkdir dir="${build.ant.dir}"/>

    <javac srcdir="${ant.src.dir}"
          destdir="${build.ant.dir}"
           source="1.4"
    />

  </target>


  <target name="filter-src"
          depends="compile-ant-filter">

    <mkdir dir="${build.filter.src.dir}"/>

    <copy todir="${build.filter.src.dir}">
      <fileset dir="${src.dir}">
        <include name="**/*.html"/>
      </fileset>
    </copy>

    <!-- Not needed now, used for doccheck filtering:
    <property name="generic.declarations"
             value="public interface E {} public interface T {} public interface K {} public interface V {}"
    />
    -->

    <copy todir="${build.filter.src.dir}">
      <fileset dir="${src.dir}">
        <exclude name="**/*.html"/>
        <patternset refid="unsafe.exclusion"/>
      </fileset>
      <filterchain>

        <!--
         # This filter gets rid of angle-bracketed type parameters
         # so that javadoc can run on the result. The following
         # heuristic seems to work:
         #
         # For all lines not starting with space(s)-asterisk-space(s),
         #   replace <something> with a space, where there may be more
         #   than one right angle bracket at the end, and "something"
         #   must not contain parens or pipes. (This may need some
         #   tweaking.)
         -->

        <filterreader classname="jsr166.ant.filters.ReplaceFilter"
                      classpath="${build.ant.dir}">
          <param name="notmatching" value="^\s+\*\s.*$"/>
          <param name="pattern"     value="&lt;[^|>()]+?>+"/>
          <param name="replacement" value=" "/>
        </filterreader>


        <!--
         # This filter uncomments lines beginning with "//@" so that
         # javadoc can see imports that are needed to resolve links
         # but that shouldn't be in the compiled code.
         -->

        <filterreader classname="jsr166.ant.filters.ReplaceFilter"
                      classpath="${build.ant.dir}">
          <param name="matching"    value="^//@.*$"/>
          <param name="pattern"     value="^//@"/>
          <param name="replacement" value=""/>
        </filterreader>


        <!--
         # The next two filters try to make the source look like
         # something that doccheck can process. The first removes
         # -source 1.4 assertions and the second adds in a bunch
         # of single letter public nested marker interfaces so that
         # the generic type parameters are recognized.
         #
         # Currently commented out because doccheck doesn't work. :-(
         -->

        <!--
        <filterreader classname="jsr166.ant.filters.ReplaceFilter"
                      classpath="${build.ant.dir}">
          <param name="matching"    value="^\s*assert[\s ].*$"/>
          <param name="pattern"     value="assert"/>
          <param name="replacement" value="//assert"/>
        </filterreader>

        <filterreader classname="jsr166.ant.filters.ReplaceFilter"
                      classpath="${build.ant.dir}">
          <param name="matching"    value="^(.*(class|interface|implements) .*|)\{.*$"/>
          <param name="pattern"     value="$"/>
          <param name="replacement" value=" ${generic.declarations}"/>
        </filterreader>
        -->

      </filterchain>
    </copy>

  </target>


  <target name="compile-tests"
          depends="jar">

    <mkdir dir="${build.testcases.dir}"/>

<!--
    <echo>javac ${gjc.args}</echo>
    <echo>bootclasspath=${test.compile.bootclasspath}</echo>
    <echo>classpath="${test.classpath}"</echo>
-->

    <javac srcdir="${test.src.dir}"
          destdir="${build.testcases.dir}"
            debug="${build.debug}"
       debuglevel="${build.debuglevel}"
      deprecation="${build.deprecation}"
           source="${build.sourcelevel}"
             fork="true">

      <compilerarg    line="${gjc.args}"/>
      <bootclasspath refid="test.compile.bootclasspath"/>
      <classpath     refid="test.classpath"/>

    </javac>

  </target>


  <target name="run-tests"
          depends="compile-tests">

    <!-- May be overridden by user.properties -->
    <property name="testcase" value="*"/>

    <mkdir dir="${build.reports.dir}"/>

    <junit printsummary="true"
             showoutput="true"
          errorProperty="junit.failed"
        failureProperty="junit.failed"
                    dir="${build.reports.dir}"
                   fork="true">

      <jvmarg value="-Xbootclasspath/p:${test.run.bootclasspath}"/>

      <formatter type="xml"/>

      <batchtest todir="${build.reports.dir}">
        <fileset dir="${test.src.dir}">
          <include name="**/${testcase}Test.java"/>
        </fileset>
      </batchtest>

    </junit>

  </target>


  <target name="report-tests"
          depends="run-tests">

    <!-- Sets junit.report.format to frames if Xalan is present,
         otherwise sets it to noframes. -->
    <available property="junit.report.format"
                  value="frames"
              classname="org.apache.xalan.lib.Redirect"
    />
    <property name="junit.report.format" value="noframes"/>

    <junitreport todir="${build.reports.dir}">
      <fileset dir="${build.reports.dir}">
        <include name="TEST-*.xml"/>
      </fileset>
      <report styledir="${stylesheet.dir}"
                format="${junit.report.format}"
                 todir="${build.reports.dir}"
      />
    </junitreport>

    <fail message="Test Cases Failed" if="junit.failed"/>

  </target>


  <target name="configure-compiler">

    <property name="gjc.version"
             value="2.0"/>

    <condition property="novariance.arg" value="-novariance">
      <and>
        <equals arg1="${gjc.version}" arg2="2.0"/>
        <or>
          <not><isset property="gjc.novariance"/></not>
          <istrue value="${gjc.novariance}"/>
        </or>
      </and>
    </condition>

    <property name="novariance.arg"
             value=""/>

    <property name="gjc.dir"
             value="${lib.dir}/gjc"/>

    <property name="javac.jar"
          location="${gjc.dir}/${gjc.version}/javac.jar"/>

    <property name="collect.jar"
          location="${gjc.dir}/${gjc.version}/collect${novariance.arg}.jar"/>


    <condition property="warnunchecked.arg" value="-warnunchecked">
      <istrue value="${gjc.warnunchecked}"/>
    </condition>

    <property name="warnunchecked.arg" value=""/>

    <condition property="prepare.src.dir" value="${build.dir}/prepare-src">
      <istrue value="${build.nothreads}"/>
    </condition>


    <!--
     ! Bootclasspath munging for source compilation.
     -->

    <path id="pre.bootclasspath">
      <pathelement location="${javac.jar}"/>
    </path>

    <path id="compile.bootclasspath">
      <pathelement location="${build.classes.dir}"/>
      <pathelement location="${collect.jar}"/>
      <pathelement location="${rt.jar}"/>
    </path>

    <!-- Flatten paths into platform-appropriate strings -->
    <property name="pre.bootclasspath"     refid="pre.bootclasspath"/>
    <property name="compile.bootclasspath" refid="compile.bootclasspath"/>


    <!-- Common options in javac invocations -->
    <property name="gjc.args"
             value="-J-Xbootclasspath/p:${pre.bootclasspath} ${warnunchecked.arg} ${novariance.arg}"
    />

  </target>


  <target name="prepare-src"
          depends="configure-compiler"
          if="prepare.src.dir">

    <mkdir dir="${prepare.src.dir}"/>
    <copy todir="${prepare.src.dir}">
      <fileset dir="${src.dir}">
        <exclude name="java/lang/**"/>
      </fileset>
    </copy>

  </target>


  <target name="configure-emulation">

    <condition property="build.emulation.true">
      <or>
        <and>
          <os family="windows"/>
          <not>
            <isset property="build.emulation"/>
          </not>
        </and>
        <istrue value="${build.emulation}"/>
      </or>
    </condition>

  </target>


  <target name="configure-tests"
       depends="configure-compiler">

    <!-- junit.framework.Protectable is in JUnit 3.8.1 but not in 3.7 -->
    <available property="junit.available"
               classname="junit.framework.Protectable"/>

    <fail message="Need JUnit 3.8.1 in ${ant.home}${file.separator}lib to run tests"
          unless="junit.available"/>


    <!--
     ! Bootclasspath munging for testing, so JUnit can test our local
     ! modifications to java.*.
     -->

    <path id="test.classpath">
      <pathelement location="${product.jar}"/>
      <pathelement location="${build.testcases.dir}"/>
      <pathelement location="${junit.jar}"/>
    </path>

    <path id="test.compile.bootclasspath">
      <pathelement location="${javac.jar}"/>
      <pathelement location="${collect.jar}"/>
      <pathelement location="${rt.jar}"/>
    </path>

    <path id="test.run.bootclasspath">
      <pathelement location="${javac.jar}"/>
      <path refid="test.classpath"/>
    </path>

    <!-- Flatten test classpaths into platform-appropriate strings -->
    <property name="test.classpath"             refid="test.classpath"/>
    <property name="test.compile.bootclasspath" refid="test.compile.bootclasspath"/>
    <property name="test.run.bootclasspath"     refid="test.run.bootclasspath"/>

  </target>



  <!-- Anthill targets -->

  <target name="anthill-build"
          depends="jar, test, docs, dist-docs"/>

  <target name="anthill-publish">

    <copy todir="${deployDir}/docs/private">
      <fileset dir="${build.javadocs.dir}"/>
    </copy>

    <copy todir="${deployDir}/docs/public">
      <fileset dir="${dist.javadocs.dir}"/>
    </copy>

    <copy tofile="${deployDir}/index.html"
          file="${basedir}/etc/anthill-index.html"/>

    <copy todir="${deployDir}/notes">
      <fileset dir="${basedir}/etc/notes"/>
    </copy>

  </target>


  <target name="ng" depends="test">
    <java classname="SuperfluousAbstract" fork="true">

      <jvmarg value="-Xbootclasspath/p:${test.run.bootclasspath}"/>

    </java>
  </target>


</project>

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8