blob: 3df018dd273a2c63934f1ad494e79ca6ccc50387 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project xmlns:ivy="antlib:org.apache.ivy.ant" xmlns:m="http://ant.apache.org/ivy/maven" xmlns:openpgp="antlib:org.apache.commons.openpgp.ant">
<tstamp/>
<import file="ivy-common.xml"/>
<property name="project.lib.dir" location="${project.webapp.dir}/WEB-INF/lib" />
<property name="project.core.src.dir" location="src" />
<property name="project.test.src.dir" location="src-tests" />
<property name="project.build.classes.dir" location="${project.build.dir}/classes" />
<property name="project.build.classes.test.dir" location="${project.build.dir}/classes-test" />
<property name="compile.debug" value="on" />
<property name="jvmargs" value="" />
<property name="compilerargs" value="" />
<property name="jdbc.driver.path" value="" />
<property name="dist.dir" location="dist"/>
<property name="java.source.version" value="1.5"/>
<property name="java.target.version" value="1.5"/>
<target name="init">
<available file="${project.core.src.dir}" property="project.core.src.dir.exists"/>
<available file="${project.test.src.dir}" property="project.test.src.dir.exists"/>
<ivy:cachepath pathid="project.core.class.path" conf="dev" />
<ivy:cachepath pathid="project.test.class.path" conf="test" />
<path id="run.path.id">
<path refid="project.core.class.path" />
<path location="${project.build.classes.dir}" />
<path location="${jdbc.driver.path}" />
</path>
<propertyset id="run.syspropertyset.id">
<propertyref prefix="${ant.project.name}."/>
</propertyset>
</target>
<target name="compile-test"
depends="compile-core" description="--> compile the project tests"
if="project.test.src.dir.exists">
<echo>Compiling test files in ${project.test.src.dir}</echo>
<mkdir dir="${project.build.classes.test.dir}" />
<javac source="${java.source.version}"
target="${java.target.version}"
destdir="${project.build.classes.test.dir}"
debug="${compile.debug}">
<src path="${project.test.src.dir}" />
<classpath>
<path refid="project.test.class.path" />
<path location="${project.build.classes.dir}" />
</classpath>
</javac>
<echo>Copying resources from test source directory</echo>
<copy todir="${project.build.classes.test.dir}">
<fileset dir="${project.test.src.dir}">
<exclude name="**.java" />
</fileset>
</copy>
<antcall target="post-compile-test" inheritRefs="true"/>
</target>
<target name="post-compile-test" description="Run after compile-test. Intended to be overridden if your project needs any post compile processing"/>
<target name="local-publish-subprojects" description="Build all sub-projects of this project and deploy them locally.">
<echo>No sub-projects of ${ant.project.name}-${version} to publish.</echo>
</target>
<target name="compile-core"
depends="local-publish-subprojects, resolve, init" description="--> compile the project"
if="project.core.src.dir.exists">
<echo>Preparing to compile core of ${ant.project.name}-${version}.</echo>
<antcall target="pre-compile-core" inheritRefs="true"/>
<echo>Compiling files in ${project.core.src.dir}</echo>
<echo>Build directory is ${project.build.classes.dir}</echo>
<mkdir dir="${project.build.classes.dir}" />
<echo>Compile core of ${ant.project.name}-${version}.</echo>
<javac
source="${java.source.version}"
target="${java.target.version}"
destdir="${project.build.classes.dir}"
debug="${compile.debug}"
classpathref="project.core.class.path">
<src path="${project.core.src.dir}" />
<compilerarg line="${compilerargs}" />
</javac>
<echo>Copying resources from source directory</echo>
<copy todir="${project.build.classes.dir}">
<fileset dir="${project.core.src.dir}">
<exclude name="**.java" />
</fileset>
</copy>
<antcall target="post-compile-core" inheritRefs="true"/>
</target>
<target name="pre-compile-core" description="Run before compile-core. intended to be overridden if your project needs any post compile processing"/>
<target name="post-compile-core" description="Run after compile-core. Intended to be overridden if your project needs any post compile processing"/>
<target name="run" depends="compile-core" description="--> compile and run the project">
<java classname="${main.start.class.name}"
classpathref="run.path.id"
fork="true"
failonerror="true">
<jvmarg line="${jvmargs}"/>
<arg line="${run.args}"/>
<syspropertyset refid="run.syspropertyset.id"/>
</java>
</target>
<target name="stopserver" depends="init" description="--> stop the running server instance">
<java classname="${main.stop.class.name}"
classpathref="run.path.id"
fork="true"
failonerror="true">
<jvmarg line="${jvmargs}"/>
<arg line="${run.args}"/>
<syspropertyset refid="run.syspropertyset.id"/>
</java>
</target>
<!-- buildbot moans if this is not here -->
<target name="jar"/>
<target name="jar-compiled" unless="not-subproject" depends="test-calling-project,clean-dist, compile-core, checkfirstrootivyrootpath, checksecondrootivyrootpath">
<mkdir dir="${dist.dir}"/>
<!-- Create compiled jar -->
<jar destfile="${dist.dir}/${ant.project.name}.jar">
<fileset dir="${project.build.classes.dir}">
<exclude name="**/*.java"/>
</fileset>
<metainf dir="${calculated-generic-path}etc/release/maven/subprojects">
<include name="LICENSE"/>
<include name="NOTICE"/>
</metainf>
<manifest>
<attribute name="Implementation-Vendor" value="Apache Software Foundation"/>
<attribute name="Implementation-Title" value="${ant.project.name}"/>
<attribute name="Implementation-Version" value="${version}"/>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Build-Date" value="${TODAY}"/>
</manifest>
</jar>
</target>
<target name="jar-javadoc" depends="clean-dist, compile-core, checkfirstrootivyrootpath, checksecondrootivyrootpath">
<!-- Create javadoc JAR -->
<mkdir dir="${dist.dir}/javadoc/"/>
<javadoc packagenames="*"
sourcepath="${project.core.src.dir}"
destdir="${dist.dir}/javadoc"
author="true"
version="true"
classpathref="project.core.class.path"
use="true"
windowtitle="${ant.project.name}-${version}"
doctitle="&lt;h1&gt;${ant.project.name}-${version}&lt;/h1&gt;">
<bottom><![CDATA[<i>2012 Apache Software Foundation.</i>]]></bottom>
</javadoc>
<jar destfile="${dist.dir}/${ant.project.name}-javadoc.jar">
<fileset dir="${dist.dir}/javadoc"/>
<metainf dir="${calculated-generic-path}etc/release/maven/subprojects">
<include name="LICENSE"/>
<include name="NOTICE"/>
</metainf>
<manifest>
<attribute name="Implementation-Vendor" value="Apache Software Foundation"/>
<attribute name="Implementation-Title" value="${ant.project.name}"/>
<attribute name="Implementation-Version" value="${version}"/>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Build-Date" value="${TODAY}"/>
</manifest>
</jar>
<!--remove folder-->
<delete dir="${dist.dir}/javadoc" />
</target>
<target name="jar-sources" depends="clean-dist, compile-core, checkfirstrootivyrootpath, checksecondrootivyrootpath" description="--> make a jar file for this project">
<mkdir dir="${dist.dir}"/>
<!-- Create source JAR -->
<jar destfile="${dist.dir}/${ant.project.name}-sources.jar">
<fileset dir="${project.core.src.dir}">
<include name="**/*"/>
</fileset>
<metainf dir="${calculated-generic-path}etc/release/maven/subprojects">
<include name="LICENSE"/>
<include name="NOTICE"/>
</metainf>
<manifest>
<attribute name="Implementation-Vendor" value="Apache Software Foundation"/>
<attribute name="Implementation-Title" value="${ant.project.name}"/>
<attribute name="Implementation-Version" value="${version}"/>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Build-Date" value="${TODAY}"/>
</manifest>
</jar>
</target>
<!-- TODO - figure how to call NOT from init-war, rather then have 2 similar methods -->
<target name="test-calling-project">
<condition property="not-subproject">
<equals arg1="${ant.project.name}" arg2="wookie"/>
</condition>
</target>
<target name="test-calling-project-true">
<condition property="subproject">
<not>
<equals arg1="${ant.project.name}" arg2="wookie"/>
</not>
</condition>
</target>
<target name="init-war" unless="subproject" depends="test-calling-project-true" >
<copy todir="${build.dir}/maven-webapp/${ant.project.name}/WEB-INF/classes">
<fileset dir="${project.build.classes.dir}">
<exclude name="**/*.java" />
</fileset>
</copy>
<copy todir="${build.dir}/maven-webapp/${ant.project.name}">
<fileset dir="${project.webapp.dir}" />
</copy>
<ivy:retrieve conf="deploy" pattern="${build.dir}/maven-webapp/wookie/WEB-INF/lib/[artifact]-[revision].[ext]"/>
<ivy:retrieve conf="database" pattern="${build.dir}/maven-webapp/wookie/WEB-INF/lib/[artifact]-[revision].[ext]" />
<!-- update widgetserver.properties file so that it points to derby as db type-->
<copy file="${project.core.src.dir}/widgetserver.properties"
todir="${build.dir}/maven-webapp/wookie/WEB-INF/classes/" overwrite="true">
<filterset>
<filter token="PERSISTENCE_MANAGER_CLASSNAME" value="org.apache.wookie.beans.jpa.JPAPersistenceManager"/>
<filter token="DATABASE_TYPE" value="derby"/>
<filter token="REPOSITORY_USER" value=""/>
<filter token="REPOSITORY_PASSWORD" value=""/>
<filter token="REPOSITORY_ROOTPATH" value=""/>
<filter token="REPOSITORY_WORKSPACE" value=""/>
</filterset>
</copy>
<!-- configure JPA context.xml configuration -->
<copy file="${etc.dir}/tomcat/conf/jpa-context.xml"
tofile="${build.dir}/maven-webapp/wookie/META-INF/context.xml"
overwrite="true">
<filterset>
<filter token="DATABASE_USER" value="java"/>
<filter token="DATABASE_PASSWORD" value="java"/>
<filter token="DATABASE_DRIVER" value="org.apache.derby.jdbc.EmbeddedDriver"/>
<filter token="DATABASE_URI" value="jdbc:derby:widgetDatabase/widgetDB;create=true"/>
</filterset>
</copy>
<copy file="${project.webapp.dir}/WEB-INF/web.xml"
todir="${build.dir}/maven-webapp/wookie/WEB-INF" overwrite="true">
<filterset>
<filter token="RESOURCE_REF_DESCRIPTION" value="The JPA database connection."/>
<filter token="RESOURCE_REF_NAME" value="jdbc/widgetdb"/>
<filter token="RESOURCE_REF_TYPE" value="javax.sql.DataSource"/>
</filterset>
</copy>
<mkdir dir="${build.dir}/maven-webapp/wookie/features"/>
<copy todir="${build.dir}/maven-webapp/wookie/features">
<fileset dir="${user.dir}/features"/>
</copy>
<!-- make all the widgets -->
<antcall target="post-deploy-webapp-widgets-extra"/>
<!-- copy them into the maven webapp -->
<copy todir="${build.dir}/maven-webapp/wookie/deploy">
<fileset dir="${build.dir}/webapp/wookie/deploy"/>
</copy>
<!-- build war file -->
<echo>Building war...</echo>
<war
destfile="${dist.dir}/wookie.war"
webxml="${build.dir}/maven-webapp/wookie/WEB-INF/web.xml">
<lib dir="${build.dir}/maven-webapp/wookie/WEB-INF/lib"/>
<classes dir="${build.dir}/maven-webapp/wookie/WEB-INF/classes" />
<fileset dir="${build.dir}/maven-webapp/wookie/">
<exclude name="WEB-INF/classes/" />
<exclude name="WEB-INF/lib/" />
</fileset>
<metainf dir="etc/release/maven/war/">
<include name="LICENSE"/>
<include name="NOTICE"/>
</metainf>
<manifest>
<attribute name="Implementation-Vendor" value="Apache Software Foundation"/>
<attribute name="Implementation-Title" value="${ant.project.name}"/>
<attribute name="Implementation-Version" value="${version}"/>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Build-Date" value="${TODAY}"/>
</manifest>
</war>
<!-- clean up -->
<delete dir="${build.dir}/maven-webapp" />
</target>
<!-- make sure the credentials have been passed via command line -->
<target name="test-upload-credentials">
<fail unless="upload.user" message="supply upload.user on the command line"/>
<fail unless="upload.password" message="supply upload.password on the command line"/>
</target>
<!--
Checks to see if the ivysettings is available and sets a property if so.
This is because when you run build.xml -> local-publish-subprojects
the current path is set to one of the subprojects i.e. connector/java
But if you run build.xml -> ivy-java-common.xml -> publish-local
then the root "wookie" project is set to the top level. The
following 4 targets figure out where the properties files are relative
to whre the current directory is. It is used eventually in the
'sign-artifacts' target below.
-->
<target name="check-first-location-for-settings">
<available file="../../ant/ivysettings.xml" property="firstivysettings.present"/>
</target>
<target name="check-second-location-for-settings">
<available file="ant/ivysettings.xml" property="secondivysettings.present"/>
</target>
<target name="checkfirstrootivyrootpath" depends="check-first-location-for-settings" if="firstivysettings.present">
<property name="calculated-ivy-path" value="../../ant/ivysettings.xml"/>
<property name="calculated-this-path" value="../../ant/ivy-java-common.xml"/>
<property name="calculated-generic-path" value="../../"/>
</target>
<target name="checksecondrootivyrootpath" depends="check-second-location-for-settings" if="secondivysettings.present">
<property name="calculated-ivy-path" value="ant/ivysettings.xml"/>
<property name="calculated-this-path" value="ant/ivy-java-common.xml"/>
<property name="calculated-generic-path" value="./"/>
</target>
<target name="publish" depends="clean-build, jar-compiled" description="--> publish this project in the ivy repository">
<ivy:publish
artifactspattern="[artifact].[ext]"
resolver="shared"
pubrevision="${version}"
/>
<echo message="project ${ant.project.name} released with version ${revision}" />
</target>
<!--
================================================================================
To use the target of sign-artifacts you must first add your pgp credentials on the
command line, otherwise it will fail.
i.e.
-Dpgp.password=yourpgppassword -Dpgp.keyId=yourpgpkeyId
================================================================================
-->
<target name="sign-artifacts" depends="checkfirstrootivyrootpath, checksecondrootivyrootpath">
<fail unless="pgp.password" message="supply -Dpgp.password=yourpassword on the command line"/>
<fail unless="pgp.keyId" message="supply -Dpgp.keyId=yourkeyid on the command line"/>
<ivy:settings id="sign.settingsId" file="${calculated-ivy-path}"/>
<ivy:cachepath organisation="org.apache.commons" settingsRef="sign.settingsId"
transitive="false" log="download-only" module="commons-openpgp" revision="1.0-SNAPSHOT"
inline="true" pathid="openpgp.classpath"/>
<ivy:cachepath organisation="org.bouncycastle" settingsRef="sign.settingsId" log="download-only"
module="bcprov-jdk16" revision="1.45" inline="true" pathid="bouncycastle.bcprov.classpath"/>
<ivy:cachepath organisation="org.bouncycastle" settingsRef="sign.settingsId" transitive="false"
log="download-only" module="bcpg-jdk16" revision="1.45" inline="true" pathid="bouncycastle.bcpg.classpath"/>
<!--
For some reason, if we use the openpgp:signer task here directly, the bouncycastle security
provider cannot be loaded. If we launch it as a forked process everything works fine !?!
- NOTE: I guess it needs to be loaded into memory first hence why you cant run it in the same thread.
-->
<java classname="org.apache.tools.ant.launch.Launcher" fork="true">
<classpath>
<fileset dir="${ant.home}" includes="**/*.jar"/>
<path refid="bouncycastle.bcprov.classpath"/>
<path refid="bouncycastle.bcpg.classpath"/>
<path refid="openpgp.classpath"/>
<path refid="openpgp.classpath"/>
</classpath>
<arg line="-f ${calculated-this-path}"/>
<arg line="sign-internal"/>
<arg line="-Dpgp.password=${pgp.password}"/>
<arg line="-Dpgp.keyId=${pgp.keyId}"/>
<arg line="-Dlocal.dist.dir=${dist.dir}"/>
</java>
</target>
<target name="sign-internal">
<taskdef resource="org/apache/commons/openpgp/ant/antlib.xml" uri="antlib:org.apache.commons.openpgp.ant"/>
<!-- NOTE - The two paths below are on windows, you may have to change this - perhaps refactor to put into build.properties-->
<openpgp:signer secring="${user.home}/AppData/Roaming/gnupg/secring.gpg"
pubring="${user.home}/AppData/Roaming/gnupg/pubring.gpg"
password="${pgp.password}"
keyid="${pgp.keyId}"
asciiarmor="true">
<fileset dir="${local.dist.dir}">
<include name="**/*.pom"/>
<include name="**/*.jar"/>
<include name="**/*.war"/>
</fileset>
</openpgp:signer>
</target>
<target name="make-subproject-pom">
<echo>Making POM file: ${ant.project.name}-${version}</echo>
<delete file="${dist.dir}/ivy.xml"/> <!-- delete last produced ivy file to be sure a new one will be generated -->
<tstamp>
<format property="now" pattern="yyyyMMddHHmmss"/>
</tstamp>
<ivy:makepom ivyfile="${basedir}/ivy.xml"
templatefile="${basedir}/pom-template.xml"
pomfile="${dist.dir}/${ant.project.name}.pom">
<mapping conf="deploy" scope="compile"/>
</ivy:makepom>
</target>
<!--
================================================================================
Note to run either the...
'publish-maven-snapshot-artifacts' OR
'publish-maven-release-artifacts'
...tasks, you must first add your apache credentials on the command line
i.e.
-Dupload.user=myusername -Dupload.password=mypassword
================================================================================
-->
<target name="publish-local" depends="clean-dist, jar-compiled, jar-sources, jar-javadoc, init-war, make-subproject-pom" description="--> publishes this project in the local repository (found under user.home/.m2). Run this from the root to publish the 'wookie' project, as well as all subprojects. To only publish the subprojects see instead 'publish-local'">
<ivy:publish resolver="local"
pubrevision="${version}"
forcedeliver="true"
publishivy="false"
srcivypattern="${dist.dir}/ivy.xml"
pubdate="${now}"
conf="deploy, deploy-with-src-and-docs"
overwrite="true"
artifactspattern="${dist.dir}/[artifact](-[classifier]).[ext]"/>
<echo message="project ${ant.project.name} published locally with version ${version}" />
</target>
<target name="publish-maven-snapshot-artifacts" depends="test-upload-credentials, clean-dist, jar-compiled, jar-sources, jar-javadoc, init-war, make-subproject-pom" description="--> publishes this project in the apache snapshot repository. Run this from the root to publish the 'wookie' project, as well as all subprojects. To only publish the subprojects see instead 'publish-subproject-artifacts-to-snapshot-repo'">
<ivy:publish resolver="apache-snapshot-artifacts"
pubrevision="${version}"
forcedeliver="true"
publishivy="false"
srcivypattern="${dist.dir}/ivy.xml"
pubdate="${now}"
conf="deploy, deploy-with-src-and-docs"
overwrite="true"
artifactspattern="${dist.dir}/[artifact](-[classifier]).[ext]"/>
<echo message="project ${ant.project.name} published to nexus snapshot repo with version ${version}" />
</target>
<target name="publish-maven-release-artifacts" depends="test-upload-credentials, clean-dist, jar-compiled, jar-sources, jar-javadoc, init-war, make-subproject-pom, sign-artifacts" description="--> publishes this project in the apache staging area repository (prior to release). Run this from the root to publish the 'wookie' project, as well as all subprojects. To only publish the subprojects see instead 'publish-subproject-artifacts-to-release-repo'">
<ivy:publish resolver="apache-release-artifacts"
pubrevision="${version}"
forcedeliver="true"
publishivy="false"
srcivypattern="${dist.dir}/ivy.xml"
pubdate="${now}"
conf="deploy, deploy-with-src-and-docs, deploy-signed"
overwrite="true"
artifactspattern="${dist.dir}/[artifact](-[classifier]).[ext]"/>
<echo message="project ${ant.project.name} published to nexus snapshot repo with version ${version}" />
</target>
</project>