blob: cf0155463be310d9539022d79ebb3e5ae61ef4d9 [file] [log] [blame]
<?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.*">
<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>