Build script from apache dbutils : Big Project Ant Script « Ant « Java






Build script from apache dbutils



<?xml version="1.0" encoding="UTF-8"?>
<!-- 
  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 default="dist"
       name="DdlUtils"
       basedir=".">
  <!-- Allow values set at the commandline or in the environment to override the defaults -->
  <property environment="env"/>
  <!-- Load the build properties -->
  <property file="build.properties"/>

  <!-- The classpath used for compiling and generating the documentation -->
  <path id="compilation-classpath">
    <fileset dir="${lib.dir}">
        <include name="**/*.jar"/>
        <include name="**/*.zip"/>
    </fileset>
    <pathelement path="${build.java.dir}"/>
    <pathelement path="${build.test.dir}"/>
  </path>

  <target name="init"
          description="Initializes the build process">
      <tstamp/>
      <mkdir dir="${build.dir}"/>
      <mkdir dir="${build.java.dir}"/>
      <mkdir dir="${dist.dir}"/>
  </target>

  <target name="compile"
          description="Compiles the code"
          depends="init">
    <javac srcdir="${src.java.dir}"
           destdir="${build.java.dir}"
           deprecation="true"
           debug="true"
           source="1.2"
           target="1.2"
           optimize="false">
      <classpath refid="compilation-classpath"/>
    </javac>
    <copy todir="${build.java.dir}">
      <fileset dir="${src.java.dir}"
               excludes="**/*.java,**/*.html"/>
    </copy>
  </target>

  <target name="jar"
          description="Creates the jar"
          depends="compile">
    <copy todir="${build.java.dir}">
      <fileset dir="${src.java.dir}"
               excludes="**/*.java"/>
    </copy>
    <mkdir dir="${build.java.dir}/META-INF"/>
    <copy todir="${build.java.dir}/META-INF"
          file="${basedir}/LICENSE.txt"/>
    <jar jarfile="${dist.dir}/${dist.filename.prefix}.jar"
         basedir="${build.java.dir}"
         excludes="**/package.html">
      <manifest>
        <attribute name="Built-By" value="${java.version} (${java.vendor})"/>
        <attribute name="Package" value="org.apache.ddlutils"/>
        <attribute name="Extension-Name" value="ddlutils"/>
        <attribute name="Specification-Version" value="${dist.version}"/>
        <attribute name="Specification-Vendor" value="${dist.vendor}"/>
        <attribute name="Specification-Title" value="${dist.name}"/>
        <attribute name="Implementation-Version" value="${dist.version}"/>
        <attribute name="Implementation-Vendor" value="${dist.vendor}"/>
      </manifest>
    </jar>
  </target>

  <target name="clean"
          description="Cleans up the generated directories">
    <delete failonerror="false"
            dir="${build.dir}"/>
    <delete failonerror="false"
            dir="${dist.dir}"/>
  </target>

  <!-- ----------------------------------------------------------------== -->
  <!-- Build the documentation                                            -->
  <!-- ----------------------------------------------------------------== -->
  <target name="doc"
          description="Builds the complete documentation">
    <fail message="Please set the FORREST_HOME environment variable to the 'src/core' subdirectory of your Forrest installation. If you don't have yet installed Forrest, you can get it from http://forrest.apache.org.">
      <condition>
        <not>
          <isset property="env.FORREST_HOME"/>
        </not>
      </condition>
    </fail>
    <available classname="org.apache.xml.resolver.Resolver" property="commons.resolver.available"/>
    <fail unless="commons.resolver.available" message="Please make the Apache XML Commons Resolver library available in the classpath, e.g. by copying the xml-commons-resolver jar file from the 'tools/ant/lib' subdirectory of your Forrest installation (${env.FORREST_HOME}/tools/ant/lib) into the lib subdirectory of your Ant installation (${env.ANT_HOME}/lib)."/>

    <delete dir="${build.doc.dir}"
          failonerror="false"/>
    <mkdir dir="${build.doc.dir}"/>

    <!-- Copy all forrest src stuff to a temporary directoy -->
    <copy todir="${build.doc.dir}">
      <fileset dir="${src.doc.dir}"/>
    </copy>

    <!-- Copy generated javadoc into the forrest structure in the temporary directory -->
    <antcall target="javadoc"/>
    <copy todir="${forrest.javadoc.destdir}">
      <fileset dir="${build.javadoc.dir}"/>
    </copy>
    <!-- Copy generated schema doc into the forrest structure in the temporary directory -->
    <antcall target="schemadoc"/>
    <copy todir="${forrest.schemadoc.destdir}">
      <fileset dir="${build.schemadoc.dir}"/>
    </copy>
    <!-- Copy generated ant doc into the forrest structure in the temporary directory -->
    <antcall target="antdoc"/>
    <copy todir="${forrest.antdoc.destdir}">
      <fileset dir="${build.antdoc.dir}"/>
    </copy>

    <ant antfile="${env.FORREST_HOME}/main/forrest.build.xml"
         dir="${build.doc.dir}"
         inheritall="false"
         target="site">
      <property name="forrest.home" value="${env.FORREST_HOME}"/>
    </ant>
    <!-- Finally we can copy the generated documentation to its designated place -->
    <mkdir dir="${doc.dir}"/>
    <copy todir="${doc.dir}">
      <fileset dir="${forrest.output.dir}"/>
    </copy>
  </target>

  <target name="-docbook">
    <mkdir dir="${build.doc.dir}"/>
    <copy todir="${build.doc.dir}">
      <fileset dir="../velocity-docbook/"/>
    </copy>
    <mkdir dir="${build.doc.dir}/src/docbook/ddlutils"/>
    <copy file="${src.doc.dir}/manual.xml" todir="${build.doc.dir}/src/docbook/ddlutils"/>
    <ant antfile="build-docbook.xml" target="all" inheritall="false" dir="${build.doc.dir}">
      <property name="docbook.dir" value="ddlutils"/>
      <property name="docbook.file" value="manual"/>
    </ant>
  </target>

  <!-- ----------------------------------------------------------------== -->
  <!-- Build the API JavaDocs                                             -->
  <!-- ----------------------------------------------------------------== -->
  <target name="javadoc"
          depends="init"
          description="Builds the API javadocs.">
    <mkdir dir="${build.javadoc.dir}"/>
    <javadoc sourcepath="${src.java.dir}"
             classpathref="compilation-classpath"
             destdir="${build.javadoc.dir}"
             doctitle="${javadoc.title}"
             windowtitle="${javadoc.title}"
             bottom="${javadoc.footer}"
             protected="true"
             author="false"
             version="true"
             packagenames="org.*">
      <tag name="ant.type" scope="types" description="Marks an ant type"/>
      <tag name="ant.task" scope="types" description="Marks an ant task"/>
      <tag name="ant.required" scope="methods" description="Marks a required task property"/>
      <tag name="ant.not-required" scope="methods" description="Marks an optional task property"/>
      <link href="http://java.sun.com/j2se/1.4.2/docs/api/"/> 
      <link href="http://jakarta.apache.org/commons/lang/apidocs/"/>
      <link href="http://jakarta.apache.org/commons/beanutils/apidocs/"/>
      <link href="http://jakarta.apache.org/commons/digester/apidocs/"/>
      <link href="http://jakarta.apache.org/commons/betwixt/apidocs/"/>
    </javadoc> 
  </target>

  <!-- ----------------------------------------------------------------== -->
  <!-- Builds the documentation for the database XML schema format        -->
  <!-- ----------------------------------------------------------------== -->
  <target name="schemadoc"
          description="Builds the documentation for the database XML schema format">
    <available classname="DTDDoc.DTDDocTask"
               classpathref="compilation-classpath"
               property="dtddoc.available"/>
    <fail unless="dtddoc.available" message="For building the XML Schema documentaion, you'll need DTDDoc which can be downloaded from http://sourceforge.net/projects/dtddoc. Please make the DTDDoc and dtdparser jars available in the classpath."/>
    <taskdef name="dtddoc"
             classname="DTDDoc.DTDDocTask"
             classpathref="compilation-classpath"/>

    <mkdir dir="${build.schemadoc.dir}"/>
    <dtddoc destdir="${build.schemadoc.dir}" sourcedir="${src.java.dir}" includes="*.dtd"/>
  </target>

  <!-- ----------------------------------------------------------------== -->
  <!-- Builds the documentation for the Ant tasks                         -->
  <!-- ----------------------------------------------------------------== -->
  <target name="antdoc"
          description="Builds the documentation for the Ant tasks">
    <available classname="com.neuroning.antdoclet.AntDoclet"
               classpathref="compilation-classpath"
               property="antdoc.available"/>
    <fail unless="antdoc.available" message="For building the Ant task documentaion, you'll need AntDoc which can be downloaded from http://antdoclet.neuroning.com/. Please make the AntDoc libraries available in the classpath."/>
    <mkdir dir="${build.antdoc.dir}"/>
    <javadoc sourcepath="${src.java.dir}"
             classpathref="compilation-classpath"
             destdir="${build.antdoc.dir}"
             doctitle="${antdoc.title}"
             protected="true"
             author="false"
             version="true"
             packagenames="org.apache.ddlutils.task">
      <doclet name="com.neuroning.antdoclet.AntDoclet"
              pathref="compilation-classpath">
        <param name="-templatesdir" value="${antdoc.templates.dir}"/>
        <param name="-templates" value="html/main.vm" />
      </doclet>
    </javadoc>
    <copy todir="${build.antdoc.dir}">
      <fileset dir="${src.antdoc.dir}" includes="*.css,*.js"/>
      <fileset dir="${antdoc.templates.dir}/html" includes="*.htm*"/>
    </copy>
  </target>

  <!-- ----------------------------------------------------------------== -->
  <!-- Checks the docs for broken links                                   -->
  <!-- ----------------------------------------------------------------== -->
  <target name="check-doc"
          description="Checks the doc for broken links using linklint">
    <echo>Running linklint on ${build.doc.dir}. The output can be found in linklint.log.</echo>
    <exec executable="linklint">
      <arg line="-quiet"/>
      <arg line="-net"/>
      <arg line="-error"/>
      <arg line="-warn"/>
      <arg line="-out"/>
      <arg line="linklint.log"/>
      <arg line="-root"/>
      <arg line="${forrest.output.dir}"/>
      <arg line="/@"/>
    </exec>
  </target>

  <!-- ----------------------------------------------------------------== -->
  <!-- Build the doc archive                                              -->
  <!-- ----------------------------------------------------------------== -->
  <target name="doc-archive" depends="doc"
          description="Builds the complete documentation archive.">
    <zip zipfile="${dist.dir}/${dist.doc.filename.prefix}.zip"
         basedir="."
         includes="${dist.doc.includes}"/>
  </target>

  <!-- ----------------------------------------------------------------== -->
  <!-- Build the src archive                                              -->
  <!-- ----------------------------------------------------------------== -->
  <target name="src-archive" depends="doc"
          description="Builds the source distribution archive.">
    <zip zipfile="${dist.dir}/${dist.src.filename.prefix}.zip"
         basedir="."
         includes="${dist.src.includes}"
         excludes="${dist.src.excludes}"/>
  </target>


  <!-- ----------------------------------------------------------------== -->
  <!-- Build the bin archive                                              -->
  <!-- ----------------------------------------------------------------== -->
  <target name="bin-archive" depends="jar,doc"
          description="Builds the binary distribution archive.">
    <zip zipfile="${dist.dir}/${dist.bin.filename.prefix}.zip"
         basedir="."
         includes="${dist.bin.includes}"
         excludes="${dist.bin.excludes}"/>
  </target>

  <!-- ----------------------------------------------------------------== -->
  <!-- Creates the DdlUtils distribution                                  -->
  <!-- ----------------------------------------------------------------== -->
  <target name="dist"
          description="Creates the distribution"
          depends="jar, doc-archive, src-archive, bin-archive"/>

  <target name="compile-tests"
          description="Compiles the unit tests"
          depends="compile">
    <mkdir dir="${build.test.dir}"/>
    <javac srcdir="${src.test.dir}"
           destdir="${build.test.dir}"
           deprecation="true"
         debug="true"
         source="1.2"
         target="1.2"
         optimize="false">
      <classpath refid="compilation-classpath"/>
    </javac>
  </target>

  <!-- ----------------------------------------------------------------== -->
  <!-- Can be used to create the testdatabase if the platform supports it -->
  <!-- ----------------------------------------------------------------== -->
  <target name="create-test-database"
          description="Can be used to create the testdatabase if the platform supports it">
    <property file="${jdbc.properties.file}"/> 

    <taskdef name="ddl2Database"
             classname="org.apache.ddlutils.task.DdlToDatabaseTask"
             classpathref="compilation-classpath"/>
    <ddl2Database>
      <database driverclassname="${datasource.driverClassName}"
                url="${datasource.url}"
                username="${datasource.username}"
                password="${datasource.password}"/> 
      <createdatabase failonerror="true"/>
    </ddl2Database>
  </target> 

  <!-- ----------------------------------------------------------------== -->
  <!-- Runs the test cases                                                -->
  <!-- ----------------------------------------------------------------== -->
  <target name="junit"
          description="Runs the test cases against no database or the one specified via -Djdbc.properties.file">
    <antcall target="-junit-internal"/>
  </target>

  <!-- ----------------------------------------------------------------== -->
  <!-- Runs the test cases against AxionDB                                -->
  <!-- ----------------------------------------------------------------== -->
  <target name="junit-axion"
          description="Runs the test cases against Axion">
    <property name="jdbc.properties.file" value="/jdbc.properties.axion"/>
    <antcall target="-junit-internal"/>
  </target>

  <!-- ----------------------------------------------------------------== -->
  <!-- Runs the test cases against Derby                                  -->
  <!-- ----------------------------------------------------------------== -->
  <target name="junit-derby"
          description="Runs the test cases against Derby">
    <property name="jdbc.properties.file" value="/jdbc.properties.derby"/>
    <antcall target="-junit-internal"/>
  </target>

  <!-- ----------------------------------------------------------------== -->
  <!-- Runs the test cases against HsqlDb                                 -->
  <!-- ----------------------------------------------------------------== -->
  <target name="junit-hsqldb"
          description="Runs the test cases against Hsqldb">
    <property name="jdbc.properties.file" value="/jdbc.properties.hsqldb"/>
    <antcall target="-junit-internal"/>
  </target>

  <!-- ----------------------------------------------------------------== -->
  <!-- Runs the test cases against MySQL                                -->
  <!-- ----------------------------------------------------------------== -->
  <target name="junit-mysql"
          description="Runs the test cases against MySql">
    <property name="jdbc.properties.file" value="/jdbc.properties.mysql"/>
    <antcall target="-junit-internal"/>
  </target>

  <!-- ----------------------------------------------------------------== -->
  <!-- Runs the test cases against PostgreSQL                             -->
  <!-- ----------------------------------------------------------------== -->
  <target name="junit-postgresql"
          description="Runs the test cases against PostgreSQL">
    <property name="jdbc.properties.file" value="/jdbc.properties.postgresql"/>
    <antcall target="-junit-internal"/>
  </target>

  <target name="-junit-internal"
          depends="compile-tests">
    <junit dir="."
           printSummary="yes"
           fork="true"
           haltonerror="false">
      <sysproperty key="jdbc.properties.file" value="${jdbc.properties.file}"/> 
      <formatter type="xml"/>
      <formatter type="plain"/>
      <classpath refid="compilation-classpath"/>
      <batchtest todir="${build.test.dir}">
          <fileset dir="${src.test.dir}" includes="**/Test*.java">
          <exclude name="**/Test*Base.java"/>
            <exclude name="**/TestPlatform.java"/>
            <exclude name="**/TestSummaryCreatorTask.java"/>
          </fileset>
      </batchtest>
    </junit>
  </target>

  <!-- ----------------------------------------------------------------== -->
  <!-- Creates the test report                                            -->
  <!-- ----------------------------------------------------------------== -->
  <target name="junit-report"
          description="Creates a test report in html form">
    <junitreport todir="${build.test.dir}">
      <fileset dir="${build.test.dir}" casesensitive="false">
          <include name="test*.xml"/>
      </fileset>
      <report format="frames"
              todir="${build.test.dir}"/>
    </junitreport>
  </target>

  <!-- ----------------------------------------------------------------== -->
  <!-- Creates the test summary                                           -->
  <!-- ----------------------------------------------------------------== -->
  <target name="junit-summary"
          depends="compile-tests"
          description="Creates a test summary">
    <taskdef name="testSummary"
             classname="org.apache.ddlutils.TestSummaryCreatorTask"
             classpathref="compilation-classpath"/>
    <testSummary version="${dist.version}"
                 outputfile="${build.test.dir}/summary.xml">
      <fileset dir="${build.test.dir}"
               casesensitive="false">
          <include name="test*.xml"/>
      </fileset>
    </testSummary>
    <property name="test.summary.stylesheet" value="${test.summary.dir}/moinmoin.xsl"/>
    <style in="${build.test.dir}/summary.xml"
           style="${test.summary.stylesheet}"
           out="${build.test.dir}/summary.txt"/>
  </target>

  <!-- ----------------------------------------------------------------== -->
  <!-- Runs Checkstyle over DdlUtils                                      -->
  <!-- ----------------------------------------------------------------== -->
  <target name="checkstyle"
          description="Checks the sourcecode via Checkstyle">
    <fail message="Due to licensing issues, DdlUtils is not distributed with Checkstyle. If you want to use this task, then please put the checkstyle jar into the lib subdirectory.">
      <condition>
        <not>
          <available classpathref="compilation-classpath"
                     resource="checkstyletask.properties"/>
        </not>
      </condition>
    </fail>

    <taskdef resource="checkstyletask.properties"
             classpathref="compilation-classpath"/>

    <checkstyle config="${src.check.dir}/ddlutils-checks.xml"
                failOnViolation="false">
      <fileset dir="${src.java.dir}"
               includes="**/*.java"/>
      <fileset dir="${src.test.dir}"
               includes="**/*.java"/>

      <formatter type="plain" usefile="false"/>
      <!-- Location of cache-file (project specific) -->
      <property key="checkstyle.cache.file" file="${build.check.dir}/checkstyle/cachefile"/>
    </checkstyle>
  </target>
