| <!-- |
| JSPWiki - a JSP-based WikiWiki clone. |
| |
| 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 |
| | |___WebContent |
| | | |___[all .jsp files] |
| | | |
| | |___java |
| | |___[...and the rest of the source code files] |
| | |
| |___docs |
| | |
| |___tests |
| |___java |
| |___[...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 source code lies. --> |
| <property name="code.src" value="src/java" /> |
| |
| <!-- Denotes where all the stuff that goes into the webapp dir lives --> |
| <property name="code.web" value="src/WebContent" /> |
| |
| <!-- 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="build" location="build" /> |
| <property name="code.build" value ="${build}/classes" /> |
| |
| <!-- The internationalization strings for the core JSPWiki classes --> |
| <property name="code.i18n" value="${code.web}/WEB-INF/classes" /> |
| <!-- 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="${build}/${ant.project.name}.jar" /> |
| |
| <!-- Define a temporary directory, based on the system temporary directory, |
| the user name, and the project name (defined above) --> |
| <property name="tmpdir" value="${java.io.tmpdir}/${user.name}/${ant.project.name}" /> |
| |
| <!-- The following properties define the location of the |
| test resources, the location of the sources, the location of the .class files and the |
| directory where the test results are written in. --> |
| |
| <property name="tests" value="tests" /> |
| <property name="tests.src" value="${tests}/java" /> |
| <property name="tests.build" value="${build}/tests/classes" /> |
| <property name="tests.classpath" value="${build}/tests/classpath" /> |
| <property name="tests.webinf" value="${tests.classpath}/WEB-INF" /> |
| <property name="tests.db" value="${build}/tests/db" /> |
| <property name="tests.ldap" value="${build}/tests/ldap" /> |
| <property name="tests.pagedir" value="${build}/tests/priha" /> |
| <property name="tests.reports" value="${build}/tests/reports" /> |
| <property name="tests.workdir" value="${build}/tests/workdir" /> |
| <available property="openldap" file="/usr/libexec/slapd" value="/usr/libexec/slapd" /> |
| |
| <!-- The location of the JAR file for the test classes --> |
| <property name="testjarfile" location="${build}/${ant.project.name}-tests.jar" /> |
| |
| <!-- WAR properties --> |
| <property name="warfile" value="${build}/${ant.project.name}.war" /> |
| <condition property="war.compile.jsps"> |
| <equals arg1="${compile.jsps}" arg2="true" casesensitive="false" trim="true" /> |
| </condition> |
| <property name="war.build" value="${build}/war" /> |
| |
| |
| <!-- Web unit test properties --> |
| <property name="webtests.browser" value="*firefox" /> |
| <property name="webtests.build" value="${build}/webtests" /> |
| <property name="webtests.reports" value="${webtests.build}/reports" /> |
| <property name="webtests.port" value="10024" /> |
| <property name="webtests.shutdown" value="19041" /> |
| <property name="webtests.temp" value="${java.io.tmpdir}/webtests" /> |
| <property name="selenium-rc.jar" value="${tests}/lib/selenium-server-1.0b2.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="trunk" /> |
| |
| <!-- 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="${code.web}/WEB-INF/lib"> |
| <include name="*.jar" /> |
| </fileset> |
| </path> |
| |
| <!-- The path used for running tests. We add the tests.classpath directory |
| to the base path defined above, since we put all the relevant |
| .properties-files there. --> |
| <path id="path.tests"> |
| <pathelement location="${jarfile}" /> |
| <pathelement location="${testjarfile}" /> |
| <pathelement location="${java.home}/../lib/tools.jar" /> |
| <fileset dir="${code.web}/WEB-INF/lib"> |
| <include name="*.jar" /> |
| </fileset> |
| <fileset dir="${tests}/lib"> |
| <include name="*.jar" /> |
| </fileset> |
| <pathelement path="${code.i18n}"/> |
| <pathelement path="${tests.classpath}" /> |
| </path> |
| |
| <!-- The prefix to use when reading environment variables --> |
| <property environment="env" /> |
| |
| |
| <!-- ============================================================== --> |
| |
| <!-- Initialising, cleaning, etc. --> |
| |
| <target name="init" |
| description="Initializes everything, creates directories, etc."> |
| <mkdir dir="${code.build}" /> |
| </target> |
| |
| <!-- Removes the build directory and the tests build directory --> |
| <target name="clean" |
| description="Cleans away all generated files."> |
| <delete dir="${build}" /> |
| <mkdir dir="${tests.classpath}" /> |
| <delete> |
| <fileset dir="." includes="**/*~" defaultexcludes="no"/> |
| <fileset dir="." includes="**/#*#" defaultexcludes="no"/> |
| </delete> |
| </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.5" |
| target="1.5" |
| > |
| <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}" |
| destdir="${tests.build}" |
| debug="true" |
| deprecation="${deprecation}" |
| source="1.5" |
| target="1.5" |
| > |
| <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://java.sun.com/j2se/1.5.0/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/"/> |
| <link href="http://stripes.sourceforge.net/docs/current/javadoc/"/> |
| <classpath refid="path.base" /> |
| </javadoc> |
| |
| </target> |
| |
| <!-- ============================================================== --> |
| |
| <!-- This target migrates Stripes JSPs --> |
| |
| <target name="migrate" depends="jar,jartests"> |
| <mkdir dir="build/migrated" /> |
| <pathconvert property="cp" refid="path.tests"/> |
| <path id="srcfiles"> |
| <fileset dir="src" includes="**/*.java" excludes="**/NoneActionBean.java" /> |
| </path> |
| <pathconvert property="srcfiles" refid="srcfiles" pathsep=" "/> |
| <!-- Generate the Stripes SiteStructure doc --> |
| <exec executable="apt"> |
| <arg line="-classpath ${cp} -nocompile"/> |
| <arg line="-factory net.sourceforge.stripes.tools.SiteStructureTool"/> |
| <arg line="-Astripes.output.file=build/sitemap.xml"/> |
| <arg line="${srcfiles}"/> |
| </exec> |
| <!-- Migrate the JSPs --> |
| <java classname="org.apache.wiki.ui.migrator.JspMigrator" fork="yes" maxmemory="512m"> |
| <classpath> |
| <path refid="path.tests" /> |
| </classpath> |
| <arg value="${code.web}" /> |
| <arg value="build/migrated" /> |
| <sysproperty key="stripes.migrator.migrateForms" value="${stripes.migrator.migrateForms}" /> |
| </java> |
| </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}" /> |
| <delete quiet="true"> |
| <fileset dir="${war.build}" includes="JSPWiki-jsp.jar,jasper-runtime-*.jar,commons-el-*.jar,web-fragment.xmlf,web.xml"/> |
| </delete> |
| </target> |
| |
| <!-- Builds the jar of all compiled class files --> |
| |
| <target name="jar" depends="compile"> |
| <!-- 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}" index="true"> |
| <fileset dir="${code.build}" includes="**/*.class" /> |
| <fileset dir="${code.src}" includes="org/**/*.properties" /> |
| <!--fileset dir="${code.src}" includes="templates/**/*.properties" /--> |
| <fileset dir="etc" includes="ini/*.xml ini/*.properties" /> |
| <metainf dir="${code.web}/WEB-INF" includes="jspwiki.tld" /> |
| </jar> |
| </target> |
| |
| <target name="jartests" depends="compiletests"> |
| <jar jarfile="${testjarfile}" update="false" index="true"> |
| <fileset dir="${tests.build}"> |
| <include name="**/*.class"/> |
| </fileset> |
| <fileset dir="${tests}"> |
| <include name="com/**/*.properties"/> |
| </fileset> |
| </jar> |
| </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,jar-compiled-jsps,compressedjs" |
| description="Builds the WAR file for installation."> |
| |
| <!-- Build war.xml and the classes/properties files --> |
| <copy toDir="${war.build}" overwrite="true"> |
| <fileset dir="etc"> |
| <include name="jspwiki.properties" /> |
| <include name="log4j.properties" /> |
| <include name="priha.properties" /> |
| </fileset> |
| <filterset> |
| <filtersfile file="${build.properties}" /> |
| </filterset> |
| </copy> |
| <copy file="${code.web}/WEB-INF/web.xml" toFile="${war.build}/web.xml" overwrite="false" /> |
| |
| <!-- Build the actual WAR file --> |
| <delete file="${warfile}" /> |
| <war destfile="${warfile}" |
| webxml="${war.build}/web.xml" duplicate="preserve"> |
| <lib file="${jarfile}" /> |
| <lib file="${war.build}/JSPWiki-jsp.jar" /> |
| <lib file="${war.build}/jasper-runtime-*.jar" /> |
| <lib file="${war.build}/commons-el-*.jar" /> |
| <classes dir="${war.build}"> |
| <include name="log4j.properties" /> |
| <include name="priha.properties" /> |
| </classes> |
| <fileset dir="${tmpdir}/compress/webdocs/" includes="**/*.js" /> |
| <fileset dir="${tmpdir}/compress/webdocs/" includes="**/*.css" /> |
| <fileset dir="${code.web}" includes="**" excludes="**/servlet-api.jar **/jsp-api.jar WEB-INF/web.xml WEB-INF/jspwiki.tld" /> |
| <webinf dir="${war.build}" includes="jspwiki.properties" /> |
| </war> |
| <copy file="${warfile}" toDir="${install.fulldir}" /> |
| </target> |
| |
| <!-- Builds a JAR file that contains pre-compiled JSPs for use |
| with a web container. Pre-compilation involves three steps: |
| 1) Generating the .java files that correspond to JSPWiki's JSPs. |
| The generated classes are actually servlets. |
| 2) Compiling the .java files and creating a jar.file, |
| which is added to the WAR's WEB-INF/lib directory |
| 3) Injecting servlet mappings into the WEB-INF/web.xml |
| file so that requests for the JSPs are mapped to the |
| servlets generated in step 1. |
| |
| Precompiling jsp's immensely speeds up web unit tests. |
| We still copy the source jsp's into the war because TemplateManager |
| depends on it. |
| |
| To use JSP pre-compilation, set the "compile.jsps" |
| property in build.properties to "true". |
| |
| --> |
| <target name="jar-compiled-jsps" depends="jar" if="war.compile.jsps"> |
| <taskdef classname="org.apache.jasper.JspC" name="jasper2"> |
| <classpath> |
| <path refid="path.base" /> |
| <path refid="path.tests" /> |
| </classpath> |
| </taskdef> |
| <!-- Generate Java source for each JSP --> |
| <mkdir dir="${war.build}/java" /> |
| <jasper2 |
| validateXml="false" |
| uriroot="${code.web}" |
| outputDir="${war.build}/java" |
| poolingEnabled="false" |
| package="org.apache.wiki.jsp" |
| webXmlFragment="${war.build}/web-fragment.xmlf" /> |
| <!-- Compile the generated Java sources --> |
| <mkdir dir="${war.build}/classes"/> |
| <javac srcdir="${war.build}/java" destdir="${war.build}/classes"> |
| <classpath> |
| <path refid="path.base" /> |
| <path refid="path.tests" /> |
| </classpath> |
| </javac> |
| <!-- Inject JSP mappings into web.xml --> |
| <echo message="Adding JSP servlet mappings to web.xml" /> |
| <loadfile property="generated-web.xml" srcFile="${war.build}/web-fragment.xmlf"/> |
| <copy file="${code.web}/WEB-INF/web.xml" toFile="${war.build}/web.xml" overwrite="true"> |
| <filterset begintoken="<!--" endtoken="-->"> |
| <filter token=" PLACEHOLDER FOR PRE-COMPILED JSP SERVLETS " value="${generated-web.xml}" /> |
| </filterset> |
| </copy> |
| <!-- Jar up the compiled class files --> |
| <jar jarfile="${war.build}/JSPWiki-jsp.jar" index="true"> |
| <fileset dir="${war.build}/classes" includes="**/*.class" /> |
| </jar> |
| <!-- Copy the Jasper runtime JAR --> |
| <copy toDir="${war.build}"> |
| <fileset dir="${tests}/lib" includes="jasper-runtime-*.jar"/> |
| <fileset dir="${tests}/lib" includes="commons-el-*.jar"/> |
| </copy> |
| </target> |
| |
| <!-- Defines a compression macro for the JS/CSS bits we want to transform |
| into something that saves a bit of space. |
| |
| The inputstring="" is required because Ant messes up the input streams |
| for any later exec() invocations otherwise (like running gpg signing). |
| --> |
| |
| <macrodef name="compressjs"> |
| <attribute name="src"/> |
| <attribute name="args" default=""/> |
| <sequential> |
| <java jar="${tests}/lib/yuicompressor-2.4.2.jar" |
| output="${tmpdir}/compress/webdocs/@{src}" |
| fork="true" |
| inputstring=""> |
| <arg line="'${code.web}/@{src}' @{args}" /> |
| </java> |
| </sequential> |
| </macrodef> |
| |
| <!-- Generates a tarball containing all of JSPWiki's static |
| content. This is quite handy for environments that use |
| JSPWiki in conjunction with a front-end web server such |
| as Apache (via mod_jk/jk2 or mod_proxy). The target strips |
| out the static content (images, css, etc) and adds it to |
| a separate tar file that can be unpacked in one of |
| Apache's content directories. |
| |
| To generate static content, set the properties |
| "static.user" and "static.group" in build.properties. |
| These should be set to the Unix runtime user and group |
| that should own the static files, for example the |
| user "apache" and "daemon" group. |
| |
| If not present, the target is skipped. |
| File permissions are owner and group read (440), |
| and for directories, owner and group read |
| and execute (550). |
| --> |
| |
| <target name="staticzip" depends="war" if="static.user"> |
| <property name="static.group" value="${static.user}" /> |
| <tar destfile="${build}/${tar.static}" longfile="fail" compression="gzip"> |
| <tarfileset dir="${war}" defaultexcludes="yes" |
| username="${static.user}" group="${static.group}" |
| mode="440" dirmode="550"> |
| <include name="**/*.css" /> |
| <include name="**/*.gif" /> |
| <include name="**/*.htm" /> |
| <include name="**/*.html" /> |
| <include name="**/*.jpg" /> |
| <include name="**/*.js" /> |
| <include name="**/*.png" /> |
| </tarfileset> |
| </tar> |
| </target> |
| |
| <!-- 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="/scripts/jspwiki-common.js"/> |
| <compressjs src="/scripts/jspwiki-edit.js"/> |
| <compressjs src="/scripts/jspwiki-prefs.js"/> |
| <compressjs src="/scripts/jspwiki-commonstyles.js"/> |
| <compressjs src="/scripts/prettify.js"/> |
| |
| <mkdir dir="${tmpdir}/compress/webdocs/templates/default"/> |
| |
| <compressjs src="/templates/default/jspwiki.css" |
| args="--line-break 0" /> |
| |
| <mkdir dir="${tmpdir}/compress/webdocs/templates/default/skins/OrderedList"/> |
| <compressjs src="/templates/default/skins/OrderedList/skin.css" |
| args="--line-break 0" /> |
| |
| <mkdir dir="${tmpdir}/compress/webdocs/templates/default/skins/PlainVanilla"/> |
| <compressjs src="/templates/default/skins/PlainVanilla/skin.css" |
| args="--line-break 0" /> |
| |
| <mkdir dir="${tmpdir}/compress/webdocs/templates/default/skins/PlainVanilla 1024x768"/> |
| <compressjs src="/templates/default/skins/PlainVanilla 1024x768/skin.css" |
| args="--line-break 0" /> |
| |
| <mkdir dir="${tmpdir}/compress/webdocs/templates/default/skins/Smart"/> |
| <compressjs src="/templates/default/skins/Smart/skin.css" |
| args="--line-break 0" /> |
| </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="init,installinit" |
| description="Builds source zip."> |
| |
| <delete dir="${install.src}" /> |
| |
| <exec executable="svn"> |
| <arg line="export ${svn.repository}/${svn.tag} "${install.src}""/> |
| </exec> |
| |
| <!-- Figure out JSPWiki version --> |
| |
| <mkdir dir="${install.src}/build"/> |
| <javac srcdir="${install.src}/src/java" destdir="${install.src}/build" |
| includes="org/apache/wiki/Release.java"> |
| <classpath> |
| <fileset dir="${install.src}/src/WebContent"> |
| <include name="**/*.jar"/> |
| </fileset> |
| </classpath> |
| </javac> |
| |
| <java classpath="${install.src}/build" |
| classname="org.apache.wiki.Release" |
| outputproperty="jspwiki.version"/> |
| |
| <property name="tmpzipdir" value="${tmpdir}/${ant.project.name}-${jspwiki.version}" /> |
| |
| <delete dir="${tmpzipdir}"/> |
| <mkdir dir="${tmpzipdir}"/> |
| |
| <move todir="${tmpzipdir}"> |
| <fileset dir="${install.src}"> |
| <include name="**"/> |
| <exclude name="build"/> |
| <!-- Any excluded files should go here --> |
| </fileset> |
| </move> |
| |
| <zip zipfile="${release.dir}/${ant.project.name}-${jspwiki.version}-src.zip" |
| basedir="${tmpdir}" |
| includes="${ant.project.name}-${jspwiki.version}/**"/> |
| |
| </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_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" /> |
| <zipfileset dir="src/wikipages" prefix="doc/wikipages" excludes="**/.??*"/> |
| </zip> |
| </target> |
| |
| <!-- Builds the entire distribution set. |
| |
| 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="installinit,srczip,war,corepageszip,documentzip" |
| description="Builds the entire distribution archive."> |
| <copy file="README" todir="${install.fulldir}" /> |
| <copy file="ChangeLog" todir="${install.fulldir}" /> |
| <copy file="ReleaseNotes" todir="${install.fulldir}" /> |
| <copy file="LICENSE" todir="${install.fulldir}" /> |
| |
| <zip zipfile="${release.dir}/${ant.project.name}-${jspwiki.version}-bin.zip"> |
| <zipfileset dir="${install.fulldir}" prefix="${ant.project.name}" /> |
| </zip> |
| |
| </target> |
| |
| <!-- Nabbed from solr --> |
| <macrodef name="sign-artifact" description="Signs the 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> |
| |
| <!-- Generates signatures and MD5 hashes for the release artifacts. --> |
| <target name="signeddist" depends="dist"> |
| |
| <checksum> |
| <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"> |
| |
| <!-- Create test files for classpath --> |
| <copy toDir="${tests.classpath}" overwrite="true"> |
| <fileset dir="${tests}/etc"> |
| <include name="CommentedPropertiesTest.properties" /> |
| <include name="log4j.properties" /> |
| <include name="migration/testrepo/**/*" /> |
| </fileset> |
| </copy> |
| |
| <!-- Create test WEB-INF --> |
| <copy toDir="${tests.webinf}" overwrite="true"> |
| <fileset dir="${tests}/etc"> |
| <include name="filters.xml" /> |
| <include name="groupdatabase.xml" /> |
| <include name="jspwiki_vers.properties" /> |
| <include name="jspwiki_rcs.properties" /> |
| <include name="jspwiki.policy" /> |
| <include name="jspwiki.properties" /> |
| <include name="jspwiki-testUserPolicy.policy" /> |
| <include name="keychain" /> |
| <include name="urlpattern.properties" /> |
| <include name="userdatabase.xml" /> |
| </fileset> |
| </copy> |
| |
| <!-- Create test WEB-INF/classes --> |
| <mkdir dir="${tests.webinf}/classes" /> |
| <copy toDir="${tests.webinf}/classes" overwrite="true"> |
| <fileset dir="${tests}/etc"> |
| <include name="priha.properties" /> |
| </fileset> |
| </copy> |
| |
| <!-- Create web.xml files for testing --> |
| <copy file="${code.web}/WEB-INF/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="<!-- REMOVE ME TO ENABLE JDBC DATABASE" value="" /> |
| <replace file="${webtests.build}/web.xml.custom" |
| token="REMOVE ME TO ENABLE JDBC DATABASE -->" 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="<!-- REMOVE ME TO ENABLE CONTAINER-MANAGED AUTH" value="" /> |
| <replace file="${webtests.build}/web.xml.container" |
| token="REMOVE ME TO ENABLE CONTAINER-MANAGED AUTH -->" value="" /> |
| |
| <mkdir dir="${tests.build}" /> |
| <mkdir dir="${tests.classpath}/WEB-INF" /> |
| <mkdir dir="${tests.reports}" /> |
| <mkdir dir="${tests.pagedir}" /> |
| <mkdir dir="${tests.workdir}" /> |
| <copy file="${webtests.build}/web.xml.container" |
| tofile="${tests.classpath}/WEB-INF/web.xml" overwrite="true" /> |
| |
| </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="jar,tests-init,jartests,tests-db-init,tests-ldap-init" |
| description="Runs the JUnit tests."> |
| |
| <junit printsummary="yes" haltonfailure="no" fork="yes" forkmode="once" maxmemory="512m"> |
| <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" /> |
| <exclude name="stress/**" if="tests.stress.disabled"/> |
| <exclude name="org/apache/wiki/web/*.*" /> |
| <exclude name="org/apache/wiki/TranslatorReaderTest*" /> |
| </fileset> |
| </batchtest> |
| </junit> |
| |
| <junitreport todir="${build}/tests"> |
| <fileset dir="${tests.reports}"> |
| <include name="**/TEST-*.xml" /> |
| <exclude name="**/TEST-stress.*.xml" if="tests.stress.disabled"/> |
| </fileset> |
| <report format="noframes" todir="${build}/tests" /> |
| </junitreport> |
| |
| </target> |
| |
| <target name="guitests" depends="jar,tests-init,jartests,tests-db-init" |
| description="Runs the tests in a pretty window."> |
| |
| <java classname="junit.swingui.TestRunner" fork="yes" maxmemory="512m"> |
| <classpath> |
| <path refid="path.tests" /> |
| </classpath> |
| <sysproperty key="jspwiki.tests.auth" value="true" /> |
| <arg value="org.apache.wiki.AllTests" /> |
| </java> |
| |
| </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,tests-db-init,jar-compiled-jsps,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" flatten="true" /> |
| <propertyfile file="${webtests.build}/jspwiki.properties"> |
| <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="log4j.appender.TestContainerLog.File" value="${basedir}/${webtests.build}/testcontainer.log" /> |
| <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" /> |
| <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="jspwiki.policy" /> |
| </fileset> |
| <fileset dir="${tests.classpath}" 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" 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="priha.properties" /> |
| </copy> |
| <copy toDir="@{context.dir}/webapp/WEB-INF"> |
| <fileset dir="tests/etc" includes="keychain" /> |
| </copy> |
| <copy toDir="@{context.dir}/webapp/WEB-INF/classes"> |
| <fileset dir="${tests.classpath}" includes="log4j.properties" /> |
| <filterset> |
| <filter token="logfile" value="@{context.dir}/jetty.log" /> |
| </filterset> |
| </copy> |
| |
| <!-- Copy the libraries --> |
| <copy toDir="@{context.dir}/webapp/WEB-INF/lib"> |
| <fileset dir="${code.web}" includes="**" excludes="**/servlet-api.jar **/jsp-api.jar WEB-INF/web.xml" /> |
| <fileset file="${jarfile}"/> |
| <fileset file="${jdbc.driver.jar}"/> |
| <fileset file="${tests}/lib/jasper-runtime-*.jar"/> |
| </copy> |
| |
| <!-- Copy the JSPs --> |
| <copy toDir="@{context.dir}/webapp"> |
| <fileset dir="${code.web}" 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 pinging the shutdown port --> |
| <echo message="Shutting down Jetty (if it is up)."/> |
| <get src="http://localhost:${webtests.shutdown}/" dest="${webtests.temp}/shutdown.log" |
| ignoreerrors="true" verbose="true" /> |
| <sleep seconds="2"/> |
| |
| <!-- Start Jetty with our test context --> |
| <echo message="Starting Jetty."/> |
| <java classname="org.apache.wiki.web.TestContainer" fork="false" spawn="false"> |
| <classpath> |
| <path refid="path.tests" /> |
| </classpath> |
| <sysproperty key="java.io.tmpdir" value="${webtests.temp}" /> |
| <sysproperty key="log4j.debug" value="true" /> |
| <!-- |
| <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}"' /> |
| <arg line="${webtests.build}/@{context}/selenium/TestSuite.html" /> |
| <arg line="${webtests.reports}/@{context}.html" /> |
| </java> |
| </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: set up your database properties in build.properties, for example: |
| |
| jdbc.driver.id=hsql |
| jdbc.driver.jar=tests/lib/hsqldb.jar |
| jdbc.driver.class=org.hsqldb.jdbcDriver |
| jdbc.driver.url=jdbc:hsqldb:hsql://localhost/jspwiki |
| jdbc.admin.id=SA |
| jdbc.admin.password= |
| jdbc.user.id=jspwiki |
| jdbc.user.password=password |
| |
| The 'jdbc.driver.id' property is important. Its presence tells |
| the Ant scripts to do JDBC testing. It also points to |
| he subdirectory in etc/db that contains our setup/teardown |
| scripts, which *must* contain these files at a minumum: |
| |
| 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. 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.classpath}/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 build.properties, as described |
| above |
| 2) Configure table and column mappings in etc/jspwiki.properties |
| 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,hsql-init,db-setup"/> |
| |
| <target name="db-properties" depends="init" if="jdbc.driver.id"> |
| <!-- Load the JDBC props we need to do table maintenance --> |
| <check-property prop="jdbc.driver.jar" /> |
| <check-property prop="jdbc.driver.class" /> |
| <check-property prop="jdbc.driver.url" /> |
| <check-property prop="jdbc.admin.id" /> |
| <check-property prop="jdbc.admin.password" /> |
| |
| <!-- Here's a neat trick: import the JDBC runtime props from jspwiki.properties --> |
| <echo message="Getting JDBC runtime properties." /> |
| <loadproperties srcFile="${tests}/etc/jspwiki.properties"> |
| <filterchain> |
| <linecontainsregexp> |
| <regexp pattern="^[jspwiki.userdatabase|jspwiki.groupdatabase]"/> |
| </linecontainsregexp> |
| </filterchain> |
| </loadproperties> |
| <check-property prop="jspwiki.userdatabase.datasource" /> |
| <check-property prop="jspwiki.userdatabase.table" /> |
| <check-property prop="jspwiki.userdatabase.email" /> |
| <check-property prop="jspwiki.userdatabase.fullName" /> |
| <check-property prop="jspwiki.userdatabase.loginName" /> |
| <check-property prop="jspwiki.userdatabase.password" /> |
| <check-property prop="jspwiki.userdatabase.wikiName" /> |
| <check-property prop="jspwiki.userdatabase.created" /> |
| <check-property prop="jspwiki.userdatabase.modified" /> |
| <check-property prop="jspwiki.userdatabase.roleTable" /> |
| <check-property prop="jspwiki.userdatabase.role" /> |
| <check-property prop="jspwiki.groupdatabase.datasource" /> |
| <check-property prop="jspwiki.groupdatabase.table" /> |
| <check-property prop="jspwiki.groupdatabase.membertable" /> |
| <check-property prop="jspwiki.groupdatabase.created" /> |
| <check-property prop="jspwiki.groupdatabase.creator" /> |
| <check-property prop="jspwiki.groupdatabase.name" /> |
| <check-property prop="jspwiki.groupdatabase.member" /> |
| <check-property prop="jspwiki.groupdatabase.modified" /> |
| <check-property prop="jspwiki.groupdatabase.modifier" /> |
| |
| <!-- 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 --> |
| <mkdir dir="${tests.db}" /> |
| <property name="tests.db.scripts" value="${tests.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" /> |
| |
| <!-- Dump all of the JDBC properties where our test scripts can find them --> |
| <echoproperties prefix="jdbc." destfile="${tests.db}/jdbc.properties" /> |
| </target> |
| |
| <target name="db-setup" depends="db-properties,hsql-init" if="db.props.exist"> |
| <echo message="Setting up the database tables." /> |
| <exec-sql file="${userdb.setup}" /> |
| </target> |
| |
| <target name="db-teardown" depends="db-properties,hsql-init" if="db.props.exist"> |
| <echo message="Tearing down the database tables." /> |
| <exec-sql file="${userdb.teardown}" /> |
| </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> |
| |
| <macrodef name="exec-sql"> |
| <attribute name="file" /> |
| <sequential> |
| <sql driver="${jdbc.driver.class}" |
| classpath="${jdbc.driver.jar}" url="${jdbc.driver.url}" |
| userid="${jdbc.admin.id}" password="${jdbc.admin.password}" |
| src="@{file}" onerror="continue" autocommit="true" /> |
| </sequential> |
| </macrodef> |
| |
| <!-- ============================================================== --> |
| |
| <!-- Hypersonic embedded database startup/shutdown (for testing JDBC) --> |
| |
| <!-- Special "init" target for Hypersonic --> |
| <target name="hsql-init" depends="hsql-check-start,hsql-start" /> |
| |
| <target name="hsql-check-start" depends="db-properties"> |
| <echo message="Checking to see if Hypersonic JDBC server is running already." /> |
| <property file="${tests.db}/hsql/server.properties" prefix="hsql" /> |
| <fail unless="hsql.server.port">Failed to load Hypersonic JDBC properties from ${tests.db}/hsql/server.properties</fail> |
| <condition property="hsql.up"> |
| <socket server="localhost" port="${hsql.server.port}" /> |
| </condition> |
| </target> |
| |
| <target name="hsql-start" depends="hsql-check-start" unless="hsql.up" |
| description="Starts the Hypersonic database for testing."> |
| <echo message="Starting up Hypersonic JDBC server on localhost." /> |
| <delete file="${tests.db}/hsql/jspwiki.lck"/> |
| <java fork="yes" spawn="yes" classname="org.hsqldb.Server" |
| dir="${tests.db}/hsql"> |
| <classpath> |
| <pathelement location="${jdbc.driver.jar}" /> |
| </classpath> |
| </java> |
| <sleep seconds="5" /> |
| <available file="${tests.db}/hsql/jspwiki.lck" property="hsql.up"/> |
| <fail unless="hsql.up">Hypersonic didn't appear to start up properly. You can start it manually from the command line as follows: |
| cd build/tests/etc/db/hsql |
| java -cp ${jdbc.driver.jar} org.hsqldb.Server |
| </fail> |
| <echo message="Done." /> |
| </target> |
| |
| <target name="hsql-stop" depends="hsql-check-start" if="hsql.up" |
| description="Shuts down the Hypersonic database, if it's up."> |
| <echo message="Shutting down Hypersonic JDBC server on localhost." /> |
| <sql driver="${jdbc.driver.class}" |
| classpath="${jdbc.driver.jar}" url="${jdbc.driver.url}" |
| onerror="continue" autocommit="true" |
| userid="${jdbc.admin.id}" password="${jdbc.admin.password}"> |
| SHUTDOWN |
| </sql> |
| <!-- The lock file should be deleted automatically, but just in case... --> |
| <delete file="${tests.db}/hsql/jspwiki.lck" /> |
| <echo message="Done." /> |
| </target> |
| |
| <!-- ============================================================== --> |
| |
| <!-- OpenLDAP server startup/shutdown (for testing LDAP integration) --> |
| |
| <!-- Special "init" target for OpenLDAP --> |
| <target name="tests-ldap-init" depends="ldap-check-start,ldap-start" if="openldap" /> |
| |
| <target name="ldap-check-start" if="openldap"> |
| <echo message="Checking to see if OpenLDAP server is running already." /> |
| <condition property="ldap.up"> |
| <socket server="localhost" port="4890" /> |
| </condition> |
| </target> |
| |
| <target name="ldap-start" depends="ldap-check-start" unless="ldap.up" if="openldap" |
| description="Starts OpenLDAP for testing."> |
| <echo message="Starting OpenLDAP server on localhost." /> |
| <delete dir="${tests.ldap}" /> |
| <mkdir dir="${tests.ldap}" /> |
| <mkdir dir="${tests.ldap}/data" /> |
| <exec executable="${openldap}" dir="." spawn="true"> |
| <arg value="-f" /> |
| <arg value="${basedir}/etc/ldap/slapd.conf" /> |
| <arg value="-h" /> |
| <arg value="ldap://127.0.0.1:4890/" /> |
| <arg value="-d" /> |
| <arg value="-1" /> |
| <arg value="-u" /> |
| <arg value="${env.USER}" /> |
| </exec> |
| <sleep seconds="3" /> |
| <echo message="Loading sample schema." /> |
| <exec executable="ldapadd" dir="."> |
| <arg value="-x" /> |
| <arg value="-h" /> |
| <arg value="127.0.0.1" /> |
| <arg value="-p" /> |
| <arg value="4890" /> |
| <arg value="-D" /> |
| <arg value="cn=Manager,dc=jspwiki,dc=org" /> |
| <arg value="-w" /> |
| <arg value="test" /> |
| <arg value="-f" /> |
| <arg value="${basedir}/etc/ldap/test.ldif" /> |
| </exec> |
| <sleep seconds="3" /> |
| <available file="${tests.ldap}/slapd.pid" property="ldap.up"/> |
| <fail unless="ldap.up">OpenLDAP didn't appear to start up properly. You can start it manually from the command line as follows: |
| ${openldap} -f etc/ldap/slapd.conf -h "ldap://127.0.0.1:4890/" -d -1 -u ${env.USER} |
| </fail> |
| <echo message="Done." /> |
| </target> |
| |
| <target name="ldap-stop" depends="ldap-check-start" if="ldap.up" |
| description="Shuts down the OpenLDAP test server, if it's up."> |
| <echo message="Shutting down OpenLDAP server on localhost." /> |
| <exec executable="killall"> |
| <arg value="-u" /> |
| <arg value="arj" /> |
| <arg value="-c" /> |
| <arg value="slapd" /> |
| </exec> |
| <delete dir="${tests.ldap}/data" /> |
| <delete file="${tests.ldap}/slapd.args" /> |
| <delete file="${tests.ldap}/slapd.pid" /> |
| <echo message="Done." /> |
| </target> |
| |
| <!-- ============================================================== --> |
| <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="${build}/${ant.project.name}_${i18n.template}.jar" index="true"> |
| <fileset dir="${tmplt.i18n.dir}/${ant.project.name}_${i18n.template}" includes="**/*.properties" /> |
| </jar> |
| <echo message="Created ${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="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='<!DOCTYPE differences SYSTEM "http://depfind.sourceforge.net/dtd/differences.dtd">' |
| value=""/> |
| <!-- Just to be safe, replace raw ampersands with something bogus --> |
| <replace file="${tests.reports}/API-changes.xml" |
| token="&" value="(ampersand)"/> |
| <xslt in="${tests.reports}/API-changes.xml" |
| out="${tests.reports}/API-changes.html" |
| style="${dependencyfinder.dir}/etc/DiffToHTML.xsl"> |
| </xslt> |
| </target> |
| |
| </project> |