blob: 95b058c565e45458883a56ea27e047fe95bac391 [file] [log] [blame]
<project name="plexi" default="build" basedir=".">
<description>GSA Adaptor library</description>
<tstamp/>
<property name="src.dir" location="src"/>
<property name="test.dir" location="test"/>
<property name="test.class" value="*Test"/>
<property name="build.dir" location="build"/>
<property name="build-src.dir" location="${build.dir}/src"/>
<property name="build-test.dir" location="${build.dir}/test"/>
<property name="build-instrument.dir" location="${build.dir}/instrument"/>
<property name="dist.dir" location="dist"/>
<property name="javadoc.dir" location="${build.dir}/javadoc"/>
<property name="resource.dir" location="resources"/>
<property name="lib.dir" location="lib"/>
<property name="junit.jar" location="${lib.dir}/junit-4.8.2.jar"/>
<property name="adaptor.pkg.dir" value="com/google/enterprise/adaptor"/>
<property name="adaptor.pkg.name" value="com.google.enterprise.adaptor"/>
<property name="adaptor.class"
value="${adaptor.pkg.name}.examples.AdaptorTemplate"/>
<property name="adaptor.args" value=""/>
<property name="cobertura.dir" value="${basedir}/../cobertura/"/>
<!-- Adaptor suffix for distribution files. Useful for placing version numbers
on our jars. -->
<condition property="adaptorlib.suffix" value="-${adaptorlib.version}">
<isset property="adaptorlib.version"/>
</condition>
<!-- If adaptorlib.version isn't set, simply use the current date. -->
<property name="adaptorlib.suffix" value="-${DSTAMP}"/>
<path id="adaptorlib.build.classpath">
<fileset dir="${lib.dir}">
<include name="json_simple-1.1.jar"/>
<include name="gdata-core-1.0.jar"/>
<include name="gdata-gsa-1.0.jar"/>
<include name="joda-time-1.6.jar"/>
<include name="opensaml-2.3.2.jar"/>
<include name="openws-1.3.1.jar"/>
<include name="xmltooling-1.2.2.jar"/>
<include name="guava-11.0.2.jar"/>
<include name="jsr305.jar"/>
<include name="gson-2.0.jar"/>
<include name="velocity-1.5.jar"/>
<include name="commons-daemon-1.0.15.jar"/>
</fileset>
</path>
<path id="adaptorlib.run.classpath">
<path refid="adaptorlib.build.classpath"/>
<pathelement location="${resource.dir}"/>
<path refid="secmgr.run.classpath"/>
<path refid="opensaml.run.classpath"/>
</path>
<path id="examples.build.classpath">
<fileset dir="${lib.dir}">
<include name="opencsv-2.3.jar"/>
<include name="j-calais-0.2.1.jar"/>
</fileset>
</path>
<path id="examples.run.classpath">
<path refid="examples.build.classpath"/>
<fileset dir="${lib.dir}">
<include name="jackson-core-asl-1.5.5.jar"/>
<include name="jackson-jaxrs-1.5.5.jar"/>
<include name="jackson-mapper-asl-1.5.5.jar"/>
<include name="jersey-client-1.3.jar"/>
<include name="jersey-core-1.3.jar"/>
<include name="jsr311-api-1.1.1.jar"/>
</fileset>
</path>
<path id="secmgr.build.classpath">
<path refid="secmgr.run.classpath"/>
<fileset dir="${lib.dir}">
<!--include name="guice-3.0.jar"/-->
<include name="jsr305.jar"/>
<include name="servlet-api.jar"/>
<!-- Dependencies that are in common with opensaml. -->
<include name="joda-time-1.6.jar"/>
<include name="opensaml-2.3.2.jar"/>
<include name="openws-1.3.1.jar"/>
<include name="slf4j-api-1.5.10.jar"/>
<include name="xmltooling-1.2.2.jar"/>
</fileset>
</path>
<path id="secmgr.run.classpath">
<fileset dir="${lib.dir}">
<include name="guava-11.0.2.jar"/>
<include name="gson-2.0.jar"/>
</fileset>
</path>
<path id="opensaml.run.classpath">
<fileset dir="${lib.dir}">
<include name="bcprov-jdk15-1.45.jar"/>
<!--include name="commons-codec-1.3.jar"/-->
<include name="commons-collections-3.1.jar"/>
<!--include name="commons-httpclient-3.1.jar"/-->
<include name="commons-lang-2.1.jar"/>
<!--include name="jcip-annotations-1.0.jar"/-->
<!--include name="jcl-over-slf4j-1.5.10.jar"/-->
<include name="joda-time-1.6.jar"/>
<!--include name="jul-to-slf4j-1.5.10.jar"/-->
<!--include name="log4j-over-slf4j-1.5.10.jar"/-->
<!--include name="not-yet-commons-ssl-0.3.9.jar"/-->
<include name="opensaml-2.3.2.jar"/>
<include name="openws-1.3.1.jar"/>
<include name="slf4j-api-1.5.10.jar"/>
<include name="velocity-1.5.jar"/>
<include name="xmlsec-1.4.3.jar"/>
<include name="xmltooling-1.2.2.jar"/>
<!-- Libraries that are supposed to be endorsed, that we aren't having
endorsed. -->
<!--include name="resolver-2.9.1.jar"/-->
<!--include name="serializer-2.9.1.jar"/-->
<!--include name="xalan-2.7.1.jar"/-->
<include name="xercesImpl-2.9.1.jar"/>
<!--include name="xml-apis-2.9.1.jar"/-->
<!-- Additional dependencies not included with opensaml. -->
<include name="slf4j-jdk14-1.5.10.jar"/>
<include name="commons-logging-api-1.1.1.jar"/>
</fileset>
</path>
<path id="cobertura.classpath">
<fileset dir="${cobertura.dir}" erroronmissingdir="false">
<include name="cobertura.jar"/>
<include name="lib/**/*.jar"/>
</fileset>
</path>
<target name="-check-instrument-uptodate">
<uptodate property="instrument.uptodate"
targetfile="${build-instrument.dir}/cobertura.ser">
<srcfiles dir="${build-src.dir}"/>
</uptodate>
</target>
<target name="build"
depends="-real-build,-check-instrument-uptodate,clean-instrument"
description="Build source"/>
<target name="-real-build">
<mkdir dir="${build-src.dir}"/>
<!-- Compile secmgr. -->
<javac srcdir="${src.dir}" destdir="${build-src.dir}" debug="true"
includeantruntime="false" encoding="utf-8" target="1.6" source="1.6">
<classpath refid="secmgr.build.classpath"/>
<exclude name="${adaptor.pkg.dir}/**"/>
</javac>
<!-- Compile adaptorlib. -->
<javac srcdir="${src.dir}" destdir="${build-src.dir}" debug="true"
includeantruntime="false" encoding="utf-8" target="1.6" source="1.6">
<compilerarg value="-Xlint:unchecked"/>
<compilerarg value="-Xlint:deprecation"/>
<classpath refid="adaptorlib.build.classpath"/>
<exclude name="${adaptor.pkg.dir}/examples/**"/>
<exclude name="${adaptor.pkg.dir}/experimental/**"/>
<include name="${adaptor.pkg.dir}/**"/>
</javac>
<!-- Compile examples. -->
<javac srcdir="${src.dir}" destdir="${build-src.dir}" debug="true"
includeantruntime="false" encoding="utf-8" target="1.6" source="1.6">
<compilerarg value="-Xlint:unchecked"/>
<classpath refid="examples.build.classpath"/>
<include name="${adaptor.pkg.dir}/examples/**"/>
</javac>
<mkdir dir="${build-test.dir}"/>
<!-- Compile JUnit helper -->
<javac srcdir="${lib.dir}" destdir="${build-test.dir}" debug="true"
includeantruntime="true" encoding="utf-8" target="1.6" source="1.6">
<compilerarg value="-Xlint:unchecked"/>
<classpath location="${junit.jar}"/>
<include name="JUnitLogFixFormatter.java"/>
</javac>
<!-- Compile tests, excluding example and experimental tests. -->
<javac srcdir="${test.dir}" destdir="${build-test.dir}" debug="true"
includeantruntime="false" encoding="utf-8" target="1.6" source="1.6">
<compilerarg value="-Xlint:unchecked"/>
<classpath refid="adaptorlib.build.classpath"/>
<classpath location="${build-src.dir}"/>
<classpath location="${junit.jar}"/>
<exclude name="${adaptor.pkg.dir}/examples/**"/>
<exclude name="${adaptor.pkg.dir}/experimental/**"/>
</javac>
<!-- Compile tests for examples. -->
<javac srcdir="${test.dir}" destdir="${build-test.dir}" debug="true"
includeantruntime="false" encoding="utf-8" target="1.6" source="1.6">
<compilerarg value="-Xlint:unchecked"/>
<classpath refid="examples.build.classpath"/>
<classpath location="${build-src.dir}"/>
<classpath location="${junit.jar}"/>
<include name="${adaptor.pkg.dir}/examples/**"/>
</javac>
<!-- Compile experimental code. -->
<javac srcdir="${src.dir}" destdir="${build-src.dir}" debug="true"
includeantruntime="false" encoding="utf-8" target="1.6" source="1.6">
<compilerarg value="-Xlint:unchecked"/>
<classpath refid="adaptorlib.build.classpath"/>
<classpath location="${lib.dir}/commons-fileupload-1.3.jar"/>
<include name="${adaptor.pkg.dir}/experimental/**"/>
</javac>
<!-- Compile tests for experimental. -->
<javac srcdir="${test.dir}" destdir="${build-test.dir}" debug="true"
includeantruntime="false" encoding="utf-8" target="1.6" source="1.6">
<compilerarg value="-Xlint:unchecked"/>
<classpath refid="adaptorlib.build.classpath"/>
<classpath location="${build-src.dir}"/>
<classpath location="${junit.jar}"/>
<include name="${adaptor.pkg.dir}/experimental/**"/>
</javac>
</target>
<target name="-discover-version" unless="adaptorlib.version">
<exec executable="git" outputproperty="adaptorlib.version"
logError="true" failifexecutionfails="false">
<arg value="describe"/>
<arg value="--always"/>
</exec>
<!-- Set version if git describe failed. -->
<property name="adaptorlib.version" value="unknown"/>
</target>
<target name="dist" description="Generate distribution binaries"
depends="clean,test,package"/>
<target name="package" description="Generate binaries"
depends="build,javadoc,-discover-version">
<property name="dist.staging.dir" value="${build.dir}/dist/staging"/>
<delete dir="${build.dir}/dist"/>
<delete dir="${dist.dir}"/>
<mkdir dir="${build.dir}/dist"/>
<mkdir dir="${build.dir}/dist/staging"/>
<mkdir dir="${build.dir}/dist/staging/examples"/>
<mkdir dir="${dist.dir}"/>
<!-- Produce intermediate distribution files -->
<copy file="LICENSE.txt" todir="${dist.staging.dir}"/>
<copy file="THIRDPARTYLICENSE.txt" todir="${dist.staging.dir}"/>
<!-- adaptor.jar -->
<jar destfile="${dist.staging.dir}/adaptor${adaptorlib.suffix}.jar"
basedir="${build-src.dir}" excludes="${adaptor.pkg.dir}/examples/**">
<manifest>
<section name="com/google/enterprise/adaptor/">
<attribute name="Implementation-Title"
value="Google Adaptor Library"/>
<attribute name="Implementation-Vendor" value="Google Inc."/>
<attribute name="Implementation-Version"
value="${adaptorlib.version}"/>
</section>
</manifest>
<fileset dir="${resource.dir}"/>
</jar>
<!-- adaptor-src.jar -->
<jar destfile="${dist.staging.dir}/adaptor${adaptorlib.suffix}-src.jar"
basedir="${src.dir}" excludes="${adaptor.pkg.dir}/examples/**">
<fileset dir="${resource.dir}"/>
</jar>
<!-- lib/ -->
<!-- Concatenate dependent JARs together into a comma-delimited list. -->
<pathconvert pathsep="," refid="adaptorlib.run.classpath"
property="tmp.adaptorlib.fileset">
<!-- We remove the lib.dir from the paths to prevent trouble with comma
and space in lib.dir. It also makes it nicer <echo>ing
tmp.adaptorlib.fileset. -->
<map from="${lib.dir}/" to=""/>
</pathconvert>
<copy todir="${dist.staging.dir}/lib">
<fileset dir="${lib.dir}" includes="${tmp.adaptorlib.fileset}"/>
</copy>
<!-- adaptor-withlib.jar -->
<jar destfile="${build.dir}/dist/adaptor-withlib.tmp.jar"
filesetmanifest="mergewithoutmain">
<!-- Provide an empty manifest to encourage mergewithoutmain to function.
See https://issues.apache.org/bugzilla/show_bug.cgi?id=54171 . -->
<manifest/>
<zipfileset src="${dist.staging.dir}/adaptor${adaptorlib.suffix}.jar"/>
<zipgroupfileset dir="${dist.staging.dir}/lib"/>
</jar>
<!-- Re-save JAR without signing keys, since keeping them in the JAR causes
security exceptions. -->
<zip destfile="${dist.staging.dir}/adaptor${adaptorlib.suffix}-withlib.jar">
<zipfileset excludes="META-INF/**/*.DSA,META-INF/**/*.SF"
src="${build.dir}/dist/adaptor-withlib.tmp.jar"/>
</zip>
<!-- adaptor-examples.jar -->
<pathconvert pathsep="," refid="examples.run.classpath"
property="tmp.examples.zipgroup">
<map from="${lib.dir}/" to=""/>
</pathconvert>
<jar destfile="${dist.staging.dir}/examples/adaptor${adaptorlib.suffix}-examples.jar"
basedir="${build-src.dir}" includes="${adaptor.pkg.dir}/examples/**">
<manifest>
<section name="com/google/enterprise/adaptor/examples/">
<attribute name="Implementation-Title"
value="Google Example Adaptors"/>
<attribute name="Implementation-Vendor" value="Google Inc."/>
<attribute name="Implementation-Version"
value="${adaptorlib.version}"/>
</section>
</manifest>
<zipgroupfileset dir="${lib.dir}" includes="${tmp.examples.zipgroup}"/>
<fileset dir="${src.dir}"
includes="${adaptor.pkg.dir}/examples/**/*.java"/>
</jar>
<!-- example Command Line Adaptor scripts -->
<copy todir="${dist.staging.dir}">
<fileset dir="${basedir}" includes="examples/*"/>
</copy>
<!-- adaptor-docs.zip -->
<zip destfile="${dist.staging.dir}/adaptor${adaptorlib.suffix}-docs.zip"
basedir="${javadoc.dir}"/>
<!-- Produce final distribution files -->
<!-- adaptor-src.zip -->
<zip destfile="${dist.dir}/adaptor${adaptorlib.suffix}-src.zip"
basedir="${basedir}">
<exclude name="**/.*/**"/>
<!-- Normal private files -->
<exclude name="build/**"/>
<exclude name="dist/**"/>
<exclude name="adaptor-config.properties"/>
<exclude name="cacerts.jks"/>
<exclude name="keys.jks"/>
<exclude name="adaptor.crt"/>
<exclude name="gsa.crt"/>
<!-- IntelliJ files -->
<exclude name="workspace/**"/>
<exclude name="classes/**"/>
<exclude name=".idea"/>
<exclude name="Plexi.iml"/>
<!-- NetBeans files -->
<exclude name="nbproject/**"/>
</zip>
<!-- adaptor-bin.zip -->
<move file="${dist.staging.dir}"
tofile="${build.dir}/dist/adaptor${adaptorlib.suffix}"/>
<zip destfile="${dist.dir}/adaptor${adaptorlib.suffix}-bin.zip"
basedir="${build.dir}/dist/adaptor${adaptorlib.suffix}"/>
</target>
<target name="-javadoc-test-uptodate">
<uptodate property="javadoc.uptodate"
targetfile="${javadoc.dir}/index.html">
<srcfiles dir="${src.dir}"/>
</uptodate>
</target>
<target name="javadoc" description="Build JavaDocs"
depends="-javadoc-test-uptodate" unless="javadoc.uptodate">
<javadoc sourcepath="${src.dir}" destdir="${javadoc.dir}"
overview="${src.dir}/overview.html"
packagenames="${adaptor.pkg.name},${adaptor.pkg.name}.**">
<classpath refid="adaptorlib.build.classpath"/>
<classpath refid="secmgr.build.classpath"/>
<classpath refid="examples.build.classpath"/>
<classpath location="${lib.dir}/commons-fileupload-1.3.jar"/>
<link href="http://download.oracle.com/javase/6/docs/jre/api/net/httpserver/spec/"/>
<link href="http://download.oracle.com/javase/6/docs/api/"/>
<link href="http://commons.apache.org/proper/commons-daemon/apidocs/"/>
<arg value="-quiet"/>
<arg value="-notimestamp"/>
</javadoc>
</target>
<target name="clean" description="Remove build output">
<delete dir="${build.dir}"/>
<delete dir="${dist.dir}"/>
</target>
<target name="run" depends="build" description="Run default adaptor">
<java classpath="${build-src.dir}" fork="true" classname="${adaptor.class}">
<classpath refid="adaptorlib.run.classpath"/>
<sysproperty key="java.util.logging.config.file"
value="${src.dir}/logging.properties"/>
<sysproperty key="javax.net.ssl.keyStore" file="keys.jks"/>
<sysproperty key="javax.net.ssl.keyStoreType" value="jks"/>
<sysproperty key="javax.net.ssl.keyStorePassword" value="changeit"/>
<sysproperty key="javax.net.ssl.trustStore" file="cacerts.jks"/>
<sysproperty key="javax.net.ssl.trustStoreType" value="jks"/>
<sysproperty key="javax.net.ssl.trustStorePassword" value="changeit"/>
<arg line="${adaptor.args}"/>
</java>
</target>
<target name="group_writer" depends="build" description="Run group writer">
<java classpath="${build-src.dir}" fork="true"
classname="${adaptor.pkg.name}.examples.GroupDefinitionsWriter">
<classpath refid="adaptorlib.run.classpath"/>
<sysproperty key="java.util.logging.config.file"
value="${src.dir}/logging.properties"/>
<sysproperty key="javax.net.ssl.keyStore" file="keys.jks"/>
<sysproperty key="javax.net.ssl.keyStoreType" value="jks"/>
<sysproperty key="javax.net.ssl.keyStorePassword" value="changeit"/>
<sysproperty key="javax.net.ssl.trustStore" file="cacerts.jks"/>
<sysproperty key="javax.net.ssl.trustStoreType" value="jks"/>
<sysproperty key="javax.net.ssl.trustStorePassword" value="changeit"/>
<arg line="${adaptor.args}"/>
</java>
</target>
<target name="sim" depends="build" description="run simulator">
<java classpath="${build-src.dir}" fork="true"
classname="com.google.enterprise.adaptor.experimental.Sim">
<classpath refid="adaptorlib.run.classpath"/>
<classpath location="${lib.dir}/commons-fileupload-1.3.jar"/>
<sysproperty key="java.util.logging.config.file"
value="${src.dir}/logging.properties"/>
</java>
</target>
<target name="coverage" depends="instrument,test,coverage-report"
description="Run instrumented tests and generate coverage report"/>
<target name="test" depends="build" description="Run JUnit tests">
<junit printsummary="yes" haltonfailure="yes" forkmode="once" fork="true"
dir="${basedir}" maxmemory="512m">
<sysproperty key="net.sourceforge.cobertura.datafile"
file="${build-instrument.dir}/cobertura.ser"/>
<!-- test-keys.jks created with:
keytool -genkeypair -alias adaptor -keystore test/test-keys.jks
-keyalg RSA -validity 1000000 -storepass changeit -dname
"CN=localhost, OU=Unknown, O=Unknown, L=Unknown, ST=Unknown,
C=Unknown" -keypass changeit
-->
<sysproperty key="javax.net.ssl.keyStore"
file="${test.dir}/test-keys.jks"/>
<sysproperty key="javax.net.ssl.keyStoreType" value="jks"/>
<sysproperty key="javax.net.ssl.keyStorePassword" value="changeit"/>
<!-- test-cacerts.jks created with:
keytool -exportcert -alias adaptor -keystore test/test-keys.jks -rfc
-file tmp.crt -storepass changeit
keytool -importcert -keystore test/test-cacerts.jks -file tmp.crt
-storepass changeit -noprompt -alias adaptor
rm tmp.crt
-->
<sysproperty key="javax.net.ssl.trustStore"
file="${test.dir}/test-cacerts.jks"/>
<sysproperty key="javax.net.ssl.trustStoreType" value="jks"/>
<sysproperty key="javax.net.ssl.trustStorePassword" value="changeit"/>
<classpath refid="adaptorlib.run.classpath"/>
<classpath refid="examples.run.classpath"/>
<classpath refid="cobertura.classpath"/>
<classpath location="${junit.jar}"/>
<classpath location="${build-instrument.dir}"/>
<classpath location="${build-src.dir}"/>
<classpath location="${build-test.dir}"/>
<classpath location="${resource.dir}"/>
<!-- Some resources are in the test directory itself. -->
<classpath location="${test.dir}"/>
<formatter type="plain" usefile="false"/>
<formatter classname="JUnitLogFixFormatter" usefile="false"/>
<batchtest>
<fileset dir="${test.dir}">
<include name="**/${test.class}.java"/>
<exclude name="**/experimental/**"/>
</fileset>
</batchtest>
</junit>
</target>
<target name="sim-test" depends="build">
<junit printsummary="yes" haltonfailure="yes" forkmode="once" fork="true"
dir="${basedir}" maxmemory="512m">
<classpath location="${junit.jar}"/>
<classpath location="${build-src.dir}"/>
<classpath refid="adaptorlib.run.classpath"/>
<classpath location="${build-test.dir}"/>
<classpath location="${lib.dir}/commons-fileupload-1.3.jar"/>
<formatter type="plain" usefile="false"/>
<formatter classname="JUnitLogFixFormatter" usefile="false"/>
<batchtest>
<fileset dir="${test.dir}">
<include name="**/experimental/SimTest.java"/>
</fileset>
</batchtest>
</junit>
</target>
<target name="instrument" depends="build" description="Instrument classes">
<taskdef classpathref="cobertura.classpath" resource="tasks.properties"/>
<cobertura-instrument datafile="${build-instrument.dir}/cobertura.ser"
todir="${build-instrument.dir}">
<fileset dir="${build-src.dir}">
<include name="${adaptor.pkg.dir}/**"/>
</fileset>
</cobertura-instrument>
</target>
<target name="clean-instrument" unless="instrument.uptodate"
description="Delete instrumented classes">
<delete dir="${build-instrument.dir}"/>
</target>
<target name="coverage-report" description="Generates code coverage report">
<taskdef classpathref="cobertura.classpath" resource="tasks.properties"/>
<cobertura-report datafile="${build-instrument.dir}/cobertura.ser"
srcdir="${src.dir}" destdir="${build.dir}/coverage"/>
</target>
</project>