blob: ce17a20646006d91c8f910c973b489dbaa05bdea [file] [log] [blame]
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
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.
-->
<!--
This is the Ant build file for the JSPWiki project.
The verbosity in this file is intentional - it is also
an example for those who don't know Ant yet that well
and would like to learn it.
The build file assumes the following directory structure:
JSPWiki
|___build.xml
|
|___etc
| |___[jspwiki.properties and web.xml]
|
|___src
| |___webdocs
| | |___[all .jsp files]
| |
| |___org
| |___[...and the rest of the source code files]
|
|___docs
|
|___lib
|
|___tests
|___org
|___[...and the rest of the test source code]
$Id: build.xml,v 1.97 2007-12-22 22:00:31 jalkanen Exp $
-->
<!--
First, we define the project. We assign it a name,
and the default action if no action is specified on the
command line. Also, all relative directory references
in the rest of the project file should be calculated from
the current directory.
-->
<project name="JSPWiki" default="compile" basedir=".">
<!-- This tells us which build.properties file lies. By default, we
use the SVN version (which is tuned to my environment), but you
will probably want to override this from the command line. -->
<property name="build.properties" value="build.properties" />
<property file="${build.properties}" />
<property name="debug" value="true" />
<property name="deprecation" value="false" />
<property name="optimize" value="false" />
<!-- This denotes the directory where the Java source code lies. -->
<property name="code.src" value="src/main/java" />
<!-- This denotes the directory where the source code resources lie. -->
<property name="code.resources" value="src" />
<!-- The class files are actually put in this directory. It is
a good habit to keep .class -files separate from the .java -files. -->
<property name="code.build" value ="build" />
<!-- The internationalization strings for the core JSPWiki classes -->
<property name="code.i18n" value="etc/i18n" />
<!-- The i18n location in which 18n templates are created -->
<property name="tmplt.i18n.dir" value="i18n_templates" />
<!-- The location for the JAR file for the core JSPWiki classes -->
<property name="jarfile" value="${code.build}/${ant.project.name}.jar" />
<!-- The location of the JAR file for the test classes -->
<property name="testjarfile" location="${code.build}/${ant.project.name}-test.jar" />
<!-- The location for the keystore used to sign the JAR; will be created if it doesn't exist. -->
<property name="jks.keystore" value="${basedir}/etc/jspwiki.jks" />
<!-- Define a temporary directory, based on the system temporary directory,
the user name, and the project name (defined above) -->
<property name="tmpdir" value="${basedir}/build/tmp" />
<!-- The following three properties define the location of the
test sources, the location of the test .class files and the
directory where the test results are written in. -->
<property name="tests.src" value="src/test/java" />
<property name="tests.resources" value="tests" />
<property name="tests.build" value="tests/build" />
<property name="tests.reports" value="tests/reports" />
<property name="doc.rat" value="doc/rat" />
<!-- dirs holding libs -->
<property name="libs.main" value="lib" />
<property name="libs.tests" value="tests/lib" />
<property name="libs.opt" value="tests/libs-opt" />
<property name="central.url" value="http://repo.maven.apache.org/maven2" />
<!-- Web unit test properties -->
<property name="webtests.browser" value="*firefox" />
<property name="webtests.reports" value="${basedir}/tests/reports/selenium" />
<property name="webtests.build" value="tests/build/webtests" />
<property name="webtests.port" value="10024" />
<property name="webtests.temp" value="${java.io.tmpdir}/webtests" />
<property name="selenium-rc.jar" value="tests/lib/selenium-server-standalone-2.25.0.jar" />
<!-- The place where the javadocs are created -->
<property name="docs.javadoc" value="doc/javadoc" />
<!-- The temporary installation directory where all war-files
are collected, for example -->
<property name="install.fulldir" value="${tmpdir}/install" />
<!-- The directory where the SVN sources are checked out. -->
<property name="install.src" value="${tmpdir}/svnsrc" />
<!-- Define the SVN properties. These are used when building the
source distribution. Normally, you shouldn't have to care about these.
-->
<property name="svn.repository" value="http://svn.apache.org/repos/asf/incubator/jspwiki" />
<property name="svn.tag" value="tags/jspwiki_2_9_1_incubating_rc2" />
<!-- And finally, the directory where the final .zip-file is put -->
<property name="release.dir" value="releases" />
<!-- PATH DEFINITIONS -->
<!-- The base path for compilation. We include, of course, the
already built files in the build-directory, and then we
add all the jar files in the "lib" -directory. -->
<path id="path.base">
<pathelement path="${code.build}" />
<fileset dir="${libs.main}">
<include name="*.jar" />
</fileset>
</path>
<!-- The path used for running tests. We add the tests/etc directory
to the base path defined above, since we put all the relevant
.properties-files in tests/etc. -->
<path id="path.tests">
<pathelement location="${jarfile}" />
<pathelement location="${testjarfile}" />
<pathelement location="${java.home}/../lib/tools.jar" />
<fileset dir="${libs.main}">
<include name="*.jar" />
</fileset>
<fileset dir="${libs.tests}">
<include name="*.jar" />
</fileset>
<!-- Standard Maven location for test resources; note ini folder
present both below and in ${jarfile} (can cause conflict? bug?) -->
<pathelement path="${tests.src}/../resources" />
<!-- Below line temporary until all test resources in Maven location -->
<pathelement path="${tests.resources}/etc" />
</path>
<!-- Path holding (L)GPL jars and their dependencies -->
<path id="path.optional">
<fileset dir="${libs.opt}">
<include name="*.jar" />
</fileset>
<path refid="path.base" />
<path refid="path.tests" />
</path>
<!-- The prefix to use when reading environment variables -->
<property environment="env" />
<!-- ============================================================== -->
<!-- Initialising, cleaning, etc. -->
<target name="init"
description="Initializes everything, creates directories, etc."
depends="mkpropertyfile">
<mkdir dir="${code.build}" />
<mkdir dir="${tests.build}" />
<mkdir dir="${tests.reports}" />
<mkdir dir="${@tests.pagedir@}" />
<mkdir dir="${libs.main}" />
<mkdir dir="${libs.tests}" />
<mkdir dir="${libs.opt}" />
<download-deps />
</target>
<target name="test-file-exists">
<echo message="Testing for ${download-to-file}" level="debug"/>
<available file="${download-to-file}" property="exists" />
</target>
<target name="download-lib" unless="exists" depends="test-file-exists">
<get src="${download-url}" dest="${download-to-file}" />
</target>
<macrodef name="get-element">
<attribute name="to-file" />
<attribute name="url" />
<sequential>
<antcall target="download-lib">
<param name="download-to-file" value="@{to-file}"/>
<param name="download-url" value="@{url}" />
</antcall>
</sequential>
</macrodef>
<macrodef name="download-deps">
<sequential>
<!-- main dependencies -->
<get-element to-file="${libs.main}/activation-1.1.jar" url="${central.url}/javax/activation/activation/1.1/activation-1.1.jar" />
<get-element to-file="${libs.main}/akismet-java-1.02.jar" url="${central.url}/net/sourceforge/akismet-java/1.02/akismet-java-1.02.jar" />
<get-element to-file="${libs.main}/commons-codec-1.3.jar" url="${central.url}/commons-codec/commons-codec/1.3/commons-codec-1.3.jar" />
<get-element to-file="${libs.main}/commons-fileupload-1.2.1.jar"
url="${central.url}/commons-fileupload/commons-fileupload/1.2.1/commons-fileupload-1.2.1.jar" />
<get-element to-file="${libs.main}/commons-httpclient-3.1.jar"
url="${central.url}/commons-httpclient/commons-httpclient/3.1/commons-httpclient-3.1.jar" />
<get-element to-file="${libs.main}/commons-io-1.4.jar" url="${central.url}/commons-io/commons-io/1.4/commons-io-1.4.jar" />
<get-element to-file="${libs.main}/commons-lang-2.6.jar" url="${central.url}/commons-lang/commons-lang/2.6/commons-lang-2.6.jar" />
<get-element to-file="${libs.main}/commons-logging-api-1.0.4.jar"
url="${central.url}/commons-logging/commons-logging-api/1.0.4/commons-logging-api-1.0.4.jar" />
<get-element to-file="${libs.main}/ecs-1.4.2.jar" url="${central.url}/ecs/ecs/1.4.2/ecs-1.4.2.jar" />
<get-element to-file="${libs.main}/freshcookies-security-0.60.jar"
url="${central.url}/org/freshcookies/freshcookies-security/0.60/freshcookies-security-0.60.jar" />
<get-element to-file="${libs.main}/standard-1.1.2.jar" url="${central.url}/taglibs/standard/1.1.2/standard-1.1.2.jar" />
<get-element to-file="${libs.main}/jstl-1.1.2.jar" url="${central.url}/javax/servlet/jstl/1.1.2/jstl-1.1.2.jar" />
<get-element to-file="${libs.main}/jaxen-1.1-beta-6.jar" url="${central.url}/jaxen/jaxen/1.1-beta-6/jaxen-1.1-beta-6.jar"/>
<get-element to-file="${libs.main}/jdom-1.0.jar" url="${central.url}/jdom/jdom/1.0/jdom-1.0.jar" />
<get-element to-file="${libs.main}/jrcs-diff-0.4.2.jar"
url="${central.url}/org/jvnet/hudson/org.suigeneris.jrcs.diff/0.4.2/org.suigeneris.jrcs.diff-0.4.2.jar" />
<get-element to-file="${libs.main}/jsonrpc-1.0.jar" url="${central.url}/com/metaparadigm/json-rpc/1.0/json-rpc-1.0.jar" />
<get-element to-file="${libs.main}/jsp-api-2.0.jar" url="${central.url}/javax/servlet/jsp/jsp-api/2.0/jsp-api-2.0.jar" />
<get-element to-file="${libs.main}/log4j-1.2.14.jar" url="${central.url}/log4j/log4j/1.2.14/log4j-1.2.14.jar" />
<get-element to-file="${libs.main}/lucene-core-3.6.0.jar" url="${central.url}/org/apache/lucene/lucene-core/3.6.0/lucene-core-3.6.0.jar" />
<get-element to-file="${libs.main}/lucene-highlighter-3.6.0.jar"
url="${central.url}/org/apache/lucene/lucene-highlighter/3.6.0/lucene-highlighter-3.6.0.jar" />
<get-element to-file="${libs.main}/lucene-memory-3.6.0.jar"
url="${central.url}/org/apache/lucene/lucene-memory/3.6.0/lucene-memory-3.6.0.jar" />
<get-element to-file="${libs.main}/mail-1.4.jar" url="${central.url}/javax/mail/mail/1.4/mail-1.4.jar" />
<get-element to-file="${libs.main}/nekohtml-0.9.4.jar" url="${central.url}/nekohtml/nekohtml/0.9.4/nekohtml-0.9.4.jar" />
<get-element to-file="${libs.main}/oro-2.0.7.jar" url="${central.url}/oro/oro/2.0.7/oro-2.0.7.jar" />
<get-element to-file="${libs.main}/oscache-2.3.jar" url="${central.url}/opensymphony/oscache/2.3/oscache-2.3.jar" />
<get-element to-file="${libs.main}/sandler-0.5.jar" url="${central.url}/net/sourceforge/sandler/0.5/sandler-0.5.jar" />
<get-element to-file="${libs.main}/servlet-api-2.4.jar" url="${central.url}/javax/servlet/servlet-api/2.4/servlet-api-2.4.jar" />
<get-element to-file="${libs.main}/xmlrpc-2.0.1.jar" url="${central.url}/xmlrpc/xmlrpc/2.0.1/xmlrpc-2.0.1.jar" />
<!-- tests dependencies -->
<get-element to-file="${libs.tests}/commons-el-1.0.jar" url="${central.url}/commons-el/commons-el/1.0/commons-el-1.0.jar" />
<get-element to-file="${libs.tests}/hsqldb-1.8.0.10.jar" url="${central.url}/org/hsqldb/hsqldb/1.8.0.10/hsqldb-1.8.0.10.jar" />
<get-element to-file="${libs.tests}/jetty-all-7.6.7.v20120910.jar"
url="${central.url}/org/eclipse/jetty/aggregate/jetty-all/7.6.7.v20120910/jetty-all-7.6.7.v20120910.jar" />
<get-element to-file="${libs.tests}/junit-3.8.2.jar" url="${central.url}/junit/junit/3.8.2/junit-3.8.2.jar" />
<get-element to-file="${libs.tests}/selenium-server-standalone-2.25.0.jar"
url="http://selenium.googlecode.com/files/selenium-server-standalone-2.25.0.jar" />
<get-element to-file="${libs.tests}/stripes-1.5.7.jar" url="${central.url}/net/sourceforge/stripes/stripes/1.5.7/stripes-1.5.7.jar" />
<get-element to-file="${libs.tests}/yuicompressor-2.4.7.jar"
url="${central.url}/com/yahoo/platform/yui/yuicompressor/2.4.7/yuicompressor-2.4.7.jar" />
<!-- other dependencies ((L)GPL dependencies and jars needed by these) -->
<get-element to-file="${libs.opt}/cobertura-1.9.4.1.jar" url="${central.url}/net/sourceforge/cobertura/cobertura/1.9.4.1/cobertura-1.9.4.1.jar" />
<get-element to-file="${libs.opt}/asm-3.0.jar" url="${central.url}/asm/asm/3.0/asm-3.0.jar" />
<get-element to-file="${libs.opt}/asm-tree-3.0.jar" url="${central.url}/asm/asm-tree/3.0/asm-tree-3.0.jar" />
<get-element to-file="${libs.opt}/sonar-ant-task-2.0.jar" url="${central.url}/org/codehaus/sonar-plugins/sonar-ant-task/2.0/sonar-ant-task-2.0.jar" />
</sequential>
</macrodef>
<target name="mkpropertyfile"
description="Builds the correct propertyfile from the build.properties">
<copy file="etc/jspwiki.properties.tmpl" tofile="etc/jspwiki.properties" />
<copy file="tests/etc/jspwiki.properties.tmpl" tofile="tests/etc/jspwiki.properties" />
<copy file="tests/etc/jspwiki_rcs.properties.tmpl" tofile="tests/etc/jspwiki_rcs.properties" />
<copy file="tests/etc/jspwiki_vers.properties.tmpl" tofile="tests/etc/jspwiki_vers.properties" />
<replace file="etc/jspwiki.properties"
replacefilterfile="${build.properties}" />
<replace file="tests/etc/jspwiki.properties"
replacefilterfile="${build.properties}" />
<replace file="tests/etc/jspwiki_rcs.properties"
replacefilterfile="${build.properties}" />
<replace file="tests/etc/jspwiki_vers.properties"
replacefilterfile="${build.properties}" />
</target>
<!-- Removes the build directory and the tests build directory -->
<target name="clean"
description="Cleans away all generated files.">
<delete file="cobertura.ser" />
<delete dir="${tests.build}" />
<delete dir="${code.build}" />
<delete dir="${tests.reports}" />
<delete dir="${docs.javadoc}" />
<delete dir="${doc.rat}" />
<delete file="etc/jspwiki.properties" />
<delete file="etc/i18n/CoreResources_en.properties" />
<delete file="etc/i18n/plugin/PluginResources_en.properties" />
<delete file="etc/i18n/templates/default_en.properties" />
<delete file="tests/etc/groupdatabase.xml" />
<delete file="tests/etc/userdatabase.xml" />
<delete file="tests/etc/jspwiki.properties" />
<delete file="tests/etc/jspwiki_rcs.properties" />
<delete file="tests/etc/jspwiki_vers.properties" />
<delete dir="tests/etc/db" />
<delete dir="tests/etc/WEB-INF/dtd" />
<delete file="tests/etc/WEB-INF/web.xml" />
<delete>
<fileset dir="." includes="**/*~" defaultexcludes="no"/>
<fileset dir="." includes="**/#*#" defaultexcludes="no"/>
</delete>
</target>
<!-- Removes all lib directories -->
<target name="clean-deps"
description="Cleans away all downloaded files.">
<delete dir="${libs.main}" />
<delete dir="${libs.tests}" />
<delete dir="${libs.opt}" />
</target>
<!-- ============================================================== -->
<!-- Compilation targets -->
<!-- In English this means that the "init" -target must be executed
first. After this, the java compiler is invoked with options
that compile every .java file in ${code.src} into .class files
in directory ${code.build}. The is no debugging information
and the compiler is instructed to optimize the resulting code.
For the classpath we use the previously defined path called
"path.base" -->
<target name="compile" depends="init"
description="Builds the source code.">
<javac srcdir="${code.src}"
destdir="${code.build}"
debug="${debug}"
optimize="${optimize}"
deprecation="${deprecation}"
source="1.6"
target="1.6"
includeantruntime="false"
>
<classpath refid="path.base" />
<classpath refid="path.tests" />
</javac>
</target>
<!-- This is similar to above. We use this to compile the
tests. -->
<target name="compiletests" depends="init,compile"
description="Builds the test code.">
<javac srcdir="${tests.src}"
destdir="${tests.build}"
debug="true"
deprecation="${deprecation}"
source="1.6"
target="1.6"
includeantruntime="false"
>
<classpath refid="path.base" />
<classpath refid="path.tests" />
</javac>
</target>
<!-- Creates javadocs -->
<target name="javadoc"
description="Compiles the javadocs.">
<delete dir="${docs.javadoc}" quiet="true"/>
<mkdir dir="${docs.javadoc}" />
<javadoc destdir="${docs.javadoc}"
use="yes"
breakiterator="true"
windowtitle="${ant.project.name}">
<packageset dir="${code.src}">
<include name="org/apache/wiki/**" />
</packageset>
<link href="http://docs.oracle.com/javase/6/docs/api/"/>
<link href="http://java.sun.com/products/javamail/javadocs/"/>
<link href="http://java.sun.com/j2ee/sdk_1.3/techdocs/api/"/>
<link href="http://www.jdom.org/docs/apidocs/"/>
<classpath refid="path.base" />
<classpath refid="path.tests" />
</javadoc>
</target>
<!-- ============================================================== -->
<!-- Installation targets -->
<!-- This target makes sure all the necessary directories exist
for building the installation package. -->
<target name="installinit">
<mkdir dir="${install.fulldir}" />
<delete dir="${install.src}" />
<mkdir dir="${install.src}" />
<delete dir="${release.dir}" />
<mkdir dir="${release.dir}" />
</target>
<!-- Builds the jar of all compiled class files -->
<target name="buildjar" unless="check_jar_has_been_built">
<!-- This is unfortunately needed, since the default property files are not otherwise
used. FIXME: Figure out a better way to do this in the future. -->
<copy file="${code.i18n}/CoreResources.properties" tofile="${code.i18n}/CoreResources_en.properties"/>
<copy file="${code.i18n}/templates/default.properties" tofile="${code.i18n}/templates/default_en.properties"/>
<copy file="${code.i18n}/plugin/PluginResources.properties" tofile="${code.i18n}/plugin/PluginResources_en.properties"/>
<jar jarfile="${jarfile}">
<fileset dir="${code.build}" includes="**/*.class" />
<fileset dir="${code.src}" includes="org/**/*.properties" />
<fileset dir="${code.resources}" includes="templates/**/*.properties" />
<fileset dir="${code.i18n}" />
<fileset dir="src/main/resources" includes="ini/*.*" />
</jar>
</target>
<target name="jar" depends="compile">
<condition property="check_jar_has_been_built">
<available file="${jarfile}"/>
</condition>
<antcall target="buildjar" /> <!-- needed to avoid circular references when invoking tests target -->
<!-- comment out the following line if you only want to run the webtests and not the normal tests -->
<antcall target="tests" />
</target>
<target name="jartests" depends="compiletests">
<jar jarfile="${testjarfile}" update="false">
<fileset dir="${tests.build}">
<include name="**/*.class"/>
</fileset>
<fileset dir="${tests.src}">
<include name="org/**/*.properties"/>
</fileset>
</jar>
</target>
<!-- Signs the JSPWiki JAR file with a self-issued digital certificate.
This should only be needed when your JVM starts with a global security
policy. By this we mean a standard J2SE policy that is set at JVM startup
using the -Djava.security.policy=/some/policy/file VM argument. If this
global policy file contains references to JSPWiki permission classes
(PagePermission, GroupPermission, etc) **and** you set it before JSPWiki
is loaded, **then** you must do four things:
0) run this target (signjar)
1) through 3) see below
-->
<target name="signjar" depends="jar,sign-init" description="Signs jar: for use with global JVM security policies">
<sign-jar jar="${jarfile}" />
<echo>
Congratulations -- you just signed your JAR file. We assume
you did this because you want to create a global security
policy for your entire JVM. That's fine, but please make
sure you configure your JVM (and container) correctly.
Normally, this means you should:
1) Copy ${jarfile} to a place where its classes will be
read at startup. (Example: for Tomcat, this is
$CATALINA_HOME/common/lib)
2) Copy the keystore from ${jks.keystore} to the same
location as your global policy. (Example: Tomcat's
policy is in $CATALINA_HOME/conf/catalina.policy,
so you would copy it to $CATALINA_HOME/conf.)
3) Add a reference to the keystore as the *first* line of
the global policy. It should read
keystore "jspwiki.jks";
... or something similar.
If you have no idea what this is all about, we assume
that you ran this target just for fun. In that case, we
hope you enjoyed the experience.</echo>
</target>
<!-- Builds a Web Archive - basically a JAR file which
also contains all of the JSP pages and can be deployed
as-is.
The archive gets put in the ${install.fulldir}. The
reason for this is that this is just a temporary
step when building the entire distribution archive.
We include the following things:
1) All .jar -files in the lib-directory (except servlet-api.jar
and jsp-api.jar, since these are provided by the servlet
container anyway.
2) All .class-files from the build-directory
3) Everything from the src/webdocs -directory
4) Everything from the etc-directory go to the WEB-INF -directory
of the WAR-file.
-->
<target name="war" depends="installinit,jar,compressedjs"
description="Builds the WAR file for installation.">
<property name="warfile" value="build/${ant.project.name}.war" />
<delete file="${warfile}" />
<war warfile="${warfile}"
webxml="etc/web.xml">
<lib dir="${libs.main}" includes="*.jar" excludes="servlet-api-*.jar jsp-api-*.jar"/>
<lib file="${jarfile}" />
<!--lib file="${libs.tests}/stripes*.jar"/-->
<fileset dir="${code.resources}/webdocs" includes="**" excludes="**/FCK/jsp" />
<webinf dir="etc">
<include name="dtd/**" />
<include name="jsp/**" />
<include name="commons-logging.properties" />
<include name="jspwiki.policy" />
<include name="jspwiki.properties" />
<include name="*.tld" />
<include name="userdatabase.xml" />
<include name="groupdatabase.xml" />
<include name="geronimo-web.xml" />
</webinf>
<classes dir="etc" includes="oscache.properties" />
</war>
<war warfile="${warfile}"
webxml="etc/web.xml" update="true">
<fileset dir="${tmpdir}/compress/webdocs/" includes="**/*.js" />
<fileset dir="${tmpdir}/compress/webdocs/" includes="**/*.css" />
</war>
</target>
<!-- Defines a compression macro for the JS/CSS bits we want to transform
into something that saves a bit of space. -->
<macrodef name="compressjs">
<attribute name="src"/>
<attribute name="args" default=""/>
<sequential>
<java jar="tests/lib/yuicompressor-2.4.7.jar"
output="${tmpdir}/compress/@{src}"
fork="true">
<arg line="'${code.resources}/@{src}' @{args}" />
</java>
</sequential>
</macrodef>
<!-- We compress the Javascript using yahoo's yui compressor,
which compresses both javascript and css files.
If you don't want to use the compressed stuff, just copy the default
.js files from the distro on top of the compressed ones from the WAR.
-->
<target name="compressedjs">
<mkdir dir="${tmpdir}/compress/webdocs/scripts"/>
<compressjs src="webdocs/scripts/jspwiki-common.js"/>
<compressjs src="webdocs/scripts/jspwiki-edit.js"/>
<compressjs src="webdocs/scripts/jspwiki-prefs.js"/>
<compressjs src="webdocs/scripts/jspwiki-commonstyles.js"/>
<compressjs src="webdocs/scripts/prettify.js"/>
<mkdir dir="${tmpdir}/compress/webdocs/templates/default"/>
<compressjs src="webdocs/templates/default/jspwiki.css"
args="--line-break 0" />
<compressjs src="webdocs/templates/default/jspwiki_print.css"
args="--line-break 0" />
<mkdir dir="${tmpdir}/compress/webdocs/templates/default/skins/OrderedList"/>
<compressjs src="webdocs/templates/default/skins/OrderedList/skin.css"
args="--line-break 0" />
<mkdir dir="${tmpdir}/compress/webdocs/templates/default/skins/PlainVanilla"/>
<compressjs src="webdocs/templates/default/skins/PlainVanilla/skin.css"
args="--line-break 0" />
<mkdir dir="${tmpdir}/compress/webdocs/templates/default/skins/PlainVanilla 1024x768"/>
<compressjs src="webdocs/templates/default/skins/PlainVanilla 1024x768/skin.css"
args="--line-break 0" />
<mkdir dir="${tmpdir}/compress/webdocs/templates/default/skins/Smart"/>
<compressjs src="webdocs/templates/default/skins/Smart/skin.css"
args="--line-break 0" />
</target>
<target name="opened-war" depends="war"
description="Creates an opened JSPWiki war hierarchy into the build dir.">
<mkdir dir="${code.build}/${ant.project.name}" />
<unzip src="${warfile}"
dest="${code.build}/${ant.project.name}" />
</target>
<!--
Here goes some nice Ant magic... We build the source
code archive by directly exporting all code from the SVN
repository, and then zipping it to the temporary installation
directory.
NB: You must have the svn command line client available in
your path before you attempt to run this task.
-->
<target name="srczip" depends="installinit"
description="Builds source zip.">
<delete dir="${install.src}" />
<exec executable="svn">
<arg line="export ${svn.repository}/${svn.tag} &quot;${install.src}&quot;"/>
</exec>
<zip zipfile="${release.dir}/${ant.project.name}-src.zip">
<zipfileset dir="${install.src}" prefix="${ant.project.name}-src" />
</zip>
</target>
<!-- Creates a zip of all the core pages. The file which determines
whether a page is a core page or not is found in src/wikipages/.corepages -->
<target name="corepageszip" depends="installinit">
<zip zipfile="${install.fulldir}/${ant.project.name}-corepages_en.zip"
basedir="src/wikipages/en" includesfile="src/wikipages/.corepages">
</zip>
<zip zipfile="${install.fulldir}/${ant.project.name}-corepages_fi.zip"
basedir="src/wikipages/fi" includesfile="src/wikipages/.corepages">
</zip>
<zip zipfile="${install.fulldir}/${ant.project.name}-corepages_de.zip"
basedir="src/wikipages/de">
</zip>
<zip zipfile="${install.fulldir}/${ant.project.name}-corepages_zh_CN.zip"
basedir="src/wikipages/zh_CN">
</zip>
<zip zipfile="${install.fulldir}/${ant.project.name}-corepages_es.zip"
basedir="src/wikipages/es" includesfile="src/wikipages/.corepages">
</zip>
<zip zipfile="${install.fulldir}/${ant.project.name}-corepages_nl.zip"
basedir="src/wikipages/nl">
</zip>
<zip zipfile="${install.fulldir}/${ant.project.name}-corepages_fr.zip"
basedir="src/wikipages/fr">
</zip>
<zip zipfile="${install.fulldir}/${ant.project.name}-corepages_it.zip"
basedir="src/wikipages/it">
</zip>
<zip zipfile="${install.fulldir}/${ant.project.name}-corepages_pt_BR.zip"
basedir="src/wikipages/pt_BR">
</zip>
<!-- Add other languages here -->
</target>
<!-- Creates a full ZIP file of all document files, ignoring any resources
which start with a dot. -->
<target name="documentzip" depends="installinit,javadoc"
description="Creates JSPWiki documentation zipfile">
<zip zipfile="${install.fulldir}/${ant.project.name}-doc.zip">
<zipfileset dir="doc" prefix="doc" excludes="rat/**" />
<zipfileset dir="src/wikipages" prefix="doc/wikipages" excludes="**/.??*" />
</zip>
</target>
<target name="version" depends="jar"
description="Reads the current code base's version string.">
<java outputproperty="jspwiki.version" classname="org.apache.wiki.Release">
<classpath>
<pathelement location="build/JSPWiki.jar"/>
</classpath>
</java>
</target>
<!-- Builds the entire distribution artifacts without checksums and signatures.
We build both the WAR-file and the source zip, then
copy in some useful files and zip the whole thing
into the release directory.
-->
<target name="dist" depends="clean-deps,installinit,srczip,war,corepageszip,documentzip,version"
description="Builds the entire distribution artifacts without checksums and signatures.">
<!-- binary distribution -->
<copy file="ChangeLog" todir="${install.fulldir}" />
<copy file="LICENSE" todir="${install.fulldir}" />
<copy file="NOTICE" todir="${install.fulldir}" />
<copy file="README" todir="${install.fulldir}" />
<copy file="ReleaseNotes" todir="${install.fulldir}" />
<copy file="UPGRADING" todir="${install.fulldir}" />
<copy file="${warfile}" todir="${install.fulldir}" />
<zip zipfile="${release.dir}/${ant.project.name}-${jspwiki.version}-bin.zip">
<zipfileset dir="${install.fulldir}" prefix="${ant.project.name}-bin" />
</zip>
<!-- source distribution -->
<move file="${release.dir}/${ant.project.name}-src.zip"
tofile="${release.dir}/${ant.project.name}-${jspwiki.version}-src.zip"/>
</target>
<!-- Nabbed from solr -->
<macrodef name="sign-artifact" description="Signs an artifact.">
<attribute name="input.file"/>
<attribute name="output.file" default="@{input.file}.asc"/>
<sequential>
<echo>Signing @{input.file} Sig File: @{output.file}</echo>
<exec executable="gpg">
<arg value="--armor"/>
<arg value="--output"/>
<arg value="@{output.file}"/>
<arg value="--detach-sig"/>
<arg value="@{input.file}"/>
</exec>
</sequential>
</macrodef>
<!-- Generate signatures and checksums for the distribution artifacts. -->
<target name="signeddist" depends="dist" description="Generate signatures and checksums for the release artifacts.">
<echo>Generating checksums for the release artifacts.</echo>
<checksum algorithm="MD5" fileext=".md5" format="MD5SUM" forceoverwrite="yes">
<fileset dir="${release.dir}"><include name="*.zip"/></fileset>
</checksum>
<checksum algorithm="SHA" fileext=".sha1" format="MD5SUM" forceoverwrite="yes">
<fileset dir="${release.dir}"><include name="*.zip"/></fileset>
</checksum>
<checksum algorithm="SHA-512" fileext=".sha512" format="MD5SUM" forceoverwrite="yes">
<fileset dir="${release.dir}"><include name="*.zip"/></fileset>
</checksum>
<sequential>
<sign-artifact input.file="${release.dir}/${ant.project.name}-${jspwiki.version}-bin.zip" />
<sign-artifact input.file="${release.dir}/${ant.project.name}-${jspwiki.version}-src.zip" />
</sequential>
</target>
<!-- ============================================================== -->
<!-- Running tests -->
<target name="tests-init" depends="init">
<!-- Build up the /etc directory for testing -->
<delete file="tests/etc/userdatabase.xml" />
<delete file="tests/etc/userdatabase.xml.old" />
<copy file="tests/etc/userdatabase.xml.tmpl" toFile="tests/etc/userdatabase.xml"/>
<delete file="tests/etc/groupdatabase.xml" />
<delete file="tests/etc/groupdatabase.xml.old" />
<copy file="tests/etc/groupdatabase.xml.tmpl" toFile="tests/etc/groupdatabase.xml"/>
<mkdir dir="tests/etc/WEB-INF" />
<!-- Create web.xml files for testing -->
<copy file="${basedir}/etc/web.xml" tofile="${webtests.build}/web.xml.custom" overwrite="true" />
<!-- For web unit tests, turn off SSL (self-signed certs b0rk
the tests) and enable JDBC refs -->
<replace file="${webtests.build}/web.xml.custom"
token="CONFIDENTIAL" value="NONE" />
<replace file="${webtests.build}/web.xml.custom"
token="&lt;!-- REMOVE ME TO ENABLE JDBC DATABASE" value="" />
<replace file="${webtests.build}/web.xml.custom"
token="REMOVE ME TO ENABLE JDBC DATABASE --&gt;" value="" />
<!-- For unit testing, turn on container auth -->
<copy file="${webtests.build}/web.xml.custom"
tofile="${webtests.build}/web.xml.container" overwrite="true" />
<replace file="${webtests.build}/web.xml.container"
token="&lt;!-- REMOVE ME TO ENABLE CONTAINER-MANAGED AUTH" value="" />
<replace file="${webtests.build}/web.xml.container"
token="REMOVE ME TO ENABLE CONTAINER-MANAGED AUTH --&gt;" value="" />
<copy file="${webtests.build}/web.xml.container"
tofile="tests/etc/WEB-INF/web.xml" overwrite="true" />
<!-- Copy the DTDs to the test WEB-INF -->
<mkdir dir="tests/etc/WEB-INF/dtd" />
<copy toDir="tests/etc/WEB-INF/dtd">
<fileset dir="${basedir}/etc/dtd/" />
</copy>
</target>
<!-- This target runs the JUnit tests that are available
under tests/. It generates the test result files
into the ${tests.reports} -directory, one file per
each tested class. The tests are generated in
plain text, but you can easily get XML format results
as well, just by setting the formatter, below.
Only tests that end with "*Test.java" are included.
This is because then you can also use a manual
"AllTests.java" in each directory, as per the JUnit
Cookbook.
This runs the tests in text mode. If you want the
pretty GUI you probably want to write a new target.
If this test fails with a "cannot find task 'junit'"
error, put the junit.jar in your CLASSPATH.
More info http://ant.apache.org/faq.html#delegating-classloader
-->
<target name="tests" depends="tests-init,jartests,tests-db-init" unless="jspwiki.test.skip"
description="Runs the JUnit tests.">
<condition property="check_jar_has_been_built"> <!-- build main jar if it has not been created yet; should -->
<available file="${jarfile}"/> <!-- only happen if this target is invoked directly -->
</condition>
<antcall target="buildjar" />
<junit printsummary="yes" haltonfailure="no" fork="yes" failureproperty="test.failed">
<classpath>
<path refid="path.tests" />
</classpath>
<sysproperty key="jspwiki.tests.auth" value="true" />
<formatter type="plain" />
<formatter type="xml" usefile="yes" />
<batchtest todir="${tests.reports}">
<fileset dir="${tests.src}">
<include name="**/*Test.java" />
<exclude name="**/AllTest*java" />
<include name="**/StressTestSpeed.java" if="tests.stress.enabled"/>
<include name="**/StressTestVersioningProvider.java" if="tests.stress.enabled"/>
<exclude name="org/apache/wiki/web/*.*" />
<exclude name="org/apache/wiki/TranslatorReaderTest*" />
</fileset>
</batchtest>
</junit>
<junitreport todir="${tests.reports}">
<fileset dir="${tests.reports}">
<include name="**/TEST-*.xml" />
</fileset>
<report format="noframes" todir="${tests.reports}" />
</junitreport>
<antcall target="fail-build-if-junit-fails">
<param name="test.failed" value="${test.failed}"/>
</antcall>
</target>
<target name="fail-build-if-junit-fails" unless="continue_even_with_test_failures">
<fail message="Test failure(s) detected, check test results." if="${test.failed}" />
</target>
<target name="tests-auth" depends="jar,tests-init,jartests"
description="Runs the AuthorizationManager tests, with JDPA">
<junit printsummary="yes" haltonfailure="no" fork="yes">
<classpath>
<path refid="path.tests" />
</classpath>
<sysproperty key="jspwiki.tests.auth" value="true" />
<jvmarg value="-Xdebug" />
<jvmarg value="-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y" />
<formatter type="plain" />
<formatter type="xml" usefile="yes" />
<batchtest todir="${tests.reports}">
<fileset dir="${tests.src}">
<include name="**/AuthorizationManagerTest.java" />
</fileset>
</batchtest>
</junit>
<junitreport todir="${tests.resources}">
<fileset dir="${tests.reports}">
<include name="**/TEST-*.xml" />
</fileset>
<report format="noframes" todir="${tests.resources}" />
</junitreport>
</target>
<!-- This target runs web unit tests using Selenium. These tests run
using an enbedded Jetty server running on a hard-coded high port.
The webapps deployed to Jetty contain 2 sample users:
- 'janne' with password 'myP@5sw0rd' and role of 'Authenticated'
- 'admin' with password 'myP@5sw0rd' and roles of 'Authenticated', 'Admin'
These are the same as the test users in tests/org.apache.wiki.auth.Users.
-->
<target name="webtests" depends="jar,tests-init,jartests,war">
<mkdir dir="${webtests.temp}" />
<mkdir dir="${webtests.build}" />
<!-- Create the master jspwiki.properties template for all webtests -->
<copy file="tests/etc/jspwiki.properties"
toFile="${webtests.build}/jspwiki.properties.tmpl" flatten="true" />
<propertyfile file="${webtests.build}/jspwiki.properties.tmpl">
<entry key="jspwiki.authorizer" value="org.apache.wiki.auth.authorize.WebContainerAuthorizer" />
<entry key="jspwiki.userdatabase" value="org.apache.wiki.auth.user.XMLUserDatabase" />
<entry key="jspwiki.groupdatabase" value="org.apache.wiki.auth.authorize.XMLGroupDatabase" />
<entry key="jspwiki.referenceStyle" value="relative" />
<entry key="jspwiki.userdatabase.hashPrefix" value="false" />
<entry key="jspwiki-x.securityconfig.enable" value="true" />
<entry key="jspwiki.login.throttling" value="false" />
</propertyfile>
<!-- Build the custom auth WAR -->
<webtest-setup context="test-custom"
webxml="${webtests.build}/web.xml.custom"/>
<!-- Build the custom auth WAR (absolute URLs) -->
<webtest-setup context="test-custom-absolute"
webxml="${webtests.build}/web.xml.custom">
<propertyfile-entries>
<entry key="jspwiki.referenceStyle" value="absolute" />
<entry key="jspwiki.baseURL" value="http://localhost:${webtests.port}/test-custom-absolute/" />
</propertyfile-entries>
</webtest-setup>
<!-- Build the container auth WAR -->
<webtest-setup context="test-container"
webxml="${webtests.build}/web.xml.container" />
<!-- Build the custom auth WAR (JDBC database) -->
<webtest-setup context="test-custom-jdbc"
webxml="${webtests.build}/web.xml.custom">
<propertyfile-entries>
<entry key="jspwiki.userdatabase" value="org.apache.wiki.auth.user.JDBCUserDatabase" />
<entry key="jspwiki.groupdatabase" value="org.apache.wiki.auth.authorize.JDBCGroupDatabase" />
</propertyfile-entries>
</webtest-setup>
<!-- Build the container auth WAR (JDBC database) and test it -->
<webtest-setup context="test-container-jdbc"
webxml="${webtests.build}/web.xml.container">
<propertyfile-entries>
<entry key="jspwiki.userdatabase" value="org.apache.wiki.auth.user.JDBCUserDatabase" />
<entry key="jspwiki.groupdatabase" value="org.apache.wiki.auth.authorize.JDBCGroupDatabase" />
</propertyfile-entries>
</webtest-setup>
<!-- Run each test in succession -->
<mkdir dir="${webtests.reports}" />
<webtest-exec context="test-custom" />
<webtest-exec context="test-container" />
<webtest-exec context="test-custom-jdbc" />
<webtest-exec context="test-container-jdbc" />
<webtest-exec context="test-custom-absolute" />
<!-- Shut down the embedded Jetty server by sending the shutdown command -->
<echo message="Shutting down Jetty (if it is up)."/>
<get src="http://localhost:${webtests.port}/GO_AWAY/" dest="${webtests.temp}/shutdown.log" ignoreerrors="true" verbose="true" />
<echo>The web unit tests have finished. You can find the test reports in ${webtests.reports}.
If all of the tests ran successfully, the reports will all be "green."</echo>
</target>
<macrodef name="webtest-setup">
<attribute name="context" />
<attribute name="webxml" />
<attribute name="context.dir" default="${webtests.build}/@{context}" />
<attribute name="context.path" default="${basedir}/${webtests.build}/@{context}" />
<element name="propertyfile-entries" implicit="no" optional="true" />
<sequential>
<echo message="===============================================================" />
<echo message=" Setting up web unit tests for '@{context}'" />
<echo message="- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" />
<echo message="" />
<echo message="Creating Selenium test scripts..."/>
<mkdir dir="@{context.dir}/selenium" />
<copy flatten="true" toDir="@{context.dir}/selenium">
<fileset dir="tests/etc/selenium/tests/all" />
<filterset>
<filter token="selenium.context" value="@{context}" />
</filterset>
</copy>
<echo message="Creating test page repositories..."/>
<!-- Create a wiki page directory and point jspwiki.properties to it -->
<mkdir dir="@{context.dir}/wikipages" />
<copy toDir="@{context.dir}/wikipages" flatten="true" >
<fileset dir="src/wikipages/en">
<include name="Main.*" />
<include name="LeftMenu*.*" />
<include name="About.*" />
<include name="RecentChanges.*" />
<include name="WikiEtiquette.*" />
<include name="UnusedPages.*" />
<include name="UndefinedPages.*" />
<include name="PageIndex.*" />
</fileset>
</copy>
<echo message="Creating test webapp..."/>
<mkdir dir="@{context.dir}/webapp/WEB-INF/classes" />
<mkdir dir="@{context.dir}/webapp/WEB-INF/lib" />
<!-- Copy the WEB-INF files -->
<copy toDir="@{context.dir}/webapp/WEB-INF">
<fileset dir="etc">
<include name="dtd/**" />
<include name="commons-logging.properties" />
<include name="jspwiki.policy" />
<include name="*.tld" />
</fileset>
<fileset dir="tests/etc" includes="userdatabase.xml groupdatabase.xml" />
</copy>
<copy toFile="@{context.dir}/webapp/WEB-INF/web.xml" file="@{webxml}" flatten="true" />
<!-- Create the jspwiki.properties file -->
<mkdir dir="@{context.dir}/workdir" />
<copy toFile="@{context.dir}/webapp/WEB-INF/jspwiki.properties"
file="${webtests.build}/jspwiki.properties.tmpl" flatten="true" />
<propertyfile file="@{context.dir}/webapp/WEB-INF/jspwiki.properties">
<entry key="jspwiki.baseURL" value="http://localhost:${webtests.port}/@{context}/" />
<entry key="jspwiki.workDir" value="@{context.path}/workdir" />
<entry key="jspwiki.fileSystemProvider.pageDir" value="@{context.path}/wikipages" />
<entry key="jspwiki.basicAttachmentProvider.storageDir" value="@{context.path}/wikipages" />
<entry key="jspwiki.xmlUserDatabaseFile" value="@{context.path}/webapp/WEB-INF/userdatabase.xml" />
<entry key="jspwiki.xmlGroupDatabaseFile" value="@{context.path}/webapp/WEB-INF/groupdatabase.xml" />
<entry key="log4j.appender.FileLog.File" value="@{context.path}/jspwiki.log" />
<propertyfile-entries/>
</propertyfile>
<!-- Copy the classes -->
<copy toDir="@{context.dir}/webapp/WEB-INF/classes">
<fileset dir="etc" includes="oscache.properties" />
</copy>
<!-- Copy the libraries -->
<copy toDir="@{context.dir}/webapp/WEB-INF/lib">
<fileset dir="lib" includes="*.jar" excludes="servlet-api-*.jar jsp-api-*.jar" />
<fileset file="${jarfile}"/>
<fileset file="${jdbc.driver.jar}"/>
</copy>
<!-- Copy the JSPs -->
<copy toDir="@{context.dir}/webapp">
<fileset dir="${code.resources}/webdocs" includes="**" />
</copy>
</sequential>
</macrodef>
<!-- ============================================================== -->
<!-- Selenium execution test task -->
<!-- This macro executes the Selenium test plans located in
tests/build/selenium/@context@/, based on templates stored
in tests/etc/selenium/tests. It expects your favorite servlet
container up & running on ${tomcat.protocol}://${tomcat.host}:${tomcat.port}
For this reason, these properties must be set up in your
build.properties file.
-->
<macrodef name="webtest-exec">
<attribute name="context"/>
<sequential>
<!-- If already running, shut down the embedded Jetty server by sending the shutdown command -->
<echo message="Shutting down Jetty (if it is up)."/>
<get src="http://localhost:${webtests.port}/GO_AWAY/" dest="${webtests.temp}/shutdown.log" ignoreerrors="true" verbose="true" />
<sleep seconds="3"/>
<!-- Start Jetty with our test context -->
<echo message="Starting Jetty."/>
<java classname="org.apache.wiki.web.StreamRedirector" fork="true" spawn="true">
<!--java classname="org.apache.wiki.web.TestContainer" fork="true" spawn="true"-->
<arg value="org.apache.wiki.web.TestContainer"/>
<arg value="/tmp/jetty-redirectedoutput.log"/>
<!--jvmarg value="-Dlog4j.debug=yesplease"/--> <!-- to enable log4j debugging-->
<jvmarg value="-Dorg.eclipse.jetty.LEVEL=info"/> <!-- to enable jetty debugging-->
<classpath>
<path refid="path.tests" />
</classpath>
<sysproperty key="java.io.tmpdir" value="${webtests.temp}" />
<!--
<jvmarg value="-Xdebug" />
<jvmarg value="-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n" />
-->
<arg line="@{context}=${webtests.build}/@{context}/webapp" />
</java>
<!-- Start Selenium tests -->
<echo message="Running web unit tests for context '@{context}'."/>
<java jar="${selenium-rc.jar}" fork="true"
output="${webtests.build}/@{context}/selenium/selenium.log">
<!--
<arg line="-browserSessionReuse" />
<arg line="-log" />
<arg line="${webtests.reports}/@{context}.selenium.log" />
-->
<arg line="-htmlSuite" />
<arg line='"${webtests.browser}"' />
<arg line='"http://localhost:${webtests.port}"' />
<!-- pre-filtered TestSuite.htmlin tests/etc/selenium/tests/all -->
<arg line="${basedir}/${webtests.build}/@{context}/selenium/TestSuite.html" />
<arg line="${webtests.reports}/@{context}.html" />
</java>
</sequential>
</macrodef>
<!-- ============================================================== -->
<!-- Targets for signing JAR files -->
<!-- These targets collectively create a Java keystore for signing,
and automate the jar-signing process.
-->
<target name="sign-init" depends="installinit,jks-init,jks-create,jks-password" />
<target name="jks-init">
<property name="jks.alias" value="jspwiki" />
<available file="${jks.keystore}" property="jks.exists" />
</target>
<target name="jks-create" unless="jks.exists">
<echo>
JSPWiki needs a digital certificate for code signing its JAR files.
Since you don't appear to have one, we need to generate a new certificate.
Once generated, it will be used to sign the JSPWiki.jar file. To create
the certificate, we need to ask you for your name and a few other things.
The certificate file will be generated at: ${jks.keystore}.
You should copy this file to your container's configuration directory,
or wherever your jspwiki.policy file lives.
If something in this process goes wrong, you can simply delete
${jks.keystore} and execute this target again... no harm done.
To automate the JAR signing processs, you can add the property
'jks.password' to your build.properties file.
</echo>
<input message="Your name (example: Simon Bar Sinister):" addproperty="jks.cn" />
<input message="Your organization (example: ecyrd.com):" addproperty="jks.o" />
<input message="Your country (example: US, FI, AU):" addproperty="jks.c" />
<input message="Keystore password (>6 characters):" addproperty="jks.password" />
<exec dir="${basedir}" executable="keytool" failonerror="true">
<arg value="-genkey"/>
<arg value="-keysize"/>
<arg value="1024"/>
<arg value="-alias"/>
<arg value="${jks.alias}"/>
<arg value="-keystore"/>
<arg value="${jks.keystore}"/>
<arg value="-storepass"/>
<arg value="${jks.password}"/>
<arg value="-dname"/>
<arg value="cn=${jks.cn}, ou=JSPWiki Code Signing Division, o=${jks.o}, c=${jks.c}"/>
</exec>
</target>
<target name="jks-password" unless="jks.password">
<input message="Keystore password:" addproperty="jks.password" />
</target>
<macrodef name="sign-jar">
<attribute name="jar"/>
<sequential>
<echo message="Signing code with this certificate: ${jks.keystore}" />
<exec dir="${basedir}" executable="keytool" failonerror="true">
<arg value="-list"/>
<arg value="-v"/>
<arg value="-alias"/>
<arg value="${jks.alias}"/>
<arg value="-keystore"/>
<arg value="${jks.keystore}"/>
<arg value="-storepass"/>
<arg value="${jks.password}"/>
</exec>
<signjar jar="@{jar}" alias="jspwiki" keystore="${jks.keystore}"
storepass="${jks.password}" verbose="false"/>
</sequential>
</macrodef>
<!-- ============================================================== -->
<!-- JDBC Support -->
<!-- Starting with 2.3.33, JSPWiki supports JDBC DataSources for
storing user profiles. The DataSource can be any database that
your web container supports. In practice, most containers supply
a generic datatbase connection pooling package that can be configured
to use any JDBC driver.
RUNNING JDBC UNIT TESTS
=======================
If you don't enable JDBC support, the JDBC-related unit test classes
will compile fine, but will fail when the 'tests' Ant target executes.
Don't worry about that. The JDBC-related test classes, by the way,
are these:
org.apache.wiki.auth.user.JDBCUserDatabaseTest
To run JDBC-related unit tests, you need to:
1) Set up an external database
2) Obtain a JDBC driver
3) Tell JSPWiki where to find the driver, and how to
connect to the database, via jdbc.* properties in
your build.properties file.
4) Provide table setup/teardown DDL scripts (executed by
the db-setup and db-teardown targets, below)
Step 1 is the hardest. Luckily for you, JSPWiki has built-in Ant
scripts to automatically start and stop the embedded Hypersonic 100%
Java database. It's small and fast, and is included
in the JSPWiki base distribution. You can, of course, use your own
JDBC-compliant database such as Postgresql.
Step 2: If desired, modify the database properties in
tests/etc/jdbc.properties.impl. The defaults given should be sufficient
for JDBC testing using hsql on any developer's local machine.
The 'jdbc.driver.id' property in this file (defaulted to hsql) is
important. Its presence tells the Ant scripts to do JDBC testing.
It also points to the subdirectory in etc/db that contains our
setup/teardown scripts, which *must* contain these files at a minimum:
userdb-setup.ddl
userdb-teardown.ddl
Sample scripts for Hypersonic and Postgresql are supplied.
If you want to use a different database, create a subdirectory in etc/db
(e.g., etc/db/oracle) and create the necessary DDL script files.
Note that the DDL scripts contain token substitution fields where
table and column names mappings can be plugged in. This is so you
can customize how JSPWiki stores its data. For example, the Hypersonic
teardown DDL looks like this:
DROP TABLE @jspwiki.userdatabase.table@ IF EXISTS;
The complete list of customizable table properties are found
in etc/jspwiki.properties.tmpl. If you don't customize them,
JSPWiki will use some sensible defaults. For unit testing purposes,
this script will always use the defaults from 'tests/etc/jspwiki.properties',
then apply any custom properties defined in your build.properties file.
All of this may sound complicated, but it really isn't. If you use Hypersonic,
the JDBC tests should Just Work. And if you specify an external database,
they should work just fine also.
RUNNING JSPWIKI WITH JDBC SUPPORT
=================================
All of the preceding tells you how to test JSPWiki with JDBC support.
Sounds great, but how do you *run* JSPWiki with it? Simple:
1) Configure the Jdbc.* properties in the build.properties file
2) Configure table and column mappings in etc/jspwiki.properties.tmpl
3) Configure your web container to create a JDBC DataSource
(by default, the JNDI name is jdbc/UserDatabase)
4) Put the JDBC driver jar in a place where your web container will
find it, for example CATALINA_HOME/common/lib
5) Build JSPWiki, and start it up!
See the Javadoc for org.apache.wiki.auth.user.JDBCUserDatabase
for details and examples.
-->
<target name="tests-db-init" depends="db-properties"/>
<target name="db-properties" depends="init" if="jdbc.driver.id">
<!-- Check for the presence of the database driver & script dir -->
<check-file file="etc/db/${jdbc.driver.id}" prop="db.scripts" />
<check-file file="${jdbc.driver.jar}" prop="jdbc.jar.present" />
<!-- Bulk-copy the table setup/teardown scripts -->
<property name="tests.db.scripts" value="${tests.resources}/etc/db/${jdbc.driver.id}" />
<mkdir dir="${tests.db.scripts}" />
<copy toDir="${tests.db.scripts}" overwrite="true">
<fileset dir="${db.scripts}" />
<filterset>
<filtersfile file="tests/etc/jspwiki.properties" />
<filtersfile file="build.properties" />
</filterset>
</copy>
<!-- Check if the customized database scripts exist -->
<check-file file="${tests.db.scripts}/userdb-setup.ddl" prop="userdb.setup" />
<check-file file="${tests.db.scripts}/userdb-teardown.ddl" prop="userdb.teardown" />
<!-- If it's the Hypersonic database, set a special flag -->
<condition property="hsql">
<equals arg1="${jdbc.driver.id}" arg2="hsql" />
</condition>
<!-- Set a flag that says all of our pre-conditions are met! -->
<property name="db.props.exist" value="true" />
<!-- Copying the testing jdbc.properties file -->
<copy file="${tests.resources}/etc/jdbc.properties.tmpl" toFile="${tests.resources}/etc/db/jdbc.properties" overwrite="true"/>
</target>
<!-- Some convenience macrodefs -->
<macrodef name="check-property">
<attribute name="prop"/>
<sequential>
<fail unless="@{prop}" message="Property @{prop} is required." />
</sequential>
</macrodef>
<macrodef name="check-file">
<attribute name="file" />
<attribute name="prop" />
<sequential>
<available file="@{file}" property="@{prop}" value="@{file}" />
<fail unless="@{prop}" message="Couldn't find @{file}!" />
</sequential>
</macrodef>
<!-- ============================================================== -->
<target name="i18n-create-template" description="Creates a given directory structure with all the needed files to make an i18n jar">
<input message="i18n template code to generate (ie: es_ES):" addproperty="i18n.template" />
<mkdir dir="${tmplt.i18n.dir}/${ant.project.name}_${i18n.template}/etc/i18n/templates" />
<mkdir dir="${tmplt.i18n.dir}/${ant.project.name}_${i18n.template}/etc/i18n/plugin" />
<copy file="etc/i18n/CoreResources.properties"
tofile="${tmplt.i18n.dir}/${ant.project.name}_${i18n.template}/etc/i18n/CoreResources_${i18n.template}.properties"
overwrite="true"/>
<copy file="etc/i18n/templates/default.properties"
tofile="${tmplt.i18n.dir}/${ant.project.name}_${i18n.template}/etc/i18n/templates/default_${i18n.template}.properties"
overwrite="true"/>
<copy file="etc/i18n/plugin/PluginResources.properties"
tofile="${tmplt.i18n.dir}/${ant.project.name}_${i18n.template}/etc/i18n/plugin/PluginResources_${i18n.template}.properties"
overwrite="true" />
<echo message="Now you can start translating at ${tmplt.i18n.dir}/${ant.project.name}_${i18n.template}." />
<echo message="When finished, execute i18n-jar-template target to jar it" />
</target>
<target name="i18n-jar-template" description="Jars a given i18n directory structure">
<input message="i18n template code to jar (ie: es_ES):" addproperty="i18n.template" />
<jar jarfile="${code.build}/${ant.project.name}_${i18n.template}.jar">
<fileset dir="${tmplt.i18n.dir}/${ant.project.name}_${i18n.template}" includes="**/*.properties" />
</jar>
<echo message="Created ${code.build}/${ant.project.name}_${i18n.template}.jar. Drop it on your web/WEB-INF/lib folder and that should do the i18n trick" />
<echo message="You can also upload the jar to http://jspwiki.org/wiki/ContributedLocalizations or to any page linked to it to make it available for everyone!" />
</target>
<target name="i18n-clean-templates" description="Deletes all i18n directory structures">
<delete dir="${tmplt.i18n.dir}" />
</target>
<target name="i18n-check" depends="compile,compiletests"
description="Run this target to check whether a translation is up to date.">
<input message="Please give the language you want to check translation for (e.g. fi, es, de)"
addproperty="check.language"/>
<java classname="org.apache.wiki.TranslationsCheck">
<classpath path="${tests.build}"/>
<classpath path="${code.build}"/>
<arg line="${check.language}"/>
</java>
</target>
<target name="api-diff" description="Compares API in JSPWiki.jar with previous version"
depends="jar">
<!-- Assumes that the dependencyfinder.dir property points to the
dir containing the binary distribution of DependencyFinder -->
<check-property prop="dependencyfinder.dir" />
<check-property prop="jarfile.old" />
<mkdir dir="${tests.reports}" />
<java classname="com.jeantessier.dependencyfinder.cli.JarJarDiff"
output="${tests.reports}/API-changes.xml">
<classpath refid="path.tests" />
<classpath>
<pathelement location="${dependencyfinder.dir}/lib/DependencyFinder.jar" />
</classpath>
<arg value="-new" />
<arg value="${jarfile}" />
<arg value="-old" />
<arg value="${jarfile.old}" />
<arg value="-name" />
<arg value="JSPWiki Public API Changes" />
</java>
<!-- Filthy hack that suppresses DTD resolution -->
<replace file="${tests.reports}/API-changes.xml"
token='&lt;!DOCTYPE differences SYSTEM "http://depfind.sourceforge.net/dtd/differences.dtd"&gt;'
value=""/>
<!-- Just to be safe, replace raw ampersands with something bogus -->
<replace file="${tests.reports}/API-changes.xml"
token="&amp;" value="(ampersand)"/>
<xslt in="${tests.reports}/API-changes.xml"
out="${tests.reports}/API-changes.html"
style="${dependencyfinder.dir}/etc/DiffToHTML.xsl">
</xslt>
</target>
<target name="coverage-tests" depends="compile,tests">
<!-- delete previous info, if any -->
<delete file="cobertura.ser" />
<delete dir="${tests.build}/instrumented-classes" />
<!-- bootstrap cobertura ant-tasks -->
<taskdef classpathref="path.optional" resource="tasks.properties" />
<cobertura-instrument todir="${tests.build}/instrumented-classes">
<fileset dir="${code.build}">
<include name="**/*.class"/>
</fileset>
</cobertura-instrument>
<junit haltonfailure="no" fork="yes">
<classpath>
<path location="${tests.build}/instrumented-classes" />
<path refid="path.optional" />
</classpath>
<formatter type="xml" />
<sysproperty key="jspwiki.tests.auth" value="true" />
<batchtest todir="${tests.reports}">
<fileset dir="${tests.src}">
<include name="**/*Test.java" />
<exclude name="**/AllTest*java" />
<include name="**/StressTestSpeed.java" if="tests.stress.enabled"/>
<exclude name="org/apache/wiki/web/*.*" />
<exclude name="org/apache/wiki/TranslatorReaderTest*" />
</fileset>
</batchtest>
</junit>
</target>
<target name="coverage-reports" depends="coverage-tests,version">
<cobertura-report srcdir="${code.src}" destdir="${tests.build}/cobertura" />
</target>
<target name="sonar-bootstrap" depends="clean" description="sonar ant task build configuration">
<!-- bootstrap sonar ant tasks -->
<typedef resource="org/sonar/ant/antlib.xml"
uri="antlib:org.sonar.ant"
classpathref="path.optional" />
<!-- list of Sonar project configuration properties -->
<property name="sonar.projectKey" value="org.apache.jspwiki:jspwiki" />
<property name="sonar.projectName" value="Apache JSPWiki (incubating)" />
<property name="sonar.projectVersion" value="${jspwiki.version}" />
<property name="sonar.sources" value="${code.src}" />
<property name="sonar.scm.url" value="scm:svn:http://svn.apache.org/repos/asf/incubator/jspwiki/trunk/" />
<!-- list of optional Sonar properties -->
<property name="sonar.binaries" value="${code.build}" />
<property name="sonar.tests" value="${tests.resources}" />
<!-- list of advanced properties -->
<property name="sonar.core.codeCoveragePlugin" value="cobertura"/>
<property name="sonar.surefire.reportsPath" value="./tests/reports" />
<property name="sonar.cobertura.reportPath" value="${tests.build}/cobertura/coverage.xml" />
<property name="sonar.dynamicAnalysis" value="reuseReports" />
<!-- Used by PMD only -->
<property name="sonar.java.source" value="1.6" />
<property name="sonar.java.target" value="1.6" />
<!-- other interesting properties that can be overriden -->
<!-- <property name="sonar.jdbc.driverClassName" value="org.apache.derby.jdbc.ClientDriver" /> -->
<!-- <property name="sonar.jdbc.username" value="sonar" /> -->
<!-- <property name="sonar.jdbc.password" value="sonar" /> -->
<!-- <property name="sonar.jdbc.url" value="jdbc:derby://localhost:1527/sonar" /> -->
<!-- <property name="sonar.host.url" value="http://localhost:9000" /> -->
<!-- don't break the build if there are test failures -->
<property name="continue_even_with_test_failures" value="true" />
</target>
<target name="sonar" depends="sonar-bootstrap,coverage-tests,version">
<!-- Sonar needs an xml type cobertura report -->
<cobertura-report format="xml"
srcdir="${code.src}"
destdir="${tests.build}/cobertura" />
<sonar:sonar xmlns:sonar="antlib:org.sonar.ant"/>
</target>
<target name="rat-report" description="Generate an Apache Rat report.">
<mkdir dir="${doc.rat}/lib" />
<get-element to-file="${doc.rat}/lib/apache-rat-tasks-0.8.jar"
url="${central.url}/org/apache/rat/apache-rat-tasks/0.8/apache-rat-tasks-0.8.jar" />
<get-element to-file="${doc.rat}/lib/apache-rat-core-0.8.jar"
url="${central.url}/org/apache/rat/apache-rat-core/0.8/apache-rat-core-0.8.jar" />
<get-element to-file="${doc.rat}/lib/commons-cli-1.2.jar"
url="${central.url}/commons-cli/commons-cli/1.2/commons-cli-1.2.jar" />
<get-element to-file="${doc.rat}/lib/commons-collections-3.2.jar"
url="${central.url}/commons-collections/commons-collections/3.2/commons-collections-3.2.jar" />
<get-element to-file="${doc.rat}/lib/commons-lang-2.1.jar" url="${central.url}/commons-lang/commons-lang/2.1/commons-lang-2.1.jar" />
<get-element to-file="${doc.rat}/lib/commons-compress-1.0.jar"
url="${central.url}/org/apache/commons/commons-compress/1.0/commons-compress-1.0.jar" />
<get-element to-file="${doc.rat}/lib/commons-io-1.4.jar" url="${central.url}/commons-io/commons-io/1.4/commons-io-1.4.jar" />
<path id="rat.libs.path">
<fileset dir="${doc.rat}/lib">
<include name="*.jar" />
</fileset>
</path>
<taskdef resource="org/apache/rat/anttasks/antlib.xml">
<classpath refid="rat.libs.path" />
</taskdef>
<!-- If you want the RAT run to automatically add license headers where needed, set addLicenseHeaders="true".
However, afterwards, you will have to manually double-check every single modified file regarding the
ASF Source Header and Copyright Notice Policy!
Exclusions and their reasons:
- .* and .*/** are automatically created configuration files
- doc/LICENSE.* are third-party licenses
- ${code.src}/wikipages/** are default wiki pages for use in JSPWiki installations
- all others are directories which contain generated output and third-party binary libraries
-->
<report reportFile="${doc.rat}/rat-report.txt" addLicenseHeaders="false">
<fileset dir="."
excludes=".*, .*/**,
doc/LICENSE.*,
${code.resources}/wikipages/**,
${code.build}/**,
${tests.build}/**,
${tests.reports}/**,
${doc.rat}/**,
${libs.main}/**,
${libs.tests}/**,
${libs.opt}/**,
${docs.javadoc}/**,
${release.dir}/**" />
<!--
<fileset dir="src/org"/>
<fileset dir="src/webdocs"
excludes="**/SilkIconSet-readme.txt,**/fckconfig.js,**/mootools.js,**/posteditor.js" />
<fileset dir="tests/org"/>
-->
</report>
</target>
</project>