198 lines
7.4 KiB
XML

<?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.
-->
<!-- ====================================================================== -->
<!-- -->
<!-- Ant build script for OpenBooks -->
<!-- -->
<!-- ====================================================================== -->
<project name="OpenBooks" default="info">
<property file="build.properties" />
<property name="jpa.provider" value="openjpa" />
<property name="src.dir" value="${basedir}/src/main/java"/>
<property name="rsrc.dir" value="${basedir}/src/main/resources"/>
<property name="msrc.dir" value="${basedir}/target/generated-sources/java"/>
<property name="classes.dir" value="${basedir}/target/classes"/>
<property name="deploy.dir" value="${basedir}/target/openbooks"/>
<property name="generated.html.dir" value="${basedir}/target/source"/>
<property name="jpa.properties" value="META-INF/persistence.xml#OpenBooks" />
<path id="compile.classpath" description="compilation requires OpenJPA specific library">
<pathelement location="${src.dir}" />
<pathelement location="${classes.dir}" />
<pathelement location="${rsrc.dir}" />
<fileset dir="${openjpa.lib}">
<include name="*.jar" />
</fileset>
</path>
<path id="java2html.classpath">
<pathelement location="${rsrc.dir}" />
<fileset dir="${java2html.lib}">
<include name="*.jar" />
</fileset>
</path>
<fileset id="canonical.metamodel" dir="${src.dir}"
description="Set of *.java files generated for static, cannonical domain model">
<include name="**/*_.java"/>
</fileset>
<target name="clean" description="Removes all *.class and generated metamodel source files">
<delete dir="${basedir}/target" failonerror="false"/>
<delete>
<fileset refid="canonical.metamodel"/>
</delete>
</target>
<target name="info" depends="check-env">
<echo>
Builds OpenBooks demo application.
OpenJPA Library: ${openjpa.lib}
</echo>
</target>
<target name="check-env" description="Checks if required libraries exist">
<available file="${openjpa.lib}" property="openjpa.exists"/>
<fail unless="openjpa.exists">*** Error:
The directory for OpenJPA libraries can not be located at ${openjpa.lib}.
Make sure openjpa.lib property value is correct in build.properties file.
</fail>
<available file="${java2html.lib}" property="java2html.exists"/>
<fail unless="java2html.exists">*** Error:
The directory for Java2HTML libraries can not be located at ${java2html.lib}.
Make sure java2html.lib property value is correct in build.properties file.
</fail>
</target>
<target name="build" depends="check-env,genmodel,compile,enhance"
description="Compilation will also generate canonical meta-model classes.">
</target>
<target name="genmodel" depends="check-env"
description="Generate canonical meta-model source">
<mkdir dir="${msrc.dir}" />
<mkdir dir="${classes.dir}" />
<javac srcdir="${src.dir}" destdir="${classes.dir}" debug="true">
<classpath refid="compile.classpath" />
<include name="openbook/domain/*.java"/>
<compilerarg value="-Aopenjpa.metamodel=true" />
<compilerarg value="-Aopenjpa.log=TRACE" />
<compilerarg value="-s"/>
<compilerarg value="${msrc.dir}" />
</javac>
</target>
<target name="compile" depends="genmodel"
description="Compile classes.">
<javac srcdir="${src.dir}" destdir="${classes.dir}" debug="true">
<classpath refid="compile.classpath" />
</javac>
</target>
<target name="enhance" depends="check-env"
description="Enhance classes.">
<java classname="org.apache.openjpa.enhance.PCEnhancer" fork="true">
<arg value="-properties" />
<arg value="${jpa.properties}" />
<classpath refid="compile.classpath" />
</java>
</target>
<target name="package" depends="clean,build,generate-html-source"
description="Generates HTML version of source code and creates distribution layout">
<delete file="${basedir}/target/openbooks.jar" failonerror="false"/>
<delete file="${basedir}/target/openbooks.zip" failonerror="false"/>
<jar destfile="${basedir}/target/openbooks.jar" basedir="${classes.dir}">
<exclude name="junit/**" />
</jar>
<jar destfile="${basedir}/target/openbooks.jar"
basedir="${rsrc.dir}"
update="true">
<include name="images/*" />
</jar>
<!-- ASF released jars must include License and Notice files -->
<jar destfile="${basedir}/target/openbooks.jar"
basedir="${basedir}"
update="true">
<include name="NOTICE.txt"/>
<include name="LICENSE.txt"/>
</jar>
<zip destfile="${basedir}/target/openbooks.zip" basedir="${basedir}">
<include name="run.properties" />
<include name="run.xml" />
<include name="index.html" />
<include name="NOTICE.txt"/>
<include name="LICENSE.txt"/>
</zip>
<zip destfile="${basedir}/target/openbooks.zip" basedir="${basedir}/target" update="true">
<include name="openbooks.jar" />
</zip>
<zip destfile="${basedir}/target/openbooks.zip" basedir="${rsrc.dir}" update="true">
<include name="load.properties" />
<include name="demo.properties" />
<include name="META-INF/persistence.xml" />
<include name="slides/**" />
</zip>
<zip destfile="${basedir}/target/openbooks.zip" basedir="${basedir}/target" update="true">
<include name="source/**" />
</zip>
</target>
<target name="deploy" description="Transfers the distribution packge to a deploy directory">
<delete dir="${deploy.dir}" failonerror="false"/>
<mkdir dir="${deploy.dir}"/>
<unzip dest="${deploy.dir}" src="${basedir}/target/openbooks.zip" overwrite="true">
</unzip>
</target>
<target name="generate-html-source"
description="Generates HTML Source Code using Java2HTML utility">
<delete dir="${generated.html.dir}" failonerror="false"/>
<mkdir dir="${generated.html.dir}"/>
<!-- Create HTML of svn source files -->
<java classname="de.java2html.Java2Html" fork="true">
<classpath refid="java2html.classpath"/>
<arg value="-srcdir"/>
<arg value="${src.dir}"/>
<arg value="-targetdir"/>
<arg value="${generated.html.dir}"/>
<arg value="-style"/>
<arg value="Eclipse"/>
</java>
<!-- Create HTML of meta-model generated source files -->
<java classname="de.java2html.Java2Html" fork="true">
<classpath refid="java2html.classpath"/>
<arg value="-srcdir"/>
<arg value="${msrc.dir}"/>
<arg value="-targetdir"/>
<arg value="${generated.html.dir}"/>
<arg value="-style"/>
<arg value="Eclipse"/>
</java>
<replace dir="${generated.html.dir}" token="10pt" value="14pt">
</replace>
</target>
</project>