2010-05-14 12:53:06 -04:00
|
|
|
<?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 -->
|
|
|
|
<!-- -->
|
|
|
|
<!-- ====================================================================== -->
|
|
|
|
|
2010-05-20 18:12:24 -04:00
|
|
|
<project name="OpenBooks" default="package">
|
2010-05-14 12:53:06 -04:00
|
|
|
|
2010-05-20 18:12:24 -04:00
|
|
|
<!-- ================================================================== -->
|
2010-05-14 16:29:27 -04:00
|
|
|
<property file="build.properties" />
|
2010-05-20 18:12:24 -04:00
|
|
|
<!-- ================================================================== -->
|
2010-05-14 12:53:06 -04:00
|
|
|
<property name="jpa.provider" value="openjpa" />
|
2010-05-20 18:12:24 -04:00
|
|
|
<!-- ================================================================== -->
|
|
|
|
<property name="build.mode" value="jse"/>
|
|
|
|
<!-- ================================================================== -->
|
|
|
|
<!-- root directory of Java Source files -->
|
2010-05-14 12:53:06 -04:00
|
|
|
<property name="src.dir" value="${basedir}/src/main/java"/>
|
2010-05-20 18:12:24 -04:00
|
|
|
<!-- ================================================================== -->
|
|
|
|
<!-- root directory of JSP and other web content files -->
|
|
|
|
<property name="web.dir" value="${basedir}/web"/>
|
|
|
|
<!-- ================================================================== -->
|
|
|
|
<!-- root directory of resource files e.g web.xml or persistence.xml -->
|
2010-05-14 12:53:06 -04:00
|
|
|
<property name="rsrc.dir" value="${basedir}/src/main/resources"/>
|
2010-05-20 18:12:24 -04:00
|
|
|
<!-- ================================================================== -->
|
|
|
|
<!-- JPA configuration file anchored by the persistence unit name -->
|
|
|
|
<property name="jpa.properties" value="META-INF/persistence.xml#OpenBooks"/>
|
|
|
|
<!-- ================================================================== -->
|
2010-05-25 17:12:08 -04:00
|
|
|
<!-- Application/Web Server type: -->
|
|
|
|
<!-- geronimo, was, tomcat, glassfish, or empty string for default -->
|
|
|
|
<property name="appserver" value=""/>
|
2010-05-20 18:12:24 -04:00
|
|
|
<!-- ================================================================== -->
|
|
|
|
<!-- Root directory of all derived artifacts -->
|
|
|
|
<property name="target.dir" value="${basedir}/target"/>
|
|
|
|
<!-- ================================================================== -->
|
|
|
|
<!-- root directory of compiled class files -->
|
|
|
|
<property name="classes.dir" value="${target.dir}/classes"/>
|
|
|
|
<!-- ================================================================== -->
|
|
|
|
<!-- root directory of generated canonical meta-model source files -->
|
2010-05-25 01:27:19 -04:00
|
|
|
<property name="generated.src.dir" value="${target.dir}/generated-metamodel/java"/>
|
2010-05-20 18:12:24 -04:00
|
|
|
<!-- ================================================================== -->
|
|
|
|
<!-- root directory of generated html for Java source files -->
|
2010-05-25 01:27:19 -04:00
|
|
|
<property name="generated.html.dir" value="${target.dir}/generated-html"/>
|
2010-05-20 18:12:24 -04:00
|
|
|
<!-- ================================================================== -->
|
|
|
|
<!-- directory for deployable artifacts -->
|
|
|
|
<property name="deploy.dir" value="${target.dir}/openbooks"/>
|
|
|
|
<!-- ================================================================== -->
|
2010-05-14 12:53:06 -04:00
|
|
|
|
2010-05-20 18:12:24 -04:00
|
|
|
<path id="compile.classpath"
|
|
|
|
description="Compilation classpath requires OpenJPA specific library because of bytecode enhancement">
|
2010-05-14 12:53:06 -04:00
|
|
|
<pathelement location="${src.dir}" />
|
|
|
|
<pathelement location="${classes.dir}" />
|
|
|
|
<pathelement location="${rsrc.dir}" />
|
|
|
|
<fileset dir="${openjpa.lib}">
|
|
|
|
<include name="*.jar" />
|
|
|
|
</fileset>
|
|
|
|
</path>
|
|
|
|
|
2010-05-25 01:27:19 -04:00
|
|
|
<path id="code.generation.classpath"
|
|
|
|
description="">
|
|
|
|
<pathelement location="${ant.home}/ant.jar" />
|
|
|
|
<pathelement location="${antlr.lib}" />
|
|
|
|
<pathelement location="${classes.dir}" />
|
|
|
|
</path>
|
|
|
|
|
|
|
|
|
2010-05-14 12:53:06 -04:00
|
|
|
<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">
|
2010-05-20 18:12:24 -04:00
|
|
|
<delete dir="${target.dir}" failonerror="false"/>
|
2010-05-14 12:53:06 -04:00
|
|
|
<delete>
|
|
|
|
<fileset refid="canonical.metamodel"/>
|
|
|
|
</delete>
|
|
|
|
</target>
|
|
|
|
|
2010-05-20 18:12:24 -04:00
|
|
|
<target name="info"
|
|
|
|
description="Prints environmental variables">
|
2010-05-14 12:53:06 -04:00
|
|
|
<echo>
|
|
|
|
Builds OpenBooks demo application.
|
|
|
|
OpenJPA Library: ${openjpa.lib}
|
2010-05-20 18:12:24 -04:00
|
|
|
Build mode : ${build.mode}
|
|
|
|
Deploy Location: ${deploy.dir}
|
2010-05-14 12:53:06 -04:00
|
|
|
</echo>
|
|
|
|
</target>
|
|
|
|
|
2010-05-20 18:12:24 -04:00
|
|
|
<target name="check-env"
|
|
|
|
description="Checks if required libraries exist"
|
|
|
|
depends="info">
|
|
|
|
<available file="${openjpa.lib}" property="openjpa.exists"/>
|
2010-05-25 01:27:19 -04:00
|
|
|
|
2010-05-14 12:53:06 -04:00
|
|
|
<fail unless="openjpa.exists">*** Error:
|
|
|
|
The directory for OpenJPA libraries can not be located at ${openjpa.lib}.
|
2010-05-14 16:29:27 -04:00
|
|
|
Make sure openjpa.lib property value is correct in build.properties file.
|
2010-05-14 12:53:06 -04:00
|
|
|
</fail>
|
2010-05-20 18:12:24 -04:00
|
|
|
<condition property="build.mode.is.valid">
|
|
|
|
<or>
|
|
|
|
<equals arg1="${build.mode}" arg2="jse" casesensitive="false" trim="true"/>
|
|
|
|
<equals arg1="${build.mode}" arg2="jee" casesensitive="false" trim="true"/>
|
|
|
|
</or>
|
|
|
|
</condition>
|
|
|
|
<fail unless="build.mode.is.valid" message="Invalid build.mode ${build.mode}"/>
|
|
|
|
<condition property="build.mode.is.jse">
|
|
|
|
<equals arg1="${build.mode}" arg2="jse" casesensitive="true" trim="true"/>
|
|
|
|
</condition>
|
|
|
|
<condition property="build.mode.is.jee">
|
|
|
|
<equals arg1="${build.mode}" arg2="jee" casesensitive="true" trim="true"/>
|
|
|
|
</condition>
|
|
|
|
<mkdir dir="${deploy.dir}"/>
|
2010-05-25 01:27:19 -04:00
|
|
|
|
|
|
|
<available file="${antlr.lib}" property="antlr.exists" />
|
2010-05-14 12:53:06 -04:00
|
|
|
</target>
|
|
|
|
|
2010-05-20 18:12:24 -04:00
|
|
|
<target name="generate-canonical-model" depends="check-env"
|
2010-05-14 17:17:02 -04:00
|
|
|
description="Generate canonical meta-model source">
|
2010-05-20 18:12:24 -04:00
|
|
|
<mkdir dir="${generated.src.dir}" />
|
2010-05-14 12:53:06 -04:00
|
|
|
<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"/>
|
2010-05-20 18:12:24 -04:00
|
|
|
<compilerarg value="${generated.src.dir}" />
|
2010-05-14 12:53:06 -04:00
|
|
|
</javac>
|
2010-05-14 17:17:02 -04:00
|
|
|
</target>
|
2010-05-20 18:12:24 -04:00
|
|
|
|
|
|
|
<target name="compile" depends="generate-canonical-model"
|
2010-05-14 17:17:02 -04:00
|
|
|
description="Compile classes.">
|
2010-05-20 18:12:24 -04:00
|
|
|
<subant antfile="build.${build.mode}.xml"
|
|
|
|
target="compile"
|
|
|
|
inheritrefs="true"
|
|
|
|
inheritall="true"
|
|
|
|
buildpath="${basedir}"/>
|
2010-05-14 17:17:02 -04:00
|
|
|
</target>
|
2010-05-20 18:12:24 -04:00
|
|
|
|
2010-05-14 17:17:02 -04:00
|
|
|
<target name="enhance" depends="check-env"
|
2010-05-20 18:12:24 -04:00
|
|
|
description="Enhance persistent domain classes.">
|
2010-05-14 12:53:06 -04:00
|
|
|
<java classname="org.apache.openjpa.enhance.PCEnhancer" fork="true">
|
|
|
|
<arg value="-properties" />
|
|
|
|
<arg value="${jpa.properties}" />
|
|
|
|
<classpath refid="compile.classpath" />
|
|
|
|
</java>
|
|
|
|
</target>
|
|
|
|
|
2010-05-20 18:12:24 -04:00
|
|
|
<target name="package" description="Build and Package based on JSE or JEE mode"
|
|
|
|
depends="check-env,
|
|
|
|
clean,
|
|
|
|
generate-canonical-model,
|
|
|
|
compile,
|
2010-05-25 01:27:19 -04:00
|
|
|
enhance,
|
|
|
|
generate-source">
|
2010-05-20 18:12:24 -04:00
|
|
|
<subant antfile="build.${build.mode}.xml"
|
|
|
|
target="package"
|
|
|
|
inheritrefs="true"
|
|
|
|
inheritall="true"
|
|
|
|
buildpath="${basedir}"/>
|
2010-05-14 12:53:06 -04:00
|
|
|
</target>
|
|
|
|
|
2010-05-26 17:50:26 -04:00
|
|
|
<target name="build-parser" depends="check-env" if="antlr.exists">
|
|
|
|
<java classname="org.antlr.Tool">
|
|
|
|
<classpath refid="code.generation.classpath"/>
|
|
|
|
<arg value="-o"/>
|
|
|
|
<arg value="${generated.src.dir}/openbook/tools/parser"/>
|
|
|
|
<arg value="-debug"/>
|
|
|
|
<arg value="${rsrc.dir}/META-INF/Java.g"/>
|
|
|
|
</java>
|
|
|
|
</target>
|
2010-05-25 01:27:19 -04:00
|
|
|
<!-- Generating viewable syntax colored Java code as html is to be split -->
|
|
|
|
<!-- for JSE and JEE mode for some differences in Swing based browser -->
|
|
|
|
<!-- versus general purpose web browsers. Swing based browser treats -->
|
|
|
|
<!-- line breaks, white spaces differently becuase it does not recognize -->
|
|
|
|
<!-- some critical CSS directives in this regard. This anamoly is -->
|
|
|
|
<!-- accounted for by customizing Java2HTMLConverter accordingly -->
|
|
|
|
<!-- see the respective target's options to notice the difference -->
|
|
|
|
<target name="generate-source" depends="check-env" if="antlr.exists">
|
|
|
|
<javac srcdir="${src.dir}" destdir="${classes.dir}">
|
|
|
|
<include name="openbook/tools/**/*.java"/>
|
|
|
|
<exclude name="openbook/tools/**/Test*.java"/>
|
|
|
|
<classpath refid="code.generation.classpath"/>
|
|
|
|
</javac>
|
|
|
|
<taskdef name="java2html" classname="openbook.tools.ant.Java2HTMLConverterTask">
|
|
|
|
<classpath refid="code.generation.classpath"/>
|
|
|
|
</taskdef>
|
|
|
|
<delete dir="${generated.html.dir}"></delete>
|
|
|
|
<mkdir dir="${generated.html.dir}"/>
|
|
|
|
<copy file="${rsrc.dir}/java.css" todir="${generated.html.dir}"/>
|
|
|
|
<subant antfile="build.${build.mode}.xml"
|
|
|
|
target="generate-source-with-options"
|
|
|
|
inheritrefs="true"
|
|
|
|
inheritall="true"
|
|
|
|
buildpath="${basedir}"/>
|
|
|
|
|
|
|
|
</target>
|
|
|
|
|
2010-05-14 12:53:06 -04:00
|
|
|
</project>
|