Source

oscache / build.xml

<?xml version="1.0" ?>

<!-- OSCache build file - http://www.opensymphony.com/oscache -->
<project name="oscache" default="jar" basedir=".">

    <!-- overridden properties (must be before the import!) -->
   
    <property name="lib.optional" value="${lib}/plugins"/> <!-- overwritten -->
    <property name="jar.excludes" value="test/**, docs/**, *.war, **/*.html"/>

    <property name="tmp.dir" value="tmp"/> <!-- ??? -->

    <!-- This property must match with what is included in the oscache.properties files -->
    <property name="test.cache.path" value="/tmp/cachetagscache"/>

    <!-- debug -->   
    <property name="debug" value="true"/>

    <!-- import common osbuild.xml -->
    
    <property name="common.build" value="../opensymphony/common/osbuild.xml"/>
    <import file="${common.build}"/>
 
    <!-- TODO use property name="build.clover" value="${build}/clover" -->
    <property name="clover.initstring" location="${build.test}/testcoverage.db"/>
    
    <!-- project properties -->

    <property name="src.webapp" value="${src}/webapp"/> <!-- new -->

    <!-- init -->
    
    <target name="init" depends="ivy-check,common.init">
        <taskdef name="ivy-configure" classname="fr.jayasoft.ivy.ant.IvyConfigure"/>
        <taskdef name="ivy-resolve" classname="fr.jayasoft.ivy.ant.IvyResolve"/>
        <taskdef name="ivy-retrieve" classname="fr.jayasoft.ivy.ant.IvyRetrieve"/>
        <taskdef name="ivy-publish" classname="fr.jayasoft.ivy.ant.IvyPublish"/>
        <taskdef name="ivy-report" classname="fr.jayasoft.ivy.ant.IvyReport"/>
        <taskdef name="ivy-deliver" classname="fr.jayasoft.ivy.ant.IvyDeliver"/>

        <ivy-retrieve/>
    </target>
 
    <!-- Ivy -->   
    
    <target name="ivyrep.copy-ivy" depends="init">
        <ivy-deliver deliverpattern="${ivyrep.path}/opensymphony/${name}/[artifact]-[revision].[ext]"
                     pubrevision="${version}-${TIME}" pubdate="${TIME}"/>
    </target>

    <available property="ivy.available" classname="fr.jayasoft.ivy.ant.IvyRetrieve"/>
   
    <target name="ivy-check" unless="ivy.available">
        <fail message="Please download Ivy at http://www.jayasoft.org/ivy and copy ivy.jar to ${ant.home}${file.separator}lib"/>
    </target>
   
    <!-- Prepares the build directory -->
    <target name="prepare" depends="init">
        <mkdir dir="${build.java}/META-INF"/>
        <copy file="${src}/etc/${name}.tld" tofile="${build.java}/META-INF/taglib.tld"/>
    </target>


    <!-- Compiles the core source code -->
    <target name="compile" depends="prepare">
        <javac srcdir="${src.java}" destdir="${build.java}" includes="com/opensymphony/oscache/**" debug="${debug}" classpathref="cp"/>
    </target>


    <!-- Prepares and compiles the web application, which includes the web test suite -->
    <target name="example-war" depends="jar">
        <mkdir dir="${build}/webapp"/>
        <mkdir dir="${dist}"/>

        <javac srcdir="${src.webapp}/WEB-INF/classes" destdir="${build}/webapp" includes="com/opensymphony/oscache/**" debug="${debug}" classpath="${build.java}" classpathref="cp"/>

        <war destfile="${dist}/${name}-example.war" basedir="${src.webapp}" webxml="${src.webapp}/WEB-INF/web.xml" excludes="WEB-INF/web.xml">
            <lib file="${build}/${name}-${version}.jar"/>
            <lib file="${lib}/commons-collections.jar"/>
            <lib file="${lib}/commons-logging.jar"/>
            <classes dir="${build}/webapp"/>
        </war>
    </target>


    <!-- Build a usable jar file -->
    <target name="jar" depends="compile">
        <mkdir dir="${build}"/>

        <jar jarfile="${build}/${name}-${version}.jar" basedir="${build.java}" excludes="${jar.excludes}">
            <manifest>
                <attribute name="Implementation-Title" value="${fullname}"/>
                <attribute name="Implementation-Version" value="${version}"/>
                <attribute name="Implementation-Vendor" value="OpenSymphony"/>
            </manifest>
        </jar>
    </target>

    <!-- Run the unit tests. This is used by the test target, so do not call directly -->
    <target name="test-base">
        <taskdef name="junit" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"/>

        <!-- Clear out any previous persistent cache directory -->
        <delete dir="${test.cache.path}" failonerror="false"/>

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

            <formatter type="xml"/>

            <batchtest todir="${dist.docs}/junit">
                <fileset dir="${build.test}">
                    <include name="**/TestComplete*.class"/>
                    <exclude name="**/web/*.*"/>
                    <exclude name="**/clustersupport/*.*"/>
                </fileset>
            </batchtest>
        </junit>
    </target>

    <target name="test-cluster" if="test.cluster">
        <taskdef name="junit" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"/>

        <!-- Clear out any previous persistent cache directory -->
        <delete dir="${test.cache.path}" failonerror="false"/>

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

            <formatter type="xml"/>

            <batchtest todir="${dist.docs}/junit">
                <fileset dir="${build.test}">
                    <include name="**/TestCompleteCluster.class"/>
                </fileset>
            </batchtest>
        </junit>
    </target>

    <target name="test-web" if="test.web.baseURL">
        <mkdir dir="${dist.docs}/junit"/>
        <mkdir dir="${build.test}"/>

        <!-- Clear out any previous persistent cache directory -->
        <delete dir="${test.cache.path}"/>

        <javac srcdir="${src.test}" destdir="${build.test}" includes="com/opensymphony/oscache/web/**" debug="${debug}" classpath="${build}" classpathref="cp"/>

        <java classname="com.opensymphony.oscache.web.CheckDeployment" failonerror="true" classpath="${build.test}" fork="yes">
            <arg value="${test.web.baseURL}"/>
        </java>

        <taskdef name="junit" classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask"/>

        <junit printsummary="yes" haltonfailure="no" haltonerror="yes" fork="yes">
            <sysproperty key="test.web.baseURL" value="${test.web.baseURL}"/>
            <classpath>
                <pathelement location="${build.test}"/>
                <pathelement location="${build}"/>
                <path refid="cp"/>
            </classpath>

            <formatter type="xml"/>
            <formatter type="plain" useFile="false"/>
            <batchtest todir="${dist.docs}/junit">
                <fileset dir="${build.test}">
                    <include name="**/web/TestComplete*.class"/>
                    <include name="**/web/TestLoadComplete*.class"/>
                </fileset>
            </batchtest>
        </junit>
    </target>


    <!-- Run JUnit tests using different combinations of disk and memory caching -->
    <target name="test" depends="init, compile, example-war, clover-check, junit-check">
        <mkdir dir="${dist.docs}/junit"/>
        <mkdir dir="${dist.docs}/clover"/>
        <mkdir dir="${build.test}"/>

        <taskdef resource="clovertasks"/>
        <javac destdir="${build.test}" debug="${debug}" classpathref="cp" compiler="org.apache.tools.ant.taskdefs.CloverCompilerAdapter">
            <src path="${src.java}"/>
        </javac>
        <javac destdir="${build.test}" debug="${debug}" classpathref="cp">
            <src path="${src.test}"/>
        </javac>
        
        <!-- Run tests using Memory Cache Only -->
        <copy file="${src.test}/oscacheMemoryOnly.properties" tofile="${build.test}/oscache.properties" overwrite="yes"/>
        <echo message="Running tests with memory cache only" level="info"/>
        <antcall target="test-base"/>
        <antcall target="test-web"/>

        <!-- Rerun tests using Disk Cache Only -->
        <copy file="${src.test}/oscacheDiskOnly.properties" tofile="${build.test}/oscache.properties" overwrite="yes"/>
        <echo message="Running tests with disk cache only" level="info"/>
        <antcall target="test-base"/>
        <antcall target="test-web"/>

        <!-- ReRun tests using Disk and Memory Cache -->
        <copy file="${src.test}/oscacheDiskAndMemory.properties" tofile="${build.test}/oscache.properties" overwrite="yes"/>
        <echo message="Running tests with disk and memory caches" level="info"/>
        <antcall target="test-base"/>
        <antcall target="test-web"/>
    
        <!-- ReRun tests using Memory and Disk Overflow Cache -->   
        <copy file="${src.test}/oscacheMemoryAndOverflowToDisk.properties" tofile="${build.test}/oscache.properties" overwrite="yes"/>
        <echo message="Running tests with memory and disk overflow caches" level="info"/>
        <antcall target="test-base"/>
        <antcall target="test-web"/>
            
        <!-- Run clustering tests -->
        <echo message="Running tests with memory caches and clustering" level="info"/>
        <antcall target="test-cluster"/>

        <delete dir="${test.cache.path}"/>
    </target>

    <!-- Create the distribution zip files -->
    <target name="dist" depends="clean, jar, docs, example-war, clover.report, junit.report">
        <!-- copy the standard file -->
        <copy file="${build}/${name}-${version}.jar" tofile="${dist}/${name}-${version}.jar"/>
   
        <!-- create the full package -->
        <mkdir dir="${tmp.dir}/docs"/>
        <mkdir dir="${tmp.dir}/src"/>
        <mkdir dir="${tmp.dir}/lib"/>
        <mkdir dir="${tmp.dir}/etc"/>

        <copy todir="${tmp.dir}/docs">
            <fileset dir="${dist.docs}"/>
        </copy>
        <copy todir="${tmp.dir}/src">
            <fileset dir="${src}" excludes="etc/**"/>
        </copy>
        
        <copy file="${lib}/commons-collections.jar" todir="${tmp.dir}/lib"/>
        <copy file="${lib}/commons-logging.jar" todir="${tmp.dir}/lib"/>
        <copy file="${lib}/jgroups-all.jar" todir="${tmp.dir}/lib"/>

        <copy file="${build}/${name}-${version}.jar" todir="${tmp.dir}"/>
        
        <copy file="${src}/etc/oscache.properties" tofile="${tmp.dir}/etc/oscache.properties"/>
        <copy file="${src}/etc/${name}.tld" tofile="${tmp.dir}/etc/${name}.tld"/>
        <copy file="readme.txt" tofile="${tmp.dir}/readme.txt" failonerror="false"/>

        <zip zipfile="${dist}/${name}-${version}-full.zip" basedir="${tmp.dir}" includes="**"/>

        <!-- Remove everything that's not in the binary release -->
        <delete dir="${tmp.dir}/src"/>
        <delete dir="${tmp.dir}/${lib.build}"/>
        <delete dir="${tmp.dir}/docs/junit"/>
        <delete dir="${tmp.dir}/docs/clover"/>
        <delete file="${tmp.lib}/jgroups-all.jar"/>

        <zip zipfile="${dist}/${name}-${version}-binary.zip" basedir="${tmp.dir}" includes="**"/>

        <delete dir="${tmp.dir}"/>
    </target>

    <target name="clover.report" depends="test">
        <clover-report>
            <current outfile="${dist.docs}/clover">
                <fileset dir="${src.java}" excludes="**/Test*"/>
                <format type="html"/>
            </current>
        </clover-report>
    </target>

    <target name="junit.report" depends="test">
        <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="reports" depends="common.reports">
        <mkdir dir="${dist.docs}/dependencies"/>
        <ivy-report todir="${dist.docs}/dependencies" graph="false"/>
    </target>
    
</project>