</project>







//File: build.properties

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

lib.dir=lib

src.dir=src
src.java.dir=${src.dir}/main/java
src.test.dir=${src.dir}/test/java
src.resources.dir=${src.dir}/main/resources
src.doc.dir=${src.dir}/main/doc
src.antdoc.dir=${src.dir}/main/antdoc
src.check.dir=${src.dir}/main/checkstyle

build.dir=target
build.java.dir=${build.dir}/classes
build.test.dir=${build.dir}/test
build.antdoc.dir=${build.dir}/antdoc
build.javadoc.dir=${build.dir}/javadoc
build.schemadoc.dir=${build.dir}/schemadoc
build.doc.dir=${build.dir}/doc
build.check.dir=${build.dir}/checkstyle

dist.dir=dist
doc.dir=doc

dist.name=DdlUtils
dist.vendor=Apache Software Foundation
dist.version=1.0
dist.filename.prefix=${dist.name}-${dist.version}
dist.doc.filename.prefix=${dist.name}-${dist.version}-doc
dist.doc.includes=doc/**
dist.src.filename.prefix=${dist.name}-${dist.version}-src
dist.src.includes=.classpath,.project,build*.*,dump-metadata.xml,*.txt,pom.xml,src/**,lib/*,lib/build-only/ant-*.jar,lib/build-only/junit*.jar,doc/**
dist.src.excludes=lib/drivers/**,lib/driver-alternatives/**
dist.bin.filename.prefix=${dist.name}-${dist.version}-bin
dist.bin.includes=dump-metadata.xml,*.txt,pom.xml,dist/${dist.filename.prefix}.jar,lib/*,doc/**
dist.bin.excludes=lib/build-only/**,lib/drivers/**,lib/driver-alternatives/**

checkstyle.version.pattern=\\$Revision.*\\$
checkstyle.author.pattern=\\S
checkstyle.header.file=${src.check.dir}/license-check.txt

test.profile.dir=${src.dir}/test-profiles
test.summary.dir=${src.dir}/test-summary

#
# Documentation properties
#

javadoc.title=${dist.name} ${dist.version} API Documentation
javadoc.footer=Copyright &copy; 2005-2007 Apache Software Foundation. All Rights Reserved.

antdoc.title=${dist.name} ${dist.version} Ant Tasks
antdoc.templates.dir=${src.antdoc.dir}/templates

forrest.antdoc.destdir=${build.doc.dir}/src/documentation/content/ant
forrest.javadoc.destdir=${build.doc.dir}/src/documentation/content/api
forrest.schemadoc.destdir=${build.doc.dir}/src/documentation/content/schema
forrest.output.dir=${build.doc.dir}/build/site

 








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.Build script for apache-cassandra-0.5.1-src
21.apache-log4j-site\build.xml
22.apache-roller-src-4.0.1
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