Click here to Skip to main content
13,053,345 members (60,435 online)
Click here to Skip to main content
Add your own
alternative version


3 bookmarked
Posted 2 Mar 2006

Manifest Reader for Ant Tool

, 2 Mar 2006
Rate this:
Please Sign up or sign in to vote.
An Ant task for reading manifest information from a jar file and displaying it


This article presents a simple but quite useful Ant task for reading MANIFEST.MF file contained in a jar and selectively printing its content.


MANIFEST.MF file is a simple text file containing one or more sections and information related to each section in name value pair format. The major purpose of having this file is that it allows you to define extension and package related data.

Task Usage

To be able to use this task, you need to inform Ant about its existence. This can be very easily done by putting the following script in your Ant build file.

<typedef resource="com/freeware/anttasks/antlib.xml">
     <classpath path="${basedir}/antcontrib/mfprinter-1.0.2.jar" />

Once this is done, you are ready to use this task in your build script. The following Ant script snippet shows a typical usage of this task.

<target name="printinfo" description="Print application details!">
    <manifestreader srcfile="${basedir}/antcontrib/mfprinter-1.0.2.jar">
        <attribute name="Build-Date"                 value="Built On        :"/>
        <section name="com/freeware/anttasks">
            <attribute name="Implementation-Title"   value="Product Name    :"/>
            <attribute name="Implementation-Version" value="Product Version :"/>
            <attribute name="Implementation-Vendor"  value="Copyright       :"/>

The above code snippet will produce the following output:

Buildfile: testtask.xml

[manifestreader] Built On        : March 3 2006 at 11:41 AM
[manifestreader] Product Name    : Manifest Printer
[manifestreader] Product Version : 1.0.2
[manifestreader] Copyright       : Khan Information Systems

Total time: 0 seconds

Task Parameters

srcfileThe full path and name of the jar file whose manifest is to be readYes

Nested Elements

  • attribute

    One attribute for the manifest file. Those attributes that are not nested into a section will be added to the "Main" section.

    nameThe name of the attribute as defined in manifest file.Yes
    valueThe label text to be used while printing the manifest attribute value.Yes

  • section

    A manifest section - you can nest attribute elements into sections.

    nameThe name of the section as defined in manifest file.No, if omitted it will be assumed to be the main section.


Ant tool does provide a task for manifest file creation. This task now completes the manifest task by providing the read capability. The main motivation behind development of this task was to be able to display certain useful fields from manifest file in situations where the standalone Java service is started by using Ant tool. This can quickly help in determining whether the user of your application is using the correct jar file or not.


  • March 03, 2006 - First release


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Prasad Khandekar
Software Developer (Senior) Freelancer
India India
I am a software professional with over 20 years of commercial business applications design and development experience.

My programming experience includes Java, Spring, .NET, Classic VB & ASP, Scripting, Power Builder, PHP, Magic & far far ago FoxPro, C, Assembly and COBOL.

From last 11 years I am mostly working with Java Technology. I am currently available to take up new assignments.

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170713.1 | Last Updated 3 Mar 2006
Article Copyright 2006 by Prasad Khandekar
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid