Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

577 lines (511 sloc) 22.582 kb
<!--
Copyright (c) 2009-2012 Couchbase, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-->
<project name="couchbase-client" default="package"
xmlns:artifact="urn:maven-artifact-ant"
xmlns:ivy="antlib:org.apache.ivy.ant">
<!-- load ant-contrib tasks to get the "if" task. -->
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="${basedir}/lib/ant-contrib-1.0b3.jar"/>
</classpath>
</taskdef>
<property name="name" value="couchbase-client"/>
<property name="copyright" value="2006-2011 Dustin Sallings, Matt Ingenthron" />
<property name="group" value="couchbase" />
<property name="base.src.dir" value="${basedir}/src" />
<property name="build.dir" value="${basedir}/build" />
<property name="build.src.dir" value="${build.dir}/src" />
<property name="etc.dir" value="${basedir}/etc" />
<property name="lib.dir" value="${basedir}/lib" />
<property name="src.dir" value="${base.src.dir}/main/java" />
<property name="test.dir" value="${base.src.dir}/test/java" />
<property name="script.src.dir" value="${base.src.dir}/scripts" />
<property name="build.javadoc" location="${build.dir}/docs/" />
<property name="junit.dir" location="${build.dir}/junit" />
<property name="dist.dir" value="${basedir}/target" />
<property name="build.classes" location="${build.dir}/classes"/>
<property name="git.hash" value="" />
<var name="version" value="no-version"/>
<!-- ivy properties used -->
<property name="ivy.settings.dir" value="${basedir}/ivy" />
<property name="ivy.pom.url"
value="http://www.couchbase.org/code/couchbase/java" />
<property name="ivy.pom.groupId" value="couchbase" />
<property name="ivy.pom.description"
value = "A client library for Couchbase Server" />
<path id="test.classpath">
<pathelement location="${build.classes}" />
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
</path>
<!-- tests -->
<property name="build.test" location="${build.dir}/test"/>
<property name="test.log.dir" location="${build.dir}/test/logs"/>
<property name="build.test.classes" location="${build.test}/classes" />
<!-- maven -->
<property name="mvn.build.dir" value="${build.dir}" />
<!-- compilation -->
<property name="javac.deprecation" value="off"/>
<property name="javac.debug" value="on"/>
<property name="build.encoding" value="ISO-8859-1"/>
<!-- Checking code style -->
<property name="checkstyle.xml" value="${etc.dir}/checkstyle.xml" />
<property name="checkstyle.format.xsl" value="${etc.dir}/checkstyle-noframes.xsl" />
<property name="checkstyle.report.dir" value="${build.dir}/checkstyle" />
<!-- static analysis -->
<property name="findbugs.out.dir" value="${build.dir}/findbugs" />
<property name="findbugs.output.xml.file"
value="${findbugs.out.dir}/report.xml" />
<property name="findbugs.output.html.file"
value="${findbugs.out.dir}/report.html" />
<!-- Ivy-based dependency resolution -->
<property name="ivy.dir" location="${basedir}/ivy" />
<property name="ivysettings.xml" location="${ivy.dir}/ivysettings.xml"/>
<loadproperties srcfile="${ivy.dir}/libraries.properties"/>
<property name="ivy.jar" location="${lib.dir}/ivy-${ivy.version}.jar"/>
<property name="ivy_repo_url"
value="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.version}/ivy-${ivy.version}.jar" />
<property name="mvn_repo_url"
value="http://repo2.maven.org/maven2/org/apache/maven/maven-ant-tasks/${mvn.version}/maven-ant-tasks-${mvn.version}.jar"/>
<property name="mvn.jar" location="${build.dir}/maven-ant-tasks-${mvn.version}.jar" />
<property name="build.ivy.dir" location="${build.dir}/ivy" />
<property name="build.ivy.lib.dir" location="${build.ivy.dir}/lib" />
<property name="build.ivy.report.dir" location="${build.ivy.dir}/report" />
<property name="redist.ivy.lib.dir" location="${build.ivy.lib.dir}/${name}/redist"/>
<!--test related properties -->
<property name="server.address_v4" value="127.0.0.1"/>
<property name="server.address_v6" value="::1"/>
<property name="server.type" value="memcached"/>
<property name="test.type" value="unit"/>
<!--this is the naming policy for artifacts we want pulled down-->
<property name="ivy.artifact.retrieve.pattern"
value="${name}/[conf]/[artifact]-[revision](-[classifier]).[ext]"/>
<!-- paths used for compilation and run -->
<path id="lib.path.id">
<fileset dir="${lib.dir}" />
</path>
<path id="run.path.id">
<path refid="lib.path.id" />
<path location="${build.dir}" />
</path>
<!-- The classpath for compiling and running couchbase-client -->
<path id="compile.classpath">
<pathelement location="${build.classes}"/>
<path refid="lib.path"/>
<path refid="${name}.common.classpath"/>
</path>
<!-- ======================================
Section: Initializing
====================================== -->
<target name="init">
<!-- Path containing third-party libraries deployed directly with couchbase-client.
This does not include anything that Ivy can retrieve for us.
-->
<path id="lib.path">
<fileset dir="${lib.dir}">
<include name="*.jar" />
</fileset>
</path>
<!-- Classpath for unit tests (superset of compile.classpath) -->
<path id="test.classpath">
<pathelement location="${build.test.classes}" />
<path refid="compile.classpath" />
</path>
</target>
<target name="ivy-probe-antlib" >
<condition property="ivy.found">
<typefound uri="antlib:org.apache.ivy.ant" name="cleancache"/>
</condition>
</target>
<target name="ivy-download" unless="offline">
<mkdir dir="${lib.dir}" />
<get src="${ivy_repo_url}" dest="${ivy.jar}" usetimestamp="true"/>
</target>
<target name="ivy-init-antlib" depends="ivy-download,ivy-probe-antlib"
unless="ivy.found">
<typedef uri="antlib:org.apache.ivy.ant" onerror="fail"
loaderRef="ivyLoader">
<classpath>
<pathelement location="${ivy.jar}"/>
</classpath>
</typedef>
<fail >
<condition >
<not>
<typefound uri="antlib:org.apache.ivy.ant" name="cleancache"/>
</not>
</condition>
You need Apache Ivy 2.0 or later from http://ant.apache.org/
It could not be loaded from ${ivy_repo_url}
</fail>
</target>
<target name="ivy-init" depends="ivy-init-antlib" unless="ivy.configured">
<ivy:configure settingsid="${name}.ivy.settings" file="${ivysettings.xml}"/>
<property name="ivy.configured" value="true" />
</target>
<!-- ======================================
Section: Resolving and Retrieving
====================================== -->
<target name="ivy-resolve" depends="ivy-init">
<ivy:resolve settingsRef="${name}.ivy.settings" conf="common" />
</target>
<target name="ivy-retrieve" depends="ivy-resolve">
<ivy:retrieve settingsRef="${name}.ivy.settings" conf="common"
pattern="${build.ivy.lib.dir}/${ivy.artifact.retrieve.pattern}" sync="true" />
<ivy:cachepath pathid="${name}.common.classpath" conf="common" />
</target>
<!-- retrieve ivy-managed artifacts for checkstyle -->
<target name="ivy-resolve-checkstyle" depends="ivy-init">
<ivy:resolve settingsRef="${name}.ivy.settings" conf="checkstyle" />
</target>
<target name="ivy-retrieve-checkstyle" depends="ivy-resolve-checkstyle">
<ivy:retrieve settingsRef="${name}.ivy.settings"
pattern="${build.ivy.lib.dir}/${ivy.artifact.retrieve.pattern}" sync="true" />
<ivy:cachepath pathid="${name}.checkstyle.classpath" conf="checkstyle" />
</target>
<!-- retrieve ivy-managed artifacts for checkstyle -->
<target name="ivy-resolve-findbugs" depends="ivy-init">
<ivy:resolve settingsRef="${name}.ivy.settings" conf="findbugs" />
</target>
<target name="ivy-retrieve-findbugs" depends="ivy-resolve-findbugs">
<ivy:retrieve settingsRef="${name}.ivy.settings"
pattern="${build.ivy.lib.dir}/${ivy.artifact.retrieve.pattern}" sync="true" />
<ivy:cachepath pathid="${name}.findbugs.classpath" conf="findbugs" />
</target>
<!-- ======================================
Section: Testing and Reporting
====================================== -->
<target name="report" depends="ivy-retrieve"
description="Generates a report of dependencies">
<ivy:report todir="${build.dir}"/>
</target>
<target name="test" depends="compile, compile-test"
description="Run couchbase-client unit tests">
<echo>IPV4 address ${server.address_v4}</echo>
<echo>IPV6 address ${server.address_v6}</echo>
<echo>Test Type (unit|ci) ${test.type}</echo>
<delete dir="${junit.dir}"/>
<mkdir dir="${junit.dir}/data"/>
<junit fork="yes" timeout="5400000" failureproperty="junit.failure" showoutput="true">
<batchtest todir="${junit.dir}/data" fork="yes">
<fileset dir="${test.dir}">
<include name="**/*Test.java"/>
</fileset>
<formatter type="xml"/>
</batchtest>
<jvmarg value="-ea" />
<sysproperty key="server.address_v4" value="${server.address_v4}"/>
<sysproperty key="server.address_v6" value="${server.address_v6}"/>
<sysproperty key="server.type" value="${server.type}"/>
<sysproperty key="test.type" value="${test.type}"/>
<formatter type="plain" usefile="false" />
<classpath refid="test.classpath" />
</junit>
<mkdir dir="${junit.dir}/tmp"/>
<junitreport todir="${junit.dir}/tmp">
<fileset dir="${junit.dir}/data"/>
<report todir="${junit.dir}"/>
</junitreport>
<delete dir="${junit.dir}/tmp"/>
<fail if="junit.failure" message="Unit test(s) failed. See reports!"/>
</target>
<target name="junitreport">
<mkdir dir="${junit.out.dir.html}"/>
<junitreport todir="${junit.out.dir.html}">
<fileset dir="${junit.out.dir.xml}">
<include name="*.xml"/>
</fileset>
<report format="frames" todir="${junit.out.dir.html}"/>
</junitreport>
</target>
<target name="compile-test" depends="compile"
description="Compile test classes">
<mkdir dir="${build.test.classes}" />
<javac
encoding="${build.encoding}"
srcdir="${test.dir}"
includes="**/*.java"
destdir="${build.test.classes}"
debug="${javac.debug}">
<classpath>
<path refid="test.classpath"/>
</classpath>
</javac>
</target>
<!-- =======================================
Section: Documentation Generation
======================================= -->
<target name="javadoc-uptodate" depends="init">
<uptodate property="javadoc.is.uptodate">
<srcfiles dir="${src.dir}">
<include name="**/*.java" />
<include name="**/*.html" />
</srcfiles>
<mapper type="merge" to="${build.javadoc}/index.html" />
</uptodate>
</target>
<target name="docs" description="Build javadoc"
depends="init,javadoc-uptodate,compile" unless="javadoc.is.uptodate">
<mkdir dir="${build.javadoc}" />
<exec executable="date" outputproperty="year">
<arg value="+%Y" />
</exec>
<javadoc
packagenames="src"
sourcepath="${src.dir}"
destdir="${build.javadoc}"
author="true"
version="true"
use="true"
windowtitle="${name} ${version} API"
doctitle="${name} ${version} API"
bottom="Copyright &amp;copy; 2006-2009 Dustin Sallings, 2009-2012 Couchbase, Inc.">
<packageset dir="${src.dir}">
<include name="**" />
</packageset>
<classpath>
<path refid="${name}.common.classpath" />
</classpath>
</javadoc>
</target>
<target name="docsjar" depends="docs"
description="Create the documentation jar">
<zip destfile="${build.dir}/javadocs/${name}-${version}.jar"
basedir="${build.javadoc}" />
</target>
<!-- =======================================
Section: Compiling and Packaging
======================================= -->
<target name="gen-version" depends="init">
<exec executable="git" resultproperty="err" outputproperty="result">
<arg value="describe" />
<arg value="--abbrev=0" />
</exec>
<if>
<equals arg1="${err}" arg2="0"/>
<then>
<var name="version" value="${result}"/>
</then>
</if>
<exec executable="${script.src.dir}/write-version-info.sh"
dir="${basedir}" failonerror="true">
<arg value="${build.dir}" />
<arg value="${version}" />
<arg value="${git.hash}" />
</exec>
</target>
<target name="compile" depends="ivy-init, gen-version, ivy-retrieve"
description="Compile and run the project">
<mkdir dir="${build.classes}" />
<javac
encoding="${build.encoding}"
srcdir="${src.dir}"
includes="**/*.java"
destdir="${build.classes}"
debug="${javac.debug}"
deprecation="${javac.deprecation}">
<classpath refid="${name}.common.classpath" />
</javac>
<javac
encoding="${build.encoding}"
srcdir="${build.src.dir}"
includes="**/*.java"
destdir="${build.classes}"
debug="${javac.debug}"
deprecation="${javac.deprecation}">
<classpath refid="${name}.common.classpath"/>
</javac>
<move file="${build.src.dir}/com/couchbase/client/changelog.txt"
tofile="${build.classes}/com/couchbase/client/changelog.txt" />
</target>
<target name="srcjar" depends="init,jar"
description="Create source jars">
<mkdir dir="${build.dir}" />
<jar jarfile="${build.dir}/sources/${name}-${version}.jar">
<fileset dir="${src.dir}" />
<fileset dir="${build.src.dir}" />
</jar>
<jar jarfile="${build.dir}/sources/${name}-test-${version}.jar">
<fileset dir="${test.dir}" />
</jar>
</target>
<target name="jar" depends="compile,compile-test" description="Creates a jar file for the library">
<jar jarfile="${build.dir}/jars/${name}-${version}.jar" basedir="${build.classes}">
<manifest>
<attribute name="Implementation-Title" value="java memcached client" />
<attribute name="Implementation-Version" value="${version}" />
<attribute name="Implementation-Vendor" value="${copyright}" />
<attribute name="Copyright" value="${copyright}" />
<attribute name="Main-Class" value="com.couchbase.client.BuildInfo" />
</manifest>
</jar>
<jar jarfile="${build.dir}/jars/${name}-test-${version}.jar" basedir="${build.test.classes}"/>
</target>
<target name="package" depends="jar,srcjar,docsjar"
description="Packages files for distribution"/>
<!-- ======================================
Section: Checkstyle Integration
====================================== -->
<target name="checkstyle" depends="ivy-retrieve-checkstyle, compile"
description="Check source code conventions">
<taskdef resource="checkstyletask.properties">
<classpath refid="${name}.checkstyle.classpath" />
</taskdef>
<mkdir dir="${checkstyle.report.dir}" />
<checkstyle config="${checkstyle.xml}" failOnViolation="false">
<fileset dir="${base.src.dir}" includes="**/*.java" />
<classpath refid="test.classpath"/>
<formatter type="xml"
toFile="${checkstyle.report.dir}/checkstyle-errors.xml" />
</checkstyle>
<xslt style="${checkstyle.format.xsl}"
in="${checkstyle.report.dir}/checkstyle-errors.xml"
out="${checkstyle.report.dir}/checkstyle-errors.html" />
</target>
<!-- ======================================
Section: Maven Support
====================================== -->
<target name="mvn-prep" depends="gen-version, ivy-init"
description="Creates maven files">
<property name="couchbase-client.pom" value="${mvn.build.dir}/poms/couchbase-client-${version}.pom" />
<property name="couchbase-client-test.pom" value="${mvn.build.dir}/poms/couchbase-client-test-${version}.pom" />
<!-- Download maven -->
<mkdir dir="${build.dir}" />
<get src="${mvn_repo_url}" dest="${mvn.jar}" usetimestamp="true" />
<!-- Register mvn tasks -->
<path id="mvn-ant-task.classpath" path="${mvn.jar}" />
<typedef resource="org/apache/maven/artifact/ant/antlib.xml"
uri="urn:maven-artifact-ant"
classpathref="mvn-ant-task.classpath"/>
<!-- generate our poms from our ivy files. -->
<mkdir dir="${mvn.build.dir}/poms" />
<ivy:makepom ivyfile="ivy/couchbase-client.xml"
pomfile="${couchbase-client.pom}"
settingsRef="${name}.ivy.settings">
<mapping conf="default" scope="compile" />
<mapping conf="runtime" scope="runtime" />
</ivy:makepom>
<ivy:makepom ivyfile="ivy/couchbase-client-test.xml"
pomfile="${couchbase-client-test.pom}"
settingsRef="${name}.ivy.settings">
<mapping conf="default" scope="compile" />
<mapping conf="runtime" scope="runtime" />
</ivy:makepom>
<!-- Change the version in the pom file to reflect our claimed version. -->
<replaceregexp>
<regexp pattern="&lt;version&gt;.*&lt;/version&gt;" />
<substitution expression="&lt;version&gt;${version}&lt;/version&gt;" />
<fileset dir="${mvn.build.dir}/poms">
<include name="*.pom" />
</fileset>
</replaceregexp>
</target>
<target name="mvn-install" depends="jar,srcjar,package,mvn-prep"
description="Install couchbase-client in local m2 repository">
<!-- @todo: change to use ivy publish -->
<artifact:pom id="couchbase-client" file="${couchbase-client.pom}" />
<artifact:install file="${build.dir}/jars/${name}-${version}.jar">
<pom refid="${name}" />
<attach file="${build.dir}/sources/${name}-${version}.jar"
classifier="sources" />
<attach file="${build.dir}/javadocs/${name}-${version}.jar"
classifier="javadocs" />
</artifact:install>
<artifact:pom id="couchbase-client-test" file="${couchbase-client-test.pom}" />
<artifact:install file="${build.dir}/jars/${name}-test-${version}.jar">
<pom refid="${name}-test" />
<attach file="${build.dir}/sources/${name}-test-${version}.jar"
classifier="sources" />
</artifact:install>
</target>
<!-- ======================================
Section: Stage Maven locally
====================================== -->
<target name="mvn-stage" depends="package,ivy-init,mvn-prep" description="publish jar/source to maven repo mounted at ~/repo">
<ivy:publish resolver="share-m2" forcedeliver="true" overwrite="true" publishivy="false">
<artifacts pattern="build/[type]s/[artifact]-[revision].[ext]" />
</ivy:publish>
</target>
<!-- ======================================
Section: Findbugs Integration
====================================== -->
<target name="findbugs" depends="check-for-findbugs, jar"
description="Run FindBugs">
<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"
classpath="${findbugs.home}/lib/findbugs-ant.jar" />
<mkdir dir="${findbugs.out.dir}"/>
<findbugs home="${findbugs.home}" output="xml:withMessages"
outputFile="${findbugs.output.xml.file}" effort="max"
jvmargs="-Xms512m -Xmx512m">
<auxClasspath>
<path refid="${name}.common.classpath"/>
</auxClasspath>
<sourcePath path="${src.dir}" />
<sourcePath path="${test.dir}" />
<class location="${build.dir}/${dest.jar}" />
</findbugs>
<xslt style="${findbugs.home}/src/xsl/default.xsl"
in="${findbugs.output.xml.file}"
out="${findbugs.output.html.file}" />
</target>
<target name="warn-findbugs-unset" unless="findbugs.home">
<fail message="You need to set -Dfindbugs.home=/path/to/findbugs" />
</target>
<target name="check-for-findbugs" depends="warn-findbugs-unset">
<available property="findbugs.present"
file="${findbugs.home}/lib/findbugs.jar" />
</target>
<!-- ======================================
Section: IDE Integration
====================================== -->
<target name="eclipse" description="Generate Eclipse project"
depends="init, ivy-retrieve">
<taskdef name="eclipse" classname="prantl.ant.eclipse.EclipseTask"
classpath="${lib.dir}/ant-eclipse-1.0-jvm1.2.jar" />
<eclipse failonerror="true" updatealways="true">
<project name="${name}" />
<classpath>
<source path="${src.dir}" />
<source path="${test.dir}" />
<output path="${build.dir}/eclipse-build" />
<library pathref="${name}.common.classpath" />
</classpath>
</eclipse>
</target>
<!-- =================================
Section: Cleaning
================================= -->
<target name="clean" description="Clean the project">
<delete includeemptydirs="true">
<fileset dir="${basedir}">
<exclude name="src/**" />
<exclude name="ivy/**" />
<exclude name="etc/**" />
<exclude name="lib/ant*" />
<exclude name="xdocs/**" />
<exclude name="build.xml" />
<exclude name="config.properties" />
<exclude name="ivy.xml" />
<exclude name="LICENSE.txt" />
<exclude name="README.markdown" />
</fileset>
</delete>
</target>
</project>
Jump to Line
Something went wrong with that request. Please try again.