<?xml version="1.0"?>

<!-- Manifest tests build file
     author: Conor MacNeill -->
<project name="manifest-test" basedir="." default="test1">

  <target name="test1">
    <jar file="mftest1.jar" manifest="manifests/test1.mf"/>
    <unjar src="mftest1.jar" dest="manifests">
      <patternset>
        <include name="META-INF/MANIFEST.MF"/>
      </patternset>
    </unjar>
  </target>
  
  <target name="test2">
    <jar file="mftest2.jar" manifest="manifests/test2.mf"/>
    <unjar src="mftest2.jar" dest="manifests">
      <patternset>
        <include name="META-INF/MANIFEST.MF"/>
      </patternset>
    </unjar>
  </target>
  
  <target name="test3">
    <jar file="mftest3.jar" manifest="manifests/test3.mf"/>
  </target>
  
  <target name="test4">
    <jar file="mftest4.jar" manifest="manifests/test4.mf"/>
  </target>
  
  <target name="test5">
    <jar file="mftest5.jar" manifest="manifests/test5.mf"/>
  </target>
  
  <target name="test6">
    <jar file="mftest6.jar" manifest="manifests/test6.mf"/>
  </target>
  
  <target name="test7">
    <jar file="mftest7.jar" manifest="manifests/test7.mf"/>
  </target>
  
  <target name="test8">
    <jar file="mftest8.jar">
      <manifest>
        <attribute name="Class-Path" value="fubar"/>
        <section name="Test">
          <attribute name="TestAttr" value="Test"/>
        </section>
      </manifest>
    </jar>
    <unjar src="mftest8.jar" dest="manifests">
      <patternset>
        <include name="META-INF/MANIFEST.MF"/>
      </patternset>
    </unjar>
  </target>

  <target name="test9">
    <jar file="mftest9.jar">
      <manifest>
        <attribute name="Class-Path" value="fubar"/>
        <section name="Test">
          <attribute name="Name" value="Test"/>
        </section>
      </manifest>
    </jar>
  </target>

  <target name="test10">
    <jar file="mftest10.jar">
      <manifest>
        <attribute value="fubar"/>
      </manifest>
    </jar>
  </target>

  <target name="test11">
    <jar file="mftest11.jar">
      <manifest>
        <attribute name="Test"/>
      </manifest>
    </jar>
  </target>

  <target name="test12">
    <jar file="mftest12.jar">
      <manifest>
        <section>
          <attribute name="TestAttr" value="Test"/>
        </section>
      </manifest>
    </jar>
  </target>

  <target name="test13">
    <jar file="mftest13.jar">
      <manifest>
        <attribute name="Test" value="Test1"/>
        <attribute name="Test" value="Test2"/>
      </manifest>
    </jar>
  </target>

  <target name="test14">
    <jar file="mftest14.jar">
      <manifest>
        <attribute name="Class-path" value="Test1"/>
        <attribute name="Class-path" value="Test2"/>
        <attribute name="Class-Path" value="Test3"/>
        <attribute name="class-Path" value="Test4"/>
      </manifest>
    </jar>
    <unjar src="mftest14.jar" dest="manifests">
      <patternset>
        <include name="META-INF/MANIFEST.MF"/>
      </patternset>
    </unjar>
  </target>

  <target name="testNoFile">
    <manifest />
  </target>

  <target name="testLongLine">
    <jar file="mftestLongLine.jar">
      <manifest>
        <attribute name="Class-path" 
                   value="${test.longline}"/>
      </manifest>
    </jar>
    <unjar src="mftestLongLine.jar" dest="manifests">
      <patternset>
        <include name="META-INF/MANIFEST.MF"/>
      </patternset>
    </unjar>
  </target>

  <target name="testOrder1">
    <jar file="mftestOrder1.jar">
      <manifest>
        <section name="Test1">
          <attribute name="TestAttr1" value="Test1"/>
          <attribute name="TestAttr2" value="Test2"/>
        </section>
        <section name="Test2">
          <attribute name="TestAttrx" value="Testx"/>
        </section>
      </manifest>
    </jar>
    <unjar src="mftestOrder1.jar" dest="manifests">
      <patternset>
        <include name="META-INF/MANIFEST.MF"/>
      </patternset>
    </unjar>
  </target>

  <target name="testOrder2">
    <jar file="mftestOrder2.jar">
      <manifest>
        <section name="Test2">
          <attribute name="TestAttrx" value="Testx"/>
        </section>
        <section name="Test1">
          <attribute name="TestAttr2" value="Test2"/>
          <attribute name="TestAttr1" value="Test1"/>
        </section>
      </manifest>
    </jar>
    <unjar src="mftestOrder2.jar" dest="manifests">
      <patternset>
        <include name="META-INF/MANIFEST.MF"/>
      </patternset>
    </unjar>
  </target>

  
  
  <target name="testReplace">
    <copy file="manifests/test2.mf" toFile="mftest.mf" />
    <manifest file="mftest.mf" />
  </target>

  <target name="testUpdate">
    <copy file="manifests/test2.mf" toFile="mftest.mf" />
    <manifest file="mftest.mf" mode="update">
      <attribute name="Foo" value="Bar" />
    </manifest>

    <copy file="manifests/test2.mf" toFile="mftest2.mf" />
    <manifest file="mftest2.mf" mode="update">
      <section name="Test">
        <attribute name="Foo" value="Bar" />
      </section>
    </manifest>
    <manifest file="mftest2.mf" mode="update">
      <section name="Test">
        <attribute name="Foo" value="Baz" />
      </section>
    </manifest>
  </target>

  <target name="clean">
    <delete>
      <fileset dir="." includes="mftest*"/>
    </delete>
    <delete dir="manifests/META-INF"/>
  </target>
</project>
