Build script for apache-cassandra-0.5.1-src : Big Project Ant Script « Ant « Java






Build script for apache-cassandra-0.5.1-src



<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!--
 ~ Licensed to the Apache Software Foundation (ASF) under one
 ~ or more contributor license agreements.  See the NOTICE file
 ~ distributed with this work for additional information
 ~ regarding copyright ownership.  The ASF licenses this file
 ~ to you under the Apache License, Version 2.0 (the
 ~ "License"); you may not use this file except in compliance
 ~ with the License.  You may obtain a copy of the License at
 ~
 ~    http://www.apache.org/licenses/LICENSE-2.0
 ~
 ~ Unless required by applicable law or agreed to in writing,
 ~ software distributed under the License is distributed on an
 ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 ~ KIND, either express or implied.  See the License for the
 ~ specific language governing permissions and limitations
 ~ under the License.
 -->
<project basedir="." default="build" name="apache-cassandra">
    <property environment="env"/>
    <property file="build.properties" />
    <property name="debuglevel" value="source,lines,vars"/>

    <property name="basedir" value="."/>
    <property name="build.src" value="${basedir}/src/java"/>
    <property name="build.src.gen-java" value="${basedir}/src/gen-java"/>
    <property name="build.lib" value="${basedir}/lib"/>
    <property name="build.dir" value="${basedir}/build"/>
    <property name="build.test.dir" value="${build.dir}/test"/>
    <property name="build.classes" value="${build.dir}/classes"/>
    <property name="javadoc.dir" value="${build.dir}/javadoc"/>
    <property name="interface.dir" value="${basedir}/interface"/>
    <property name="interface.src.dir" value="${interface.dir}/gen-java"/>
    <property name="test.dir" value="${basedir}/test"/>
    <property name="test.resources" value="${test.dir}/resources"/>
    <property name="test.classes" value="${build.dir}/test/classes"/>
    <property name="test.conf" value="${test.dir}/conf"/>
    <property name="test.name" value="*Test"/>
    <property name="test.unit.src" value="${test.dir}/unit"/>
    <property name="dist.dir" value="${build.dir}/dist"/>
    <property name="version" value="0.5.1"/>
    <property name="final.name" value="${ant.project.name}-${version}"/>

    <!-- http://cobertura.sourceforge.net/ -->
    <property name="cobertura.build.dir" value="${build.dir}/cobertura"/>
    <!-- can't include due to licensing, specify jar via command line -->
    <property name="cobertura.dir" value="/tmp"/>
    <property name="cobertura.report.dir" value="${cobertura.build.dir}/report"/>
    <property name="cobertura.classes.dir" value="${cobertura.build.dir}/classes"/>
    <property name="cobertura.datafile" value="${cobertura.build.dir}/cobertura.ser"/>
  
    <!-- 
   Add all the dependencies.
    -->
    <path id="cassandra.classpath">
        <pathelement location="${cobertura.classes.dir}"/>
        <pathelement location="${build.classes}"/>
        <fileset dir="${build.lib}">
          <include name="**/*.jar" />
        </fileset>
    </path>

    <!--
  Setup the output directories.
    -->
    <target name="init">
        <mkdir dir="${build.classes}"/>
        <mkdir dir="${test.classes}"/>
        <mkdir dir="${build.src.gen-java}"/>
    </target>

    <target name="clean">
        <delete dir="${build.dir}" />
        <delete dir="${build.src.gen-java}" />
    </target>
    <target depends="clean" name="cleanall"/>

    <!--
       This generates the CLI grammar files from Cli.g
    -->
    <target name="check-gen-cli-grammar">
        <uptodate property="cliUpToDate" 
                srcfile="${build.src}/org/apache/cassandra/cli/Cli.g" 
                targetfile="${build.src.gen-java}/org/apache/cassandra/cli/Cli.tokens"/>
    </target>
 
    <target name="gen-cli-grammar" depends="check-gen-cli-grammar" unless="cliUpToDate">
      <echo>Building Grammar ${build.src}/org/apache/cassandra/cli/Cli.g  ....</echo>
      <java classname="org.antlr.Tool"
            classpath="${build.lib}/antlr-3.1.3.jar"
            fork="true">
         <arg value="${build.src}/org/apache/cassandra/cli/Cli.g" />
         <arg value="-fo" />
         <arg value="${build.src.gen-java}/org/apache/cassandra/cli/" />
      </java> 
    </target>

    <target name="gen-thrift-java">
      <echo>Generating Thrift Java code from ${basedir}/interface/cassandra.thrift ....</echo>
      <exec executable="thrift" dir="${basedir}/interface">
        <arg line="--gen java cassandra.thrift" />
      </exec>
    </target>
    <target name="gen-thrift-py">
      <echo>Generating Thrift Python code from ${basedir}/interface/cassandra.thrift ....</echo>
      <exec executable="thrift" dir="${basedir}/interface">
        <arg line="--gen py cassandra.thrift" />
      </exec>
    </target>

    <!--
  The build target builds all the .class files
    -->
    <target name="build" depends="build-subprojects,build-project"/>
    <target name="build-subprojects"/>
    <target name="codecoverage" depends="cobertura-instrument,test,cobertura-report"/>
      
    <target depends="init,gen-cli-grammar" name="build-project">
        <echo message="${ant.project.name}: ${ant.file}"/>
        <javac debug="true" debuglevel="${debuglevel}" destdir="${build.classes}">
            <src path="${build.src}"/>
            <src path="${build.src.gen-java}"/>
            <src path="${interface.src.dir}"/>
            <classpath refid="cassandra.classpath"/>
        </javac>
    </target>

    <!--
  The jar target makes cassandra.jar output.
    -->
    <target name="jar" depends="build">
      <mkdir dir="${build.classes}/META-INF"/>
      <copy file="LICENSE.txt" tofile="${build.classes}/META-INF/LICENSE.txt"/>
      <copy file="NOTICE.txt" tofile="${build.classes}/META-INF/NOTICE.txt"/>
      <jar jarfile="${build.dir}/${final.name}.jar"
           basedir="${build.classes}">
        <manifest>
        <!-- <section name="org/apache/cassandra/infrastructure"> -->
          <attribute name="Implementation-Title" value="Cassandra"/>
          <attribute name="Implementation-Version" value="${version}"/>
          <attribute name="Implementation-Vendor" value="Apache"/>
          <attribute name="Premain-Class" value="org.apache.cassandra.infrastructure.continuations.CAgent"/>
        <!-- </section> -->
        </manifest>
      </jar>
    </target>

    <!-- creates a release tarball -->  
    <target name="release" depends="jar,javadoc">
      <mkdir dir="${dist.dir}"/>
      <copy todir="${dist.dir}/lib">
        <fileset dir="${build.lib}"/>
        <fileset dir="${build.dir}">
          <include name="*.jar" />
        </fileset>
      </copy>
      <copy todir="${dist.dir}/javadoc">
        <fileset dir="${javadoc.dir}"/>
      </copy>
      <copy todir="${dist.dir}/bin">
        <fileset dir="bin"/>
      </copy>
      <copy todir="${dist.dir}/conf">
        <fileset dir="conf"/>
      </copy>   
      <copy todir="${dist.dir}/interface">
        <fileset dir="interface">
          <include name="**/*.thrift" />
        </fileset>
      </copy>      
      <copy todir="${dist.dir}/">
        <fileset dir="${basedir}">
          <include name="*.txt" />
        </fileset>
      </copy> 
      
      <tar compression="gzip" longfile="gnu"
        destfile="${build.dir}/${final.name}-bin.tar.gz">

        <!-- Everything but bin/ (default mode) -->
        <tarfileset dir="${dist.dir}" prefix="${final.name}">
          <include name="**"/>
          <exclude name="bin/*" />
        </tarfileset>
        <!-- Shell includes in bin/ (default mode) -->
        <tarfileset dir="${dist.dir}" prefix="${final.name}">
          <include name="bin/*.in.sh" />
        </tarfileset>
        <!-- Executable scripts in bin/ -->
        <tarfileset dir="${dist.dir}" prefix="${final.name}" mode="755">
          <include name="bin/*"/>
          <not>
          <filename name="bin/*.in.sh" />
          </not>
        </tarfileset>  
      </tar>
      <tar compression="gzip" longfile="gnu"
        destfile="${build.dir}/${final.name}-src.tar.gz">

        <tarfileset dir="${basedir}"
          prefix="${final.name}-src">
          <include name="**"/>
          <exclude name="build/**" />
          <exclude name="src/gen-java/**" />
        </tarfileset>
      </tar>
    </target>

  <target name="build-test" depends="build" description="Build the Cassandra classes">
    <javac
     debug="true"
     debuglevel="${debuglevel}"
     destdir="${test.classes}"
    >
      <classpath refid="cassandra.classpath"/>
      <src path="${test.unit.src}"/>
    </javac>

    <!-- Non-java resources needed by the test suite -->    
    <copy todir="${test.classes}">
      <fileset dir="${test.resources}"/>
    </copy>
  </target>

   <target name="test" depends="build-test">
    <echo message="running tests"/>
    <mkdir dir="${build.test.dir}/cassandra"/>
    <mkdir dir="${build.test.dir}/output"/>
    <junit fork="on" failureproperty="testfailed">
      <sysproperty key="net.sourceforge.cobertura.datafile" file="${cobertura.datafile}"/>
      <formatter type="xml" usefile="true"/>
      <formatter type="brief" usefile="false"/>
      <jvmarg value="-Dstorage-config=${test.conf}"/>
      <jvmarg value="-ea"/>
      <classpath>
        <path refid="cassandra.classpath" />
        <pathelement location="${test.classes}"/>
        <pathelement location="${cobertura.dir}/cobertura.jar"/>
        <pathelement location="${test.conf}"/>
      </classpath>
      <batchtest todir="${build.test.dir}/output">
        <fileset dir="${test.classes}" includes="**/${test.name}.class" />
      </batchtest>
    </junit>

    <fail if="testfailed" message="Some test(s) failed."/>
  </target>
  
  <!-- instruments the classes to later create code coverage reports -->
  <target name="cobertura-instrument" depends="build,build-test">
    <taskdef resource="tasks.properties">
      <classpath>
        <fileset dir="${cobertura.dir}">
            <include name="cobertura.jar" />
            <include name="lib/**/*.jar" />
        </fileset>
      </classpath>
    </taskdef>
    
    <delete file="${cobertura.datafile}"/>
    
    <cobertura-instrument todir="${cobertura.classes.dir}" datafile="${cobertura.datafile}">
      <ignore regex="org.apache.log4j.*"/>
      
      <fileset dir="${build.classes}">
        <include name="**/*.class"/>
        <exclude name="**/*Test.class"/>
        <exclude name="**/*TestCase.class"/>
        <exclude name="**/test/*.class"/>
        <exclude name="${cobertura.excludes}"/>
      </fileset>
     
    </cobertura-instrument>
  </target>  

  <!-- create both html and xml code coverage reports -->
  <target name="cobertura-report">
    <cobertura-report format="html" destdir="${cobertura.report.dir}" srcdir="${build.src}"
      datafile="${cobertura.datafile}"/>
    <cobertura-report format="xml" destdir="${cobertura.report.dir}" srcdir="${build.src}"
      datafile="${cobertura.datafile}"/>
  </target>  
  
  <target name="javadoc" depends="init">
    <tstamp>
      <format property="YEAR" pattern="yyyy"/>
    </tstamp>
    <javadoc destdir="${javadoc.dir}" author="true" version="true" use="true"
      windowtitle="${ant.project.name} API" classpathref="cassandra.classpath"
      bottom="Copyright &amp;copy; ${YEAR} The Apache Software Foundation">

      <fileset dir="${build.src}" defaultexcludes="yes">
        <include name="org/apache/**/*.java"/>
      </fileset>
      <fileset dir="${interface.src.dir}" defaultexcludes="yes">
        <include name="org/apache/**/*.java"/>
      </fileset>
    </javadoc>
   </target>

</project>

 








Related examples in the same category

1.Ant script for xmlgraphics-commons
2.nutch ant script
3.rhino ant build script
4.apache solr ant script
5.Tomcat ant build script
6.OFBiz ant build script
7.Apache Lenya Build System
8.Apache pivot ant build script
9.XmlSchema ant script
10.xml security
11.velocity tools ant script
12.weka build script
13.xml bean ant script
14.xml graphics common ant script
15.uPortal ant script
16.SmartGWT ant script
17.Build file to fetch maven2 tasks; extracted from (Ant's) fetch.xml
18.Build file to fetch optional libraries for Apache Ant
19.Ant build script
20.apache-log4j-site\build.xml
21.apache-roller-src-4.0.1
22.Build script from apache dbutils
23.Fop build script
24.Google guice ant script
25.GWT ant script
26.hadoop ant build script
27.jakarta jmeter ant script
28.jakarta oro ant script
29.jakarta regexp ant script
30.jedit build script
31.jibx ant build script
32.lucene ant build script