blob: fe0de7d4da008b51bcf225aead3cde349a72e124 [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.
-->
<!-- $Id$ -->
<project name="lenya-webapp">
<description>
Webapp Targets
</description>
<target name="compile-api" description="compile and deploy API">
<antcall target="compile-src">
<param name="compile.src.dir" value="${src.java.api.dir}"/>
<param name="compile.dest.dir" value="${build.dir}/api"/>
<param name="compile.classpath" value="classpath"/>
<param name="jar.name" value="api"/>
</antcall>
</target>
<target name="compile-impl" description="compile and deploy core implementation">
<path id="classpath.impl">
<path refid="classpath"/>
<fileset dir="${build.webapp}/WEB-INF/lib" includes="lenya-*-api.jar"/>
</path>
<antcall target="compile-src">
<param name="compile.src.dir" value="${src.java.impl.dir}"/>
<param name="compile.dest.dir" value="${build.dir}/impl"/>
<param name="compile.classpath" value="classpath.impl"/>
<param name="jar.name" value="impl"/>
</antcall>
</target>
<!--
This target creates a webapp directory which exactly mirrors how
the war file will look. It is used to create the war file for
the "war" target but it can also be used by developers
directly.
This is useful if the reloadable attribute of the context
in the server.xml configuration is set to true so changes in the classes
are reflected immediately.
-->
<target name="webapp" depends="prepare-src"
description="Builds the webapp directory ready to be linked into a servlet engines context directory">
<!--
Copy CMS files and overwrite some parts of the previously copied cocoon webapp package with our customized files
-->
<copy todir="${build.webapp}">
<fileset dir="${src.webapp.dir}">
<exclude name="lenya/config/cocoon-xconf/**"/>
<exclude name="lenya/config/sitemap/**"/>
</fileset>
</copy>
<!-- Copy publications -->
<copyPubs todir="${build.webapp}/lenya/pubs"
pubsrootdirs="${pubs.root.dirs}"
excludes="CVS,.svn,cocoon-xconf,lenya-roles,local.publication.xml,local.ac.xconf,.project"/>
<jing rngfile="${src.resource.dir}/build/publication.rng">
<fileset dir="${build.webapp}" includes="lenya/pubs/*/config/publication.xml"/>
</jing>
<jing rngfile="${src.resource.dir}/build/workflow.rng">
<fileset dir="${build.webapp}" includes="lenya/pubs/*/config/workflow/workflow.xml"/>
</jing>
<bulkCopy
sourcedirs="${pubs.root.dirs}"
todir="${build.patch}/cocoon-xconf/pubs"
flatten="false">
<fileset includes="config/cocoon-xconf/**.xconf"/>
<fileset includes="*/config/cocoon-xconf/**.xconf"/>
</bulkCopy>
<bulkCopy
sourcedirs="${pubs.root.dirs}"
todir="${build.patch}/lenya-roles/pubs"
flatten="false">
<fileset includes="config/lenya-roles/**.xroles"/>
<fileset includes="*/config/lenya-roles/**.xroles"/>
</bulkCopy>
<!-- copy patch files -->
<copy todir="${build.patch}" flatten="false">
<fileset dir="${src.webapp.dir}/lenya/config">
<include name="cocoon-xconf/**/*.xconf"/>
<include name="cocoon-xconf/*.xconf"/>
<include name="sitemap/**/*.xmap"/>
<include name="sitemap/*.xmap"/>
</fileset>
</copy>
<!-- Patch publication tests -->
<copy file="./src/targets/publication-test-build-template.xml"
tofile="./src/targets/publication-test-build.xml"
overwrite="true"/>
<xpatch file="./src/targets/publication-test-build.xml"
srcdir="${build.webapp}/lenya/pubs"
includes="*/targets/test-build.xconf"
addComments="true"/>
<!-- now create logs directory, where log4j can write to -->
<mkdir dir="${build.webapp}/WEB-INF/logs"/>
<!-- now copy any additional libraries in ./lib -->
<mkdir dir="${build.webapp}/WEB-INF/lib"/>
<!-- Copy libraries from ${lib.dir} and ${tools.lib.dir} to ${build.webapp}/WEB-INF/lib -->
<copy todir="${build.webapp}/WEB-INF/lib">
<fileset dir="${lib.dir}">
<include name="**/*"/>
</fileset>
<fileset dir="${tools.lib.dir}">
<include name="**/*"/>
</fileset>
</copy>
<!-- now create directory for endorsed libraries -->
<mkdir dir="${build.webapp}/WEB-INF/lib/endorsed"/>
<!-- Copy libraries from ${endorsed.lib.dir} and ${cocoon.endorsed.lib.dir} to ${build.webapp}/WEB-INF/lib/endorsed -->
<copy todir="${build.webapp}/WEB-INF/lib/endorsed">
<fileset dir="${cocoon.endorsed.lib.dir}">
<include name="**/*"/>
</fileset>
</copy>
<!-- Delete endorsed libraries from common webapp lib directory -->
<delete>
<fileset dir="${build.webapp}/WEB-INF/lib">
<present present="both" targetdir="${cocoon.endorsed.lib.dir}"/>
</fileset>
</delete>
<antcall target="compile-api"/>
<antcall target="compile-impl"/>
<!--
<antcall target="deploy-modules"/>
-->
<!-- Patch sitemap.xmap -->
<xpatch file="${build.webapp}/sitemap.xmap"
srcdir="${build.patch}/sitemap"
includes="**/*.xmap"
addComments="false"/>
<!-- Patch cocoon.xconf -->
<property name="patch.webapp" value="true"/>
<xpatch file="${build.webapp}/WEB-INF/cocoon.xconf"
srcdir="${build.patch}/cocoon-xconf"
includes="prepare/*.xconf"
addComments="true"/>
<xpatch file="${build.webapp}/WEB-INF/cocoon.xconf"
srcdir="${build.patch}/cocoon-xconf"
includes="**/*.xconf"
excludes="prepare/*.xconf"
addComments="false"/>
<antcall target="deploy-modules"/>
<path id="classpath.pubs">
<path refid="classpath"/>
<fileset dir="${build.webapp}/WEB-INF/lib" includes="lenya-*-api.jar"/>
<fileset dir="${build.webapp}/WEB-INF/lib" includes="lenya-module-*.jar"/>
</path>
<!-- compile and package publications -->
<antcall target="compile-src">
<param name="compile.src.dir" value="${build.dir}/java/pubs"/>
<param name="compile.dest.dir" value="${build.dir}/pubs"/>
<param name="compile.classpath" value="classpath.pubs"/>
<param name="jar.name" value="pubs"/>
</antcall>
<!-- Patch lenya.roles -->
<copy todir="${build.webapp}/WEB-INF/classes/org/apache/lenya"
file="${build.dir}/impl/org/apache/lenya/lenya.roles"/>
<!-- Copy database files to ${build.webapp}/WEB-INF/db -->
<copy todir="${build.webapp}/WEB-INF/db">
<fileset dir="${src.database.dir}">
<include name="**/*"/>
</fileset>
</copy>
<!-- Replace version placeholder with build version -->
<replace dir="${build.webapp}">
<include name="lenya/content/welcome.xml"/>
<include name="lenya/content/about.xml"/>
<include name="**/config/publication.xml"/>
<replacefilter token="@lenya.version@" value="${version}"/>
<replacefilter token="@lenya.revision@" value="${lenya.revision}"/>
</replace>
<condition property="servlet.engine.tomcat">
<equals arg1="${web.app.server}" arg2="Tomcat"/>
</condition>
<antcall target="install-tomcat"/>
<antcall target="successfully-built-message-tomcat"/>
<condition property="servlet.engine.jetty">
<equals arg1="${web.app.server}" arg2="Jetty"/>
</condition>
<antcall target="successfully-built-message-jetty"/>
</target>
<!--
The war target just packs up what was created in the webapp target
(and triggers the javadoc target with the dependency)
-->
<target name="war" depends="webapp" description="Builds the deployable war file">
<mkdir dir="${dist.bin.dir}"/>
<jar jarfile="${dist.bin.warfile}" basedir="${build.webapp}" excludes="META-INF/MANIFEST.MF"/>
<echo>
The following libraries must be placed in the endorsed library directory for your deployment.
* jakarta-bcel-20040329.jar
* jakarta-regexp-1.3.jar
* xalan-2.6.0.jar
* xercesImpl-2.6.2.jar
* xml-apis.jar
</echo>
</target>
<!-- Clean Tomcat directories -->
<target name="clean-tomcat" description="Clean also the servlet engine context of Tomcat" if="servlet.engine.tomcat">
<echo>INFO: Clean Tomcat context and cache: ${tomcat.webapps.dir}, ${tomcat.cache.dir}</echo>
<delete dir="${tomcat.cache.dir}" quiet="true"/>
<delete includeEmptyDirs="true" quiet="true">
<fileset dir="${tomcat.webapps.dir}" excludes="${target.reset.excludes}" />
</delete>
</target>
<!-- Cleans the Lenya build directory, with the exception of target.reset.excludes -->
<target name="clean" depends="init" description="Cleans the build directories">
<mkdir dir="${build.root}"/> <!-- Create dir such that build process does not fail if build dir does not exist -->
<delete includeEmptyDirs="true">
<fileset dir="${build.root}" excludes="${target.reset.excludes}" />
</delete>
<delete dir="${dist.root}"/>
<condition property="servlet.engine.tomcat">
<equals arg1="${web.app.server}" arg2="Tomcat"/>
</condition>
<antcall target="clean-tomcat"/>
</target>
<!-- Cleans the Cocoon build directory and the local.p* files -->
<target name="clean-cocoon" depends="init" description="Cleans Cocoon">
<echo>INFO: Clean Cocoon: ${cocoon.src.dir}/build</echo>
<delete includeEmptyDirs="true" quiet="true">
<fileset dir="${cocoon.src.dir}/build"/>
</delete>
<delete file="${cocoon.src.dir}/local.build.properties" quiet="true"/>
<delete file="${cocoon.src.dir}/local.blocks.properties" quiet="true"/>
</target>
<!-- Cleans the build files of Lenya, Cocoon and Tomcat -->
<target name="clean-all" depends="clean, clean-cocoon" description="Cleans Lenya and Cocoon"/>
<!-- Install the webapp into Tomcat -->
<target name="install-tomcat" description="Install the webapp into Tomcat servlet engine context" if="servlet.engine.tomcat">
<!-- Copy From build.webapp=${build.webapp} To tomcat.webapps.dir=${tomcat.webapps.dir} -->
<copy todir="${tomcat.webapps.dir}" filtering="off">
<fileset dir="${build.webapp}"/>
</copy>
<!-- Copy endorsed libraries -->
<copy todir="${tomcat.endorsed.dir}">
<fileset dir="${build.webapp}/WEB-INF/lib/endorsed">
<include name="*.jar"/>
</fileset>
</copy>
</target>
<!-- Install publication -->
<target name="install-pub" depends="webapp" description="Install a publication into servlet engine context. Usage: -Dpub.prefix=blog">
<!-- Copy From build.webapp=${build.webapp}/lenya/pubs/${pub.prefix} To tomcat.webapps.dir=${tomcat.webapps.dir}/lenya/pubs/${pub.prefix} -->
<copy todir="${tomcat.webapps.dir}/lenya/pubs/${pub.prefix}" filtering="off">
<fileset dir="${build.webapp}/lenya/pubs/${pub.prefix}" excludes="${target.install.excludes}"/>
</copy>
</target>
<!-- Reload Tomcat -->
<target name="reload">
<!-- For Tomcat Tasks -->
<path id="tomcat.classpath">
<fileset dir="${tomcat.webapps.dir}/../../server/lib"
includes="catalina-ant.jar" />
</path>
<taskdef name="reload"
classname="org.apache.catalina.ant.ReloadTask"
classpathref="tomcat.classpath" />
<reload
url="http://localhost:8080/manager"
username="user"
password="password"
path="/lenya"/>
</target>
</project>