alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Ant example source code file (manifest.xml)

This example Ant source code file (manifest.xml) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Ant tags/keywords

bar, class-path, class-path, foo, test, test, test1, test1, test2, test2, testattr, testattr1, testattr2, testattrx

The manifest.xml source code

<?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}"/>
        <attribute name="${test.long68name}" value="${test.value}" />
        <attribute name="${test.long70name}" value="${test.value}" />
        <attribute name="${test.notlongname}" value="${test.value}" />
      </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="testFrom">
    <manifest file="mftestfrom.mf" >
      <section name="Test">
        <attribute name="before" value="before" />
        <attribute name="From" value="illegal"/>
        <attribute name="after" value="after" />
      </section>
    </manifest>
  </target>

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

Other Ant examples (source code examples)

Here is a short list of links related to this Ant manifest.xml source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.