Source

propertyset / build.xml

Full commit
<project default="jar" basedir=".">
  <path id="cp">
    <fileset dir="lib">
      <include name="**/*.jar"/>
    </fileset>
  </path>

  <path id="jalopy.classpath">
    <fileset dir="lib/build/jalopy">
      <include name="*.jar"/>
    </fileset>
  </path>

  <taskdef name="jalopy" classname="de.hunsicker.jalopy.plugin.ant.AntPlugin">
    <classpath refid="jalopy.classpath"/>
  </taskdef>

  <taskdef name="ejbdoclet" classname="xdoclet.modules.ejb.EjbDocletTask" classpathref="cp"/>

  <target name="junit-check" depends="init" unless="junit.available">
    <fail message="Cannot run test cases. Please copy lib/build/junit-3.8.1.jar to ${ant.home}/lib"/>
  </target>

  <target name="clover-check" depends="init" unless="clover.available">
    <fail message="Cannot run coverage tests. Please copy lib/build/clover-1.2.jar to ${ant.home}/lib"/>
  </target>

  <target name="init">
    <property file="build.properties"/>

    <property name="lib" value="lib"/>
    <property name="lib.core" value="${lib}/core"/>
    <property name="lib.build" value="${lib}/build"/>
    <property name="lib.optional" value="${lib}/optional"/>

    <property name="src" value="src"/>
    <property name="src.java" value="${src}/java"/>
    <property name="src.test" value="${src}/test"/>
    <property name="src.etc" value="${src}/etc"/>

    <property name="build" value="build"/>
    <property name="build.test" value="${build}/test"/>
    <property name="build.java" value="${build}/java"/>

    <property name="dist" value="dist"/>
    <property name="docs" value="docs"/>
    <property name="clover.initstring" location="testcoverage.db"/>
    <property name="packages" value="com.opensymphony.*"/>

    <available property="junit.available" classname="junit.framework.TestCase"/>
    <available property="clover.available" classname="org.apache.tools.ant.taskdefs.CloverCompilerAdapter" />
  </target>

  <target name="clean" depends="init">
    <delete dir="${tmp}"/>
    <delete dir="${build}"/>
    <delete dir="${dist}"/>
    <delete>
      <fileset dir="${src.java}/com/opensymphony/module/propertyset/ejb">
        <exclude name="**/*EJB*.java" />
      </fileset>
    </delete>
    <delete>
      <fileset dir="." includes="testcoverage.db*"/>
    </delete>
  </target>

  <target name="ejbdoclet" depends="init">
    <!-- work around a bug in xdoclet -->
    <delete file="${build.java}/META-INF/orion-ejb-jar.xml" />
    <ejbdoclet ejbspec="2.0" verbose="false" destdir="${src.java}">
      <fileset dir="${src.java}">
        <include name="com/opensymphony/module/propertyset/ejb/**/*EJB.java" />
      </fileset>
      <remoteinterface/>
      <localinterface/>
      <homeinterface/>
      <localhomeinterface/>
      <!--<valueobject/>-->
      <!--<entitypk/>-->
      <entitycmp/>
      <!--<session/>-->
      <utilobject pattern="{0}HomeFactory" cacheHomes="true" />
      <deploymentdescriptor destdir="${build.java}/META-INF" validatexml="true" description="OpenSymphony PropertySet" displayname="PropertySet Module"/>
      <jboss version="3.0" destdir="${build.java}/META-INF"/>
      <weblogic version="7.0" destdir="${build.java}/META-INF" datasource="defaultDS" createtables="true"/>
      <jrun version="4.0" destdir="${build.java}/META-INF" />
      <orion version="2.0" destdir="${build.java}/META-INF" />
    </ejbdoclet>
  </target>

  <target name="java" depends="ejbdoclet">
    <mkdir dir="${build.java}"/>
    <javac srcdir="${src.java}" destdir="${build.java}" classpathref="cp" debug="on"/>
    <copy filtering="no" todir="${build.java}">
      <fileset dir="${src.java}">
        <exclude name="**/*.java"/>
        <exclude name="**/package.html"/>
      </fileset>
    </copy>
    <copy file="${src.etc}/propertyset-default.xml" todir="${build.java}/META-INF" />
  </target>

  <target name="test" depends="junit-check,ejbdoclet">
    <taskdef name="junit" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"/>
    <mkdir dir="${build.test}"/>
    <javac srcdir="${src.java}" destdir="${build.test}" classpathref="cp" debug="on" compiler="org.apache.tools.ant.taskdefs.CloverCompilerAdapter"/>
    <javac srcdir="${src.test}" destdir="${build.test}" classpathref="cp" debug="on"/>

    <mkdir dir="${dist}/docs/junit"/>
    <junit printsummary="yes" haltonfailure="yes" haltonerror="yes" fork="yes">
      <classpath>
        <pathelement location="${build.test}"/>
        <path refid="cp"/>
      </classpath>

      <formatter type="xml"/>

      <batchtest todir="${dist}/docs/junit">
        <fileset dir="${src.test}">
          <include name="**/*Test.java"/>
        </fileset>
      </batchtest>
    </junit>
  </target>

  <target name="format" depends="java">
    <jalopy fileformat="unix" convention="src/etc/jalopy.xml" history="file" historymethod="adler32" loglevel="error" threads="2" classpathref="cp">
      <fileset dir="${src.java}">
        <include name="**/*.java"/>
      </fileset>
      <fileset dir="${src.test}">
        <include name="**/*.java"/>
      </fileset>
    </jalopy>
  </target>

  <target name="jar" depends="format">
    <mkdir dir="${dist}"/>
    <jar basedir="${build.java}" jarfile="${dist}/${name}-${version}.jar"/>
  </target>

    <target name="ejb-jar" depends="format">
        <mkdir dir="${dist}"/>
        <jar basedir="${build.java}" jarfile="${dist}/${name}-ejb-${version}.jar" manifest="${src.etc}/manifest-ejb.txt">
            <exclude name="**/ofbiz/**" />
        </jar>
    </target>

   <target name="ofbiz-jar" depends="format">
       <mkdir dir="${dist}"/>
       <jar basedir="${build.java}" jarfile="${dist}/${name}-ofbiz-${version}.jar">
           <include name="**/ofbiz/**" />
       </jar>
   </target>
  <target name="javadocs" depends="init">
    <mkdir dir="${dist}/docs/api"/>
    <javadoc sourcepath="${src.java}" destdir="${dist}/docs/api" packagenames="${packages}" classpathref="cp" author="true" version="true" windowTitle="${name} ${version} API" doctitle="${name}" footer="See &lt;a href=&quot;http://www.opensymphony.com&quot;&gt;www.opensymphony.com&lt;/a&gt; for more information." use="true" verbose="false"/>
    <copy overwrite="yes" file="${docs}/main.css" tofile="${dist}/docs/api/stylesheet.css"/>
  </target>

  <target name="clover.report" depends="clover-check,test">
    <java classname="com.cortexeb.tools.clover.reporters.html.HtmlReporter" fork="true">
      <arg line="--outputdir ${dist}/docs/clover --showSrc --initstring ${clover.initstring} --title '${name}'"/>
      <classpath refid="cp"/>
    </java>
  </target>

  <target name="junit.report" depends="junit-check,test">
    <taskdef name="junit" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"/>
    <junitreport todir="${dist}/docs/junit">
      <fileset dir="${dist}/docs/junit">
        <include name="TEST-*.xml"/>
      </fileset>
      <report format="frames" todir="${dist}/docs/junit"/>
    </junitreport>
  </target>

  <target name="docs" depends="javadocs, clover.report, junit.report">
    <copy todir="${dist}/docs">
      <fileset dir="${docs}"/>
    </copy>
  </target>

  <target name="dist" depends="jar, docs">
    <mkdir dir="${dist}/zip"/>
    <mkdir dir="${dist}/zip/docs"/>
    <mkdir dir="${dist}/zip/src"/>
    <mkdir dir="${dist}/zip/lib"/>

    <copy todir="${dist}/zip/docs">
      <fileset dir="${dist}/docs"/>
    </copy>

    <copy todir="${dist}/zip/src">
      <fileset dir="src"/>
    </copy>

    <copy todir="${dist}/zip/lib">
      <fileset dir="${lib.core}"/>
    </copy>

    <copy file="${dist}/${name}-${version}.jar" todir="${dist}/zip"/>

    <zip zipfile="${dist}/${name}-${version}.zip" basedir="${dist}/zip"/>

    <delete dir="${dist}/zip"/>
  </target>
</project>