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

View of /jsr166/build.xml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.16 - (download) (as text) (annotate)
Fri Dec 13 06:34:04 2002 UTC (11 years, 4 months ago) by tim
Branch: MAIN
Changes since 1.15: +47 -10 lines
Added doccheck target, not working yet.
Added strip target to produce "angle-bracket free" code
<project name="jsr166" default="jar">

  <description>

    Build file for JSR-166

    Note that junit.jar must be in ${ant.home}/lib for the
    test target to work. [FIXME: This should be automatically
    enforced by this build file by failing with a message if
    junit.jar is not in the right place.]

  </description>

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

  <!-- Build locations -->
  <property name="build.dir"            location="build"/>
  <property name="build.classes.dir"    location="${build.dir}/classes"/>
  <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}"/>
  <property name="test.src.dir"         location="${basedir}/etc/testcases"/>
  <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="javac.jar"            location="${lib.dir}/javac.jar"/>
  <property name="collect.jar"          location="${lib.dir}/collect.jar"/>
  <property name="junit.jar"            location="${lib.dir}/junit.jar"/>
  <property name="rt.jar"               location="${java.home}/lib/rt.jar"/>

  <property name="javac.args"           value='-J-Xbootclasspath/p:${javac.jar}'/>

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

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


  <!-- Main targets -->

  <target name="compile" depends="init"
          description="Compiles all sources to build folder">
    <mkdir dir="${build.classes.dir}"/>
    <javac srcdir="${src.dir}"
          destdir="${build.classes.dir}"
            debug="${build.debug}"
       debuglevel="${build.debuglevel}"
      deprecation="${build.deprecation}"
           source="${build.sourcelevel}"
             fork="true">

      <bootclasspath refid="javac.bootclasspath"/>
      <compilerarg line="${javac.args} ${build.warnings.option}"/>

      <!-- need this because srcdir is basedir! -->
      <include name="java/**/*.java"/>

    </javac>
  </target>


  <target name="jar" depends="compile"
          description="Builds library jar from compiled sources">
    <mkdir dir="${build.lib.dir}"/>
    <jar basedir="${build.classes.dir}"
        destfile="${product.jar}"
    />
  </target>


  <target name="test" depends="init, report-tests"
          description="Runs all tests"/>


  <target name="checkstyle" depends="filter-src"
          description="Reports on style errors in Java source">
    <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">
    <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}">
        <include name="java/**"/>
      </packageset>
    </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.sourcelevel}">

      <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}">
        <include name="java/**"/>
      </packageset>

    </javadoc>
  </target>


  <target name="strip" depends="init">
    <mkdir dir="${build.stripped.dir}"/>
    <javac srcdir="${src.dir}"
          destdir="${build.stripped.dir}"
            debug="${build.debug}"
       debuglevel="${build.debuglevel}"
      deprecation="${build.deprecation}"
           source="${build.sourcelevel}"
             fork="true">

      <bootclasspath refid="javac.bootclasspath"/>
      <compilerarg line="${javac.args} ${build.warnings.option} -s"/>

      <!-- need this because srcdir is basedir! -->
      <include name="java/**/*.java"/>

    </javac>
  </target>


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


  <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>


  <!-- Anthill targets -->

  <!-- Should really run the tests instead of just the jar target -->
  <target name="anthill-build" depends="jar, docs, dist-docs"
          description="Build the jar and both the external and internal 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>
  </target>


  <!-- Internal targets -->

  <target name="set-warnings-if" if="build.warnings">
    <property name="build.warnings.option" value="-warnunchecked"/>
  </target>


  <target name="set-warnings-unless" unless="build.warnings">
    <property name="build.warnings.option" value=""/>
  </target>


  <target name="init" depends="set-warnings-if, set-warnings-unless">
    <!-- Version is kept in a separate file -->
    <loadfile property="version" srcFile="version.properties"/>
    <echo>Building JSR-166 version ${version}</echo>
  </target>


  <target name="dist-jar" depends="clean, jar">
    <copy file="${product.jar}" todir="${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.sourcelevel}">

      <packageset dir="${build.filter.src.dir}">
        <include name="java/**"/>
      </packageset>

    </javadoc>
  </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="java/**/*.java"/>
      </fileset>
      <filterchain>
        <filterreader classname="jsr166.ant.filters.ReplaceFilter"
                      classpath="${build.ant.dir}">
          <!--
           # These arguments are to get rid of angle-bracketed type
           # parameters so that javadoc can run on the result. The
           # following heuristic that 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.)
           -->
          <param name="notmatching" value="^\s+\*\s.*$"/>
          <param name="pattern" value="&lt;[^|>()]+?>+"/>
          <param name="replacement" value=" "/>
        </filterreader>
        <filterreader classname="jsr166.ant.filters.ReplaceFilter"
                      classpath="${build.ant.dir}">
          <!--
           # These arguments are to uncomment lines beginning with
           # "//@" so that javadoc can see imports that are needed
           # to resolve links but that shouldn't be in the compiled
           # code.
           -->
          <param name="matching" value="^//@.*$"/>
          <param name="pattern" value="^//@"/>
          <param name="replacement" value=""/>
        </filterreader>
      </filterchain>
    </copy>
  </target>


  <target name="compile-tests" depends="jar">
    <mkdir dir="${build.testcases.dir}"/>
    <javac srcdir="${test.src.dir}"
          destdir="${build.testcases.dir}"
            debug="${build.debug}"
       debuglevel="${build.debuglevel}"
      deprecation="${build.deprecation}"
           source="${build.sourcelevel}"
             fork="true">

      <bootclasspath refid="javac.bootclasspath"/>
      <compilerarg line="${javac.args} ${build.warnings.option}"/>
      <classpath refid="test.classpath"/>
      <include name="**/*Test.java"/>

    </javac>
  </target>


  <target name="run-tests" depends="compile-tests">
    <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:${product.jar}"/>

      <classpath>
        <!-- <path refid="test.classpath"/> -->
        <pathelement location="${build.testcases.dir}"/>
      </classpath>

      <formatter type="xml"/>

      <batchtest todir="${build.reports.dir}">
        <fileset dir="${test.src.dir}">
          <include name="**/*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>


</project>

Doug Lea
ViewVC Help
Powered by ViewVC 1.0.8