blob: 42e74178f644d3e16aabd06de57e76a3b577beed [file] [log] [blame]
<?xml version="1.0"?>
<!--
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="compile-core" basedir="." name="wookie" xmlns:ivy="antlib:org.apache.ivy.ant">
<description>
Ivy based build system for Apache Wookie.
</description>
<property file="local.build.properties"/>
<property file="build.properties"/>
<property name="wookie.root.dir" location="."/>
<property name="wookie.widgets.dir" location="./widgets"/>
<property name="db.name" value="widgetDB" />
<property name="etc.dir" location="etc" />
<!-- JPA annotation processor -->
<property name="java.source.version" value="1.6"/>
<property name="java.target.version" value="1.6"/>
<property name="compilerargs" value="-Aopenjpa.metamodel=true" />
<import file="ant/ivy-webapp-common.xml"/>
<import file="ant/ivy-release-common.xml"/>
<property file="${project.core.src.dir}/widgetserver.properties"/>
<property name="servletEngine.repository.dir" location="${servletEngine.webapp.dir}/../repository"/>
<target name="run" depends="deploy-webapp" description="Run in standalone mode">
<ant antfile="ant/ivy-java-common.xml" target="run"/>
</target>
<target name="post-deploy-webapp">
<!-- configure web.xml -->
<condition property="deploy.webapp.jpa" value="true">
<or>
<equals arg1="${wookie.persistence.manager.type}" arg2="jpa"/>
<not><isset property="wookie.persistence.manager.type"/></not>
</or>
</condition>
<condition property="deploy.webapp.jcr" value="true">
<equals arg1="${wookie.persistence.manager.type}" arg2="jcr"/>
</condition>
<antcall target="post-deploy-webapp-jpa"/>
<antcall target="post-deploy-webapp-jcr"/>
<!-- deploy features -->
<antcall target="post-deploy-webapp-features-extra"/>
<antcall target="post-deploy-webapp-features-scratchpad"/>
<!-- deploy widgets -->
<delete dir="${widget.build.dir}"/>
<antcall target="post-deploy-webapp-widgets-extra"/>
<antcall target="post-deploy-webapp-widgets-scratchpad"/>
</target>
<target name="post-deploy-webapp-widgets-extra" if="include.extra.widgets">
<subant antfile="build.xml" target="deploy-widget" inheritall="true">
<property name="deployToDev" value="true"/>
<fileset dir="${wookie.widgets.dir}">
<include name="${widget.deploy.include}"/>
<exclude name="${widget.deploy.exclude}"/>
</fileset>
</subant>
</target>
<target name="post-deploy-webapp-widgets-scratchpad" if="include.scratchpad.widgets">
<subant antfile="build.xml" target="deploy-widget" inheritall="true">
<property name="deployToDev" value="true"/>
<fileset dir="${user.dir}/scratchpad/widgets">
<include name="${widget.deploy.include}"/>
<exclude name="${widget.deploy.exclude}"/>
</fileset>
</subant>
</target>
<target name="post-deploy-webapp-features-extra" if="include.extra.features">
<echo>deploying extra features</echo>
<mkdir dir="${servletEngine.webapp.dir}/${ant.project.name}/features"/>
<copy todir="${servletEngine.webapp.dir}/${ant.project.name}/features">
<fileset dir="${user.dir}/features"/>
</copy>
</target>
<target name="post-deploy-webapp-features-scratchpad" if="include.scratchpad.features">
<echo>deploying scratchpad features</echo>
<mkdir dir="${servletEngine.webapp.dir}/${ant.project.name}/features"/>
<copy todir="${servletEngine.webapp.dir}/${ant.project.name}/features">
<fileset dir="${user.dir}/scratchpad/features"/>
</copy>
</target>
<target name="post-deploy-webapp-jpa" if="deploy.webapp.jpa">
<!-- configure JPA web.xml resource ref -->
<copy file="${project.webapp.dir}/WEB-INF/web.xml"
todir="${servletEngine.webapp.dir}/${ant.project.name}/WEB-INF"
overwrite="true">
<filterset>
<filter token="RESOURCE_REF_DESCRIPTION" value="The JPA database connection."/>
<filter token="RESOURCE_REF_NAME" value="jdbc/widgetdb"/>
<filter token="RESOURCE_REF_TYPE" value="javax.sql.DataSource"/>
</filterset>
</copy>
<!-- configure JPA widgetserver.properties settings -->
<condition property="widgetserver.db.type" value="${wookie.db.type}" else="">
<isset property="wookie.db.type"/>
</condition>
<copy file="${project.build.classes.dir}/widgetserver.properties"
todir="${servletEngine.webapp.dir}/${ant.project.name}/WEB-INF/classes"
overwrite="true">
<filterset>
<filter token="PERSISTENCE_MANAGER_CLASSNAME" value="org.apache.wookie.beans.jpa.JPAPersistenceManager"/>
<filter token="DATABASE_TYPE" value="${widgetserver.db.type}"/>
<filter token="REPOSITORY_USER" value=""/>
<filter token="REPOSITORY_PASSWORD" value=""/>
<filter token="REPOSITORY_ROOTPATH" value=""/>
<filter token="REPOSITORY_WORKSPACE" value=""/>
</filterset>
</copy>
<!-- deploy container libraries -->
<condition property="deploy.webapp.container.lib" value="true">
<and>
<isset property="servletEngine.container.lib.dir"/>
<isset property="jdbc.driver.path"/>
</and>
</condition>
<antcall target="post-deploy-webapp-jdbc-driver"/>
<!-- deploy tomcat webapp context configuration -->
<antcall target="post-deploy-webapp-context-conf-jpa"/>
</target>
<target name="post-deploy-webapp-jdbc-driver" if="deploy.webapp.container.lib">
<copy file="${jdbc.driver.path}" todir="${servletEngine.container.lib.dir}"/>
</target>
<target name="post-deploy-webapp-context-conf-jpa" if="servletEngine.context.conf.dir">
<!-- configure JPA context.xml configuration -->
<copy file="${etc.dir}/tomcat/conf/jpa-context.xml"
tofile="${servletEngine.context.conf.dir}/${ant.project.name}.xml"
overwrite="true">
<filterset>
<filter token="DATABASE_USER" value="${wookie.db.user}"/>
<filter token="DATABASE_PASSWORD" value="${wookie.db.password}"/>
<filter token="DATABASE_DRIVER" value="${wookie.db.driver}"/>
<filter token="DATABASE_URI" value="${wookie.db.uri}"/>
</filterset>
</copy>
</target>
<target name="post-deploy-webapp-jcr" if="deploy.webapp.jcr">
<ant dir="modules/jcr" target="deploy-module" inheritAll="false"/>
<!-- configure JCR web.xml resource ref -->
<copy file="${project.webapp.dir}/WEB-INF/web.xml"
todir="${servletEngine.webapp.dir}/${ant.project.name}/WEB-INF"
overwrite="true">
<filterset>
<filter token="RESOURCE_REF_DESCRIPTION" value="The JCR repository."/>
<filter token="RESOURCE_REF_NAME" value="jcr/widgetrepo"/>
<filter token="RESOURCE_REF_TYPE" value="javax.jcr.Repository"/>
</filterset>
</copy>
<!-- configure JCR widgetserver.properties settings -->
<condition property="widgetserver.repository.user" value="${wookie.repository.user}" else="">
<isset property="wookie.repository.user"/>
</condition>
<condition property="widgetserver.repository.password" value="${wookie.repository.password}" else="">
<isset property="wookie.repository.password"/>
</condition>
<condition property="widgetserver.repository.rootpath" value="${wookie.repository.rootpath}" else="">
<isset property="wookie.repository.rootpath"/>
</condition>
<condition property="widgetserver.repository.workspace" value="${wookie.repository.workspace}" else="">
<isset property="wookie.repository.workspace"/>
</condition>
<copy file="${project.build.classes.dir}/widgetserver.properties"
todir="${servletEngine.webapp.dir}/${ant.project.name}/WEB-INF/classes"
overwrite="true">
<filterset>
<filter token="PERSISTENCE_MANAGER_CLASSNAME" value="org.apache.wookie.beans.jcr.JCRPersistenceManager"/>
<filter token="DATABASE_TYPE" value=""/>
<filter token="REPOSITORY_USER" value="${widgetserver.repository.user}"/>
<filter token="REPOSITORY_PASSWORD" value="${widgetserver.repository.password}"/>
<filter token="REPOSITORY_ROOTPATH" value="${widgetserver.repository.rootpath}"/>
<filter token="REPOSITORY_WORKSPACE" value="${widgetserver.repository.workspace}"/>
</filterset>
</copy>
<!-- deploy tomcat webapp context configuration -->
<antcall target="post-deploy-webapp-context-conf-jcr"/>
</target>
<target name="post-deploy-webapp-context-conf-jcr" if="servletEngine.context.conf.dir">
<mkdir dir="${servletEngine.repository.dir}"/>
<copy file="${etc.dir}/tomcat/conf/repository.xml"
tofile="${servletEngine.repository.dir}/repository.xml"/>
<copy file="${etc.dir}/tomcat/conf/jcr-context.xml"
tofile="${servletEngine.context.conf.dir}/${ant.project.name}.xml"
overwrite="true">
<filterset>
<filter token="REPOSITORY_DIR" value="${servletEngine.repository.dir}"/>
</filterset>
</copy>
</target>
<target name="deploy-widget">
<property name="deployToDev" value="true"/>
<input message="What is the short name of the widget you wish to deploy?"
addproperty="widget.shortname"/>
<ant antfile="${wookie.widgets.dir}/${widget.shortname}/build.xml" target="deploy-widget"/>
</target>
<target name="seed-widget" description="Create a new widget from a supplied template">
<ant antfile="${wookie.widgets.dir}/build.xml" target="seed-widget"/>
</target>
<target name="build-widget">
<property name="deployToDev" value="true"/>
<input message="What is the short name of the widget you wish to build?"
addproperty="widget.shortname"/>
<ant antfile="${wookie.widgets.dir}/${widget.shortname}/build.xml" target="build-widget"/>
</target>
<target name="local-publish-subprojects">
<!-- localy publish sub-projects -->
<ant dir="${wookie.connector.dir}/java" target="publish-local" inheritAll="false"/>
<ant dir="${wookie.parser.w3c.dir}/java" target="publish-local" inheritAll="false"/>
</target>
<target name="publish-subproject-artifacts-to-snapshot-repo" description="Publishes all sub projects (i.e. java connector and parser projects) to the apache snapshot repository">
<!-- publish snapshot sub-projects -->
<ant dir="${wookie.connector.dir}/java" target="publish-maven-snapshot-artifacts" inheritAll="false"/>
<ant dir="${wookie.parser.w3c.dir}/java" target="publish-maven-snapshot-artifacts" inheritAll="false"/>
</target>
<target name="publish-subproject-artifacts-to-release-repo" description="Publishes all sub projects (i.e. java connector and parser projects) to the apache release repository">
<!-- publish staging/release sub-projects -->
<ant dir="${wookie.connector.dir}/java" target="publish-maven-release-artifacts" inheritAll="false"/>
<ant dir="${wookie.parser.w3c.dir}/java" target="publish-maven-release-artifacts" inheritAll="false"/>
</target>
<target name="pre-compile-core">
<!-- build supported database schema scripts -->
<ivy:cachepath pathid="project.ddlutils.class.path" conf="ddlutils" />
<antcall target="build-database-schema" inheritRefs="true">
<param name="databasetype" value="db2" />
</antcall>
<antcall target="build-database-schema" inheritRefs="true">
<param name="databasetype" value="derby" />
</antcall>
<antcall target="build-database-schema" inheritRefs="true">
<param name="databasetype" value="hsqldb" />
</antcall>
<antcall target="build-database-schema" inheritRefs="true">
<param name="databasetype" value="mssql" />
</antcall>
<antcall target="build-database-schema" inheritRefs="true">
<param name="databasetype" value="mysql" />
</antcall>
<antcall target="build-database-schema" inheritRefs="true">
<param name="databasetype" value="mysql5" />
</antcall>
<antcall target="build-database-schema" inheritRefs="true">
<param name="databasetype" value="oracle" />
</antcall>
<antcall target="build-database-schema" inheritRefs="true">
<param name="databasetype" value="oracle9" />
</antcall>
<antcall target="build-database-schema" inheritRefs="true">
<param name="databasetype" value="oracle10" />
</antcall>
<antcall target="build-database-schema" inheritRefs="true">
<param name="databasetype" value="postgresql" />
</antcall>
<antcall target="build-database-schema" inheritRefs="true">
<param name="databasetype" value="sybase" />
</antcall>
</target>
<target name="build-database-schema">
<!-- build specified database schema script -->
<taskdef classname="org.apache.ddlutils.task.DdlToDatabaseTask" name="ddlToDatabase"
classpathref="project.ddlutils.class.path" />
<mkdir dir="${project.build.classes.dir}/org/apache/wookie/beans/jpa" />
<ddlToDatabase usedelimitedsqlidentifiers="false"
databasetype="${databasetype}"
schemafile="${etc.dir}/ddl-schema/wookie-schema.xml">
<writeSchemaSqlToFile outputfile="${project.build.classes.dir}/org/apache/wookie/beans/jpa/${databasetype}-wookie-schema.sql"
dodrops="true"
alterdatabase="false"
failonerror="true" />
</ddlToDatabase>
</target>
<target name="post-compile-core">
<!-- JPA enhancement -->
<path id="project.openjpa.class.path">
<path refid="project.core.class.path" />
<path location="${project.build.classes.dir}" />
</path>
<taskdef name="openJPAEnhancer" classname="org.apache.openjpa.ant.PCEnhancerTask"
classpathref="project.openjpa.class.path" />
<openJPAEnhancer directory="${project.build.classes.dir}/org/apache/wookie/beans/jpa/impl"
addDefaultConstructor="true" enforcePropertyRestrictions="true">
<config propertiesFile="${project.build.classes.dir}/META-INF/persistence.xml" />
<classpath>
<path refid="project.openjpa.class.path" />
</classpath>
</openJPAEnhancer>
</target>
<target name="post-compile-test">
<!-- run unit tests, (skip functional and integration tests) -->
<junit fork="yes" forkmode="once" printsummary="true" haltonfailure="true">
<formatter type="brief" usefile="false"/>
<classpath>
<path location="${project.build.classes.test.dir}" />
<path location="${project.build.classes.dir}" />
<path refid="project.test.class.path" />
</classpath>
<batchtest>
<fileset dir="${project.build.classes.test.dir}"
includes="**/*Test.class"
excludes="**/Abstract*Test.class,**/functional/*Test.class,**/integration/*Test.class,**/flatpack/*Test.class" />
</batchtest>
</junit>
</target>
</project>