<?xml version="1.0"?>
<project name="Apache Santuario" default="help" basedir=".">

    <!-- G L O B A L    P R O P E R T I E S -->
    <!-- Product name and version properties -->
    <property name="product.Name" value="Apache XML Security for Java"/>
    <property name="product.name" value="xml-security"/>
    <property name="product.shortname" value="xmlsec"/>

    <property name="product.version.major" value="1"/>
    <property name="product.version.minor" value="5"/>
    <property name="product.version.level" value="6"/>
    <property name='product.version.qualifier' value=''/>
    <property name="product.version" 
	  value="${product.version.major}.${product.version.minor}.${product.version.level}${product.version.qualifier}"/>
    <property name="product_version" 
	  value="${product.version.major}_${product.version.minor}_${product.version.level}${product.version.qualifier}"/>
    <property name="year" value="2000-2013"/>
    <property name="copyright" 
			  value="Copyright © ${year} Apache XML Project. All Rights Reserved."/>

    <!-- directory properties -->
    <property name="dir.src"            value="${basedir}/src/main/java" />
    <property name="dir.src.test"       value="${basedir}/src/test/java" />
    <property name="dir.src.samples"    value="${basedir}/samples" />
    <property name="dir.libs"           value="${basedir}/libs" />
    <property name="dir.build"          value="${basedir}/build" />
    <property name="dir.build.bin"      value="${dir.build}/classes" />
    <property name="dir.build.libs"     value="${dir.build}/libs" />
    <property name="dir.build.test"     value="${dir.build}/test" />
    <property name="dir.build.samples"  value="${dir.build}/samples" />
    <property name="dir.build.docs"     value="${dir.build}/docs" />
    <property name="dir.build.docs.xml" value="${dir.build.docs}/xml" />
    <property name="dir.build.docs.html" value="${dir.build.docs}/html" />
    <property name="dir.build.src"      value="${dir.build}/src" />
    <property name="dir.build.dist"     value="${dir.build}/dist" />
    <property name="dir.build.srcdist"  value="${dir.build.dist}/src/${product.name}-${product_version}"/>
    <property name="dir.build.bindist"  value="${dir.build.dist}/bin/${product.name}-${product_version}"/>
    <property name="dir.build.junit.xml"  value="${dir.build.docs.xml}/junit" />
    <property name="dir.build.junit.html" value="${dir.build.docs.html}/junit" />
    <property name="dir.build.javadoc"  value="${dir.build.docs.html}/javadoc" />
    <property name="dir.build.coverage" value="${dir.build.docs.html}/coverage" />
    <property name="dir.manifest"       value="${dir.build.bin}/META-INF"/>

    <!-- library properties -->
    <property name="lib.logging"        value="${dir.libs}/commons-logging-1.1.1.jar" />
    <property name="lib.log4j"          value="${dir.libs}/log4j-1.2.16.jar" />
    <property name="lib.xalan.1"        value="${dir.libs}/xalan-2.7.1.jar" />
    <property name="lib.xalan.2"        value="${dir.libs}/serializer-2.7.1.jar" />
    <property name="lib.xalan.3"        value="${dir.libs}/xml-apis-1.3.04.jar" />
    <property name="lib.xerces.1"       value="${dir.libs}/xercesImpl-2.9.1.jar" />
    <property name="lib.jce"            value="${dir.libs}/${jce.provider.prefix}-${jce.provider.jar}" />
    <property name="lib.junit"		value="${dir.libs}/junit-4.8.2.jar" />
    <property name="lib.clover"		value="${dir.libs}/clover.jar" />

    <!-- Apache Santuario libraries (for bin distribution) -->
    <property name="lib.xmlsec"         value="${dir.libs}/xmlsec-${product.version}.jar" />
    <property name="lib.xmlsec.samples" value="${dir.libs}/xmlsecSamples-${product.version}.jar"/>
    <property name="lib.xmlsec.tests"   value="${dir.libs}/xmlsecTests-${product.version}.jar" />

    <!-- JAR properties -->
    <property name="jar.library"        value="${dir.build}/xmlsec-${product.version}.jar" />
    <property name="jar.samples"        value="${dir.build}/xmlsecSamples-${product.version}.jar" />
    <property name="jar.tests"          value="${dir.build}/xmlsecTests-${product.version}.jar" />
    <property name="jar.manifest"       value="${dir.manifest}/MANIFEST.MF"/>
    

    <!-- build variable properties -->

    <!-- T A S K D E F S -->
    <taskdef resource="clovertasks"/>
	
    <!-- C O N D I T I O N A L    P R O P E R T I E S -->
    <target name="do.build.src" >
        <!-- global properties applies here -->
    </target >

    <!-- P A T H S -->
    <path id="id.classpath.xalan" >
        <pathelement location="${lib.xalan.1}" />
        <pathelement location="${lib.xalan.2}" />
        <pathelement location="${lib.xalan.3}" />
    </path >
    <path id="id.classpath.xerces" >
        <pathelement location="${lib.xerces.1}" />
    </path >
    <path id="id.classpath.logging" >
        <pathelement location="${lib.logging}" />
        <pathelement location="${lib.log4j}" />
    </path >
    <path id="id.classpath.common" >
        <path refid="id.classpath.xalan" />
        <path refid="id.classpath.xerces" />
        <path refid="id.classpath.logging" />
    </path >
    <path id="id.classpath.crypt" >
        <pathelement location="${lib.jce}" />
    </path >
    <path id="id.classpath.coverage" >
    	<pathelement location="${lib.clover}" />
    </path >
    <path id="id.classpath.sig" >
    </path >
    <path id="id.classpath" >
        <path refid="id.classpath.common" />
        <path refid="id.classpath.crypt" />
        <path refid="id.classpath.sig" />
        <!--path refid="id.classpath.coverage" /-->
    </path >
    <path id="id.classpath.test" >
        <path refid="id.classpath" />
        <pathelement path="${lib.junit}"/>
        <pathelement location="${dir.build.bin}" />
        <pathelement location="${dir.build.test}" />
        <path refid="id.classpath.coverage" />
        <pathelement location="${lib.xmlsec}" />
        <pathelement location="${lib.xmlsec.samples}" />
        <pathelement location="${lib.xmlsec.tests}" />
    </path>
    <path id="id.classpath.samples" >
        <path refid="id.classpath" />
        <pathelement location="${dir.build.bin}" />
    	<pathelement location="${dir.build.test}" />    	
        <pathelement location="${dir.build.samples}" />
        <pathelement location="${lib.xmlsec}" />
        <pathelement location="${lib.xmlsec.samples}" />
        <pathelement location="${lib.xmlsec.tests}" />
    </path>

    <!-- P A T T E R N S E T S -->
    <patternset id="id.patternset.distFiles">
	<include name="build.xml"/>
	<include name="pom.xml"/>
	<include name="LICENSE"/>
	<include name="NOTICE"/>
    </patternset>

    <patternset id="id.patternset.srcFiles">
	<include name="src/**/*"/>
    </patternset>
    
    <patternset id="id.patternset.sampleFiles">
	<include name="samples/**/*"/>
    </patternset>
	
    <!-- T A R G E T S -->

    <!-- Welcome screen -->

    <target name="init">
	<echo message=""/>
	<echo message="-------------------------------------------------------------------"/>
	<echo message="--------- ${product.Name} v${product.version} [${year}] -----------"/>
	<echo message="-------------------------------------------------------------------"/>
	<echo message="Building with ${ant.version}"/>
	<echo message="Java ${java.version} located at ${java.home} "/>
	<echo message="-------------------------------------------------------------------"/>
	<echo message=""/>
    </target>

    <!-- environment targets -->
    <!-- set up -->
    <target name="env.mk.dirs" depends="init" unless="has.dirs" >
        <mkdir dir="${dir.build}" />
        <mkdir dir="${dir.build.bin}" />
        <mkdir dir="${dir.build.docs}" />
        <mkdir dir="${dir.build.test}" />
        <mkdir dir="${dir.build.libs}" />
        <mkdir dir="${dir.build.dist}" />
        <mkdir dir="${dir.build.samples}" />
        <property name="has.dirs" value="true" />
    </target >

    <!-- tear down -->
    <target depends="init" name="env.rm.dirs" >
        <delete dir="${dir.build}" />
    </target >
    
    <target depends="init" name="env.rm.files" >
	<delete file="signature.xml"/>
	<delete file="axisSignature.xml"/>
	<delete file="encryptedInfo.xml"/>
	<delete file="decryptedInfo.xml"/>
	<delete file="kek"/>
	<delete>
		<fileset dir="." includes="merlin16*.html,merlins*.xml" />
	</delete>
    </target >

    <target depends="init" name="with.clover" >
    	<clover-setup initstring="clover-db/coverage.db" >
    		<fileset dir="${dir.src}" >
	  		<include name="**/*.java" />
	  		<exclude name="**/*Exception.java" />
		</fileset >
     	</clover-setup >
    </target >

    <!-- check targets -->

    <target name="do.check.bindist">
	<condition property="is.bin.dist">
	    <and>
		<available file="${lib.xmlsec}" />
		<available file="${lib.xmlsec.samples}" />
		<available file="${lib.xmlsec.tests}" />
		<not>
		    <available type="dir" file="src" />
		</not>
	    </and>
	</condition>
    </target>


    <!-- B U I L D  T A R G E T S -->
    <property environment="env"/>
    <!-- source -->
    <target name="build.src"
            depends="do.build.src,env.mk.dirs,do.check.bindist"
			unless="is.bin.dist">
        <javac target="1.5" source="1.5" srcdir="${dir.src}"
               destdir="${dir.build.bin}"
               debug="${build.compile.debug}"
               includeAntRuntime="false">
            <compilerarg value="-XDignore.symbol.file" />
            <classpath refid="id.classpath" />
            <include name="**/org/apache/xml/security/**/*.java" />
            <include name="**/javax/xml/crypto/**/*.java" />
            <include name="**/org/apache/jcp/xml/dsig/internal/**/*.java" />
        </javac >

        <copy todir="${dir.build.bin}" >
            <fileset dir="${dir.src}"
                     includes="**/org/apache/xml/security/resource/*,
                               **/org/apache/xml/security/resource/schema/*"/>
        </copy >
    </target >
    
    <!-- tests -->
    <target name="build.test"
    		depends="build.src"
		unless="is.bin.dist">
    	<javac target="1.5" source="1.5" srcdir="${dir.src.test}"
               destdir="${dir.build.test}"
               debug="${build.compile.debug}"
               includeAntRuntime="false">
        	<classpath refid="id.classpath.test" />
        	<include name="**/org/apache/xml/security/**/*.java" />
        	<include name="**/javax/xml/crypto/**/*.java" />
        </javac>
        <copy todir="${dir.build.test}">
	      	<fileset dir="${dir.src.test}" includes="**/*.properties"/>
      		<fileset dir="${dir.src.test}" includes="**/*.xml"/>
      		<fileset dir="${dir.src.test}" includes="**/*.zip"/>
    	</copy>
    </target>

    <!-- samples -->
    <target name="build.samples"
		depends="build.src"
		unless="is.bin.dist">
	<javac target="1.5" source="1.5" srcdir="${dir.src.samples}"
		destdir="${dir.build.samples}"
		debug="${build.compile.debug}"
        includeAntRuntime="false">
		<classpath refid="id.classpath.samples"/>
	</javac>
        <copy todir="${dir.build.samples}/data">
      		<fileset dir="${dir.src.samples}/data" includes="**/*.xml"/>
      		<fileset dir="${dir.src.samples}/data" includes="**/*.zip"/>
    	</copy>
    </target>


	<!-- T E S T  T A R G E T S -->  
	<!-- big test -->
	<target name="test" depends="build.jar"
		description="Starts all Junit tests">
	    <delete dir="${dir.build.junit.xml}"/>
	    <delete dir="${dir.build.junit.html}"/>
	    <mkdir dir="${dir.build.junit.xml}"/>
	    <mkdir dir="${dir.build.junit.html}"/>
	    <!-- The unit tests include so-called interoperability tests against
	         cryptographic values generated using software from other vendors.
	         This package includes many of these vectors, but not the ones from
	         the IBM alphaWorks XML Security Suite. They are not included because
	         IBM even has these signatures under copyright.
	         If you want to test against IBM, download xss4j from
	
	         http://www.alphaworks.ibm.com/tech/xmlsecuritysuite
	
	         and put the files into the
	
	         src/test/resources/com/ibm/xss4j-20030127/
	
	         directory. If the file enveloped-rsa.sig is found in that directory,
	         IBM is 'magically' included in the test ;-))
	    -->
	    <available file="src/test/resources/com/ibm/xss4j-20030127/enveloped-rsa.sig" property="ibm.available"/>
	    <junit filtertrace="true" fork="true" printsummary="on" 
		   failureproperty="build.test.failed">
	        <jvmarg value="-Djava.compiler=NONE"/>
	        <sysproperty key="basedir" value="${basedir}"/>
                <sysproperty key="proxyHost" value="${proxy.host}"/>
                <sysproperty key="proxyPort" value="${proxy.port}"/>
                <sysproperty key="java.util.logging.config.file" 
			     value="${basedir}/logging.properties"/>
                <sysproperty key="product.version" value="${product.version}"/>
	        <classpath refid="id.classpath.test"/>
	        <formatter type="xml"/>
	        <!-- Also put output to screen -->
	        <formatter type="plain" usefile="false"/>
	        <batchtest fork="yes" todir="${dir.build.junit.xml}">
	            <fileset dir="${dir.src.test}">
	                <include name="org/apache/xml/security/**/*Test.java"/>
	             </fileset>
	        </batchtest>
	        <test if="ibm.available" name="org.apache.xml.security.test.interop.IBMTest" todir="${dir.build.junit.xml}"/>
	    </junit>
	    <junitreport todir="${dir.build.junit.xml}">
	        <fileset dir="${dir.build.junit.xml}">
	            <include name="TEST-*.xml"/>
	        </fileset>
	        <report format="frames" todir="${dir.build.junit.html}"/>
	    </junitreport>
	    <fail if="build.test.failed" message="Unit Tests Failed"/>
	</target>

    <!-- Test JSR 105/XML DSig API -->
    <target name="test_jsr105" depends="build.jar"
	    description="Runs JSR 105 interop and unit tests">
        <delete dir="${dir.build.junit.xml}"/>
        <delete dir="${dir.build.junit.html}"/>
        <mkdir dir="${dir.build.junit.xml}"/>
        <mkdir dir="${dir.build.junit.html}"/>
        <junit filtertrace="true" fork="true" printsummary="on" 
	       failureproperty="build.test.failed">
            <sysproperty key="basedir" value="${basedir}"/>
            <sysproperty key="proxyHost" value="${proxy.host}"/>
	    <sysproperty key="proxyPort" value="${proxy.port}"/>
	    <sysproperty key="java.util.logging.config.file" value="${basedir}/logging.properties"/>
            <classpath refid="id.classpath.test"/>
	    <formatter type="xml"/>
	    <!-- Also put output to screen -->
	    <formatter type="plain" usefile="false"/>
	    <batchtest fork="yes" todir="${dir.build.junit.xml}">
	        <fileset dir="${dir.src.test}">
	            <include name="javax/xml/crypto/**/*Test.java"/>
            </fileset>
            </batchtest>
        </junit>
        <junitreport todir="${dir.build.junit.xml}">
            <fileset dir="${dir.build.junit.xml}">
	        <include name="TEST-*.xml"/>
            </fileset>
	    <report format="frames" todir="${dir.build.junit.html}"/>
        </junitreport>
        <fail if="build.test.failed" message="Unit Tests Failed"/>
    </target>
    
    <!-- Run all the tests -->
    <target name="all-tests" depends="test,test_jsr105"
	    description="Runs all the test targets">
    </target>
	
    <!-- XML Encryption Samples -->
    <target name="encrypt"
	    depends="build.samples"
	    description="encrypts xml data">
	<delete file="build/encryptedInfo.xml"/>
	<delete file="build/kek"/>
	<java classname="org.apache.xml.security.samples.encryption.Encrypter" 
		  failonerror="true" 
		  fork="yes" 
		  taskname="Encrypter">
		<classpath refid="id.classpath.samples"/>
	</java>
    </target>

    <target name="decrypt"
	    depends="build.samples" 
	    description="decrypts xml data">
	<delete file="build/decryptedInfo.xml"/>
	<java classname="org.apache.xml.security.samples.encryption.Decrypter" 
		  failonerror="true" 
		  fork="yes" 
		  taskname="Decrypter">
		<classpath refid="id.classpath.samples"/>
	</java>
    </target>
    
    <target name="encryptAndDecrypt"
	    depends="encrypt, decrypt" 
	    description="encrypts and decrypts an element's contents" />

    <!-- Signature Samples -->

    <target name="sign"
	    depends="build.samples" 
	    description="creates a signature" >
	<delete file="build/signature.xml"/>
	<java classname="org.apache.xml.security.samples.signature.CreateSignature" 
		  failonerror="true" 
		  fork="yes" 
		  taskname="CreateSignature">
		<classpath refid="id.classpath.samples"/>
	</java>
    </target>

    <target name="verify" 
	    depends="build.samples" 
	    description="verifies a signature">
	<java classname="org.apache.xml.security.samples.signature.VerifySignature" 
		  failonerror="true" 
		  fork="yes" 
		  taskname="VerifySignature">
		<classpath refid="id.classpath.samples"/>
	</java>
    </target>
	
    <target name="signAndVerify"
	    depends="sign, verify" 
	    description="creates and verifies a signature" />

    <!-- Axis Signature Samples -->

    <target name="axis-sign"
	    depends="build.samples" 
	    description="axis sign sample">
	<echo message="Running org.apache.xml.security.samples.AxisSigner"/>
	<java classname="org.apache.xml.security.samples.AxisSigner" 
		  failonerror="true" fork="yes" taskname="SignAxis">
		<classpath refid="id.classpath.samples"/>
	</java>
    </target>

    <target name="axis-verify"
	    depends="build.samples" 
	    description="axis verify sample">
	<echo message="Running org.apache.xml.security.samples.AxisVerifier"/>
	<java classname="org.apache.xml.security.samples.AxisVerifier" 
		  failonerror="true" 
		  fork="yes" 
		  taskname="VerifyAxis">
		<classpath refid="id.classpath.samples"/>
	</java>
    </target>

    <target depends="axis-sign, axis-verify" name="AxisSignAndVerify"/>

    <!-- Mega Samples -->
    <target name="mega-sample" 
	    depends="build.samples">
	<echo message="Now I&apos;ll try to verify merlins example fifteen-HMAC"/>
	<java classname="org.apache.xml.security.samples.signature.VerifyMerlinsExamplesFifteen" 
		  fork="yes">
		<classpath refid="id.classpath.samples"/>
	</java>

	<echo message=""/>
	<echo message="Now I&apos;ll try to verify merlins example sixteen"/>
	<java classname="org.apache.xml.security.samples.signature.VerifyMerlinsExamplesSixteen" 
		  fork="yes">
		<classpath refid="id.classpath.samples"/>
	</java>

	<echo message=""/>
	<echo message="Now I&apos;ll try to verify merlins example twenty three"/>
	<java classname="org.apache.xml.security.samples.signature.VerifyMerlinsExamplesTwentyThree" 
		  fork="yes">
		<classpath refid="id.classpath.samples"/>
	</java>

	<echo message=""/>
	<echo message="Now I&apos;ll create a signature in signature.xml and verify it"/>
	<java classname="org.apache.xml.security.samples.signature.CreateSignature" 
		  fork="yes">
		<classpath refid="id.classpath.samples"/>
	</java>
	<java classname="org.apache.xml.security.samples.signature.VerifySignature" 
		  fork="yes">
		<classpath refid="id.classpath.samples"/>
	</java>
		
	<echo message=""/>
	<echo message="Now I&apos;ll create a signature like merlin-16 but without XSLT"/>
	<java classname="org.apache.xml.security.samples.signature.CreateMerlinsExampleSixteen" 
		  fork="yes">
		<classpath refid="id.classpath.samples"/>
	</java>

	<echo message=""/>
	<echo message="Please look into log.txt, merlinsSixteenRecreated.xml and signature.xml"/>


	<echo message=""/>
	<echo message="Now I&apos;ll create a signature like merlin-23 but without XSLT"/>
	<java classname="org.apache.xml.security.samples.signature.CreateMerlinsExampleTwentyThree" 
		  fork="yes">
		<classpath refid="id.classpath.samples"/>
	</java>

	<echo message=""/>
	<echo message="Please look into log.txt, merlinsTwentyThreeRecreated.xml and signature.xml"/>
    </target>

    <target name="createEnvelope" 
	    depends="build.samples">
	<java classname="org.apache.xml.security.samples.signature.CreateEnvelopingSignature" 
		  fork="yes">
		<classpath refid="id.classpath.samples"/>
	</java>
    </target>

    <!-- JSR 105 Samples -->
    <target name="jsr105-samples" 
	    depends="build.samples">
        <echo message="Generating a detached signature"/>
        <java classname="javax.xml.crypto.dsig.samples.GenDetached"
	    fork="yes">
	    <classpath refid="id.classpath.samples"/>
	    <sysproperty key="proxyHost" value="${proxy.host}"/>
	    <sysproperty key="proxyPort" value="${proxy.port}"/>
	</java>
	<echo message="Generating an enveloped signature"/>
	<java classname="javax.xml.crypto.dsig.samples.GenEnveloped"
	    fork="yes">
	    <arg value="${dir.src.samples}/javax/xml/crypto/dsig/samples/envelope.xml"/>
	    <classpath refid="id.classpath.samples"/>
	</java>
	<echo message="Generating an enveloping signature"/>
	<java classname="javax.xml.crypto.dsig.samples.GenEnveloping"
	    fork="yes">
	    <classpath refid="id.classpath.samples"/>
	</java>
	<echo message="Validating a signature"/>
	<java classname="javax.xml.crypto.dsig.samples.Validate"
	    fork="yes">
	    <arg value="${dir.src.samples}/javax/xml/crypto/dsig/samples/envelopedSignature.xml"/>
	    <classpath refid="id.classpath.samples"/>
	</java>
    </target>
	
    <!-- D I S T R I B U T I O N  T A R G E T S -->
    <!-- distribution targets -->

    <target name="build.dist"       
	    depends="build.srcdist,build.bindist" />

    <target name="build.srcdist" 
	description="Creates the source distribution" >
		
	<mkdir dir="${dir.build.srcdist}"/>

	<copy todir="${dir.build.srcdist}">
	    <fileset dir=".">
		<patternset refid="id.patternset.distFiles"/>
		<patternset refid="id.patternset.srcFiles"/>
		<patternset refid="id.patternset.sampleFiles"/>
				
		<include name="ant/**/*"/>
	    </fileset>
	</copy>

	<mkdir description="create an empty libs dir"
	       dir="${dir.build.srcdist}/libs"/>
		
	<zip basedir="${dir.build.dist}/src" 
	     zipfile="${dir.build}/${product.name}-src-${product_version}.zip"/>
    </target>

    <target name="build.bindist"
	    depends="build.src,build.docs" 
	    description="Creates the binary distribution">

	<mkdir dir="${dir.build.bindist}"/>

	<copy todir="${dir.build.bindist}">
	    <fileset dir=".">
		<patternset refid="id.patternset.distFiles"/>
		<patternset refid="id.patternset.srcFiles"/>
		<patternset refid="id.patternset.sampleFiles"/>
				
		<include name="ant/**/*"/>
	    </fileset>
	</copy>

	<mkdir dir="${dir.build.bindist}/libs"/>

	<copy file="${lib.xerces.1}" 
	      todir="${dir.build.bindist}/libs"/>
	<copy file="${lib.xalan.1}" 
	      todir="${dir.build.bindist}/libs"/>
	<copy file="${lib.xalan.2}" 
	      todir="${dir.build.bindist}/libs"/>
	<copy file="${lib.xalan.3}" 
	      todir="${dir.build.bindist}/libs"/>
	<copy file="${lib.logging}" 
	      todir="${dir.build.bindist}/libs"/>
	
	<copy description="copy xmlsec JAR" 
	      file="${jar.library}" 
	      todir="${dir.build.bindist}/libs"/>
	<copy description="copy xmlsec sample JAR" 
	      file="${jar.samples}" 
	      todir="${dir.build.bindist}/libs"/>
	<copy description="copy xmlsec test JAR" 
	      file="${jar.tests}" 
	      todir="${dir.build.bindist}/libs"/>

	<mkdir dir="${dir.build.bindist}/doc"/>
	<mkdir dir="${dir.build.bindist}/doc/Java/api" />
	<copy todir="${dir.build.bindist}/doc/Java/api">
	    <fileset dir="${dir.build.docs.html}/javadoc"/>
	</copy>

	<zip basedir="${dir.build.dist}/bin" 
	     zipfile="${dir.build}/${product.name}-bin-${product_version}.zip"/>
    </target>

	
    <!-- M I S C E L A N E O U S  T A R G E T S -->

    <!-- documentation -->
    <target name="build.docs">
	<mkdir dir="${dir.build.javadoc}"/>
	<javadoc classpathref="id.classpath"
		 destdir="${dir.build.javadoc}">
	    <packageset dir="${dir.src}">
      		<include name="org/apache/xml/security/**"/>
      		<include name="javax/xml/crypto/**"/>
            </packageset>
            <group title="JSR 105 Packages" packages="javax.xml.crypto*"/>
            <group title="XMLSec Packages" packages="org.apache.xml.security*"/>
    	</javadoc>
    </target>

    <target name="clover.report.html" depends="with.clover">
	<clover-report>
      		<current outfile="${dir.build.coverage}"
      				 title="Apache XML-Security coverage">
      			<fileset dir="${dir.src}">
		  		<include name="**/*.java"/>
		  		<exclude name="**/*Exception.java" />
			</fileset>
         		<format type="html"/> 
      		</current>	 
   	</clover-report>
    </target>

    <!-- jars -->
    <target name="manifest">
	<tstamp/>
	<mkdir dir="${dir.manifest}"/>
	<copy file="${basedir}/LICENSE" tofile="${dir.manifest}/LICENSE.txt"/>
	<copy file="${basedir}/NOTICE" tofile="${dir.manifest}/NOTICE.txt"/>
	<manifest file="${jar.manifest}" mode="replace">
            <attribute name="Built-By" value="${user.name}"/>
            <section name="${product.shortname}">
		<attribute name="Implementation-Title"
                           value="${product.Name}"/>
		<attribute name="Implementation-Version"
                           value="${product.version} ${TODAY}"/>
		<attribute name="Implementation-Vendor"
                           value="Apache Software Foundation"/>
            </section>
        </manifest>
    </target>

    <target name="build.jar"
	    depends="manifest,build.src,build.test,build.samples">

	<!-- Main Library -->
	<jar basedir="${dir.build.bin}"
	     excludes="org/apache/xml/security/temp/**"
	     includes="org/apache/**, javax/xml/crypto/**"
	     destfile="${jar.library}" 
	     manifest="${jar.manifest}">
	  <metainf file="${dir.manifest}/*.txt"/>
	</jar>

	<!-- Samples -->
	<jar basedir="${dir.build.samples}" 
	     excludes="org/apache/xml/security/temp/**" 
	     includes="org/apache/**, javax/xml/crypto/**"
	     destfile="${jar.samples}" 
	     manifest="${jar.manifest}">
	  <metainf file="${dir.manifest}/*.txt"/>
	</jar>
		
	<!-- Tests -->
	<jar basedir="${dir.build.test}" 
	     excludes="org/apache/xml/security/temp/**" 
	     includes="org/apache/**, javax/xml/crypto/**"
	     destfile="${jar.tests}" 
	     manifest="${jar.manifest}">
	  <metainf file="${dir.manifest}/*.txt"/>
	</jar>
    </target>

    <target name="build.src.jar"
	    depends="manifest,build.src">

	<jar basedir="${dir.build.bin}" 
	     excludes="org/apache/xml/security/temp/**"
	     includes="**/LICENSE, **/NOTICE, org/apache/**, javax/xml/crypto/**, *.txt" 
	     jarfile="${jar.library}" 
	     manifest="${jar.manifest}"/>
    </target>

    <!-- archive targets -->
    <target name="build.arch"
            depends="env.mk.dirs" >
    </target >

    <!-- aliases -->
    <target name="build.all"        depends="env.mk.dirs,build.src,build.docs,build.test,build.samples,build.jar,build.arch" />

    <target name="compile"          depends="build.src" />
    <target name="docs"             depends="build.docs" />
    <target name="javadoc"          depends="build.docs" />
    <target name="jar"              depends="build.jar" />
    <target name="dist"             depends="build.dist" />
    <target name="clean"            depends="env.rm.dirs,env.rm.files"/>
    <target name="gump"		    depends="clean, docs, jar, test"/>
    <target name="clover"	    depends="clean, with.clover, test, clover.report.html" />

    <!-- maintenance targets -->

    <!-- help targets -->
    <target depends="init" name="help" >
        <echo message="synopsis: ant [target]" />
        <echo message="targets:" />
        <echo message="compile  - builds xml-security source" />
        <echo message="docs     - creates java documentation" />
        <echo message="jar      - creates a jar file, containing the built source" />
        <echo message="dist     - creates a distribution" />
        <echo message="           (see ant help.dist for more information)" />
        <echo message="clean    - resets the build environment" />
        <echo message="test     - performs a series of tests" />
        <echo message="           (see ant help.test for more information)" />
        <echo message="help     - displays this help message (default)" />
        <echo message=""/>
        <echo message="See also help.samples for help on building samples"/>
    </target >
    <target depends="init" name="help.dist" >
        <echo message="dist:" />
        <echo message="this target will:" />
        <echo message="1.  build the source files," />
        <echo message="2.  create the appropriate java documentation," />
        <echo message="3.  create distribution jars," />
        <echo message="4.  copy the license, copies source and" />
        <echo message="5.  creates distribution archives" />
    </target >

    <target depends="init" name="help.test" >
        <echo message="test			- runs all unit and interop tests" />
        <echo message="test_exc_c14n - runs the exclusive c14n tests" />
        <echo message="test_xenc	- does all encryption related tests" />
        <echo message="clover		- generates clover coverage reports" />
    </target >

    <target depends="init" name="help.samples" >
	<echo message=""/>
	<echo message="------------- Signature Samples ----------------"/>
	<echo message=""/>
	<echo message="sign               - runs CreateSignature sample"/>
	<echo message="verify             - runs signature verification sample"/>
	<echo message="signAndVerify      - runs sign and then verify"/>
	<echo message="axis-sign          - runs axis signing sample"/>
	<echo message="axis-verify        - runs axis verification sample"/>
	<echo message="AxisSignAndVerify  - runs axis sign and verify"/>
	<echo message="createEnvelope     - runs enveloping signature sample"/>
	<echo message="mega-sample        - runs all big signature samples"/>
	<echo message=""/>
	<echo message="------------- Encryption Samples ----------------"/>
	<echo message=""/>
	<echo message="encrypt            - run encryption sample" />
	<echo message="decrypt            - run decryption sample" />
	<echo message="encryptAndDecrypt  - run encryption sample" />
    </target>
		
</project>
