Is there a Java API to read, interpret and write Java manifest files (MANIFEST.MF)?

I am working with the ATG Dynamo framework, a Java based framework that uses manifest files to define many of the configuration details for its modules.

I would like to create some tools and scripts - say ANT scripts or Maven plugins - to programmatically manage these files. Specifically, I want to be able to read existing files and do some content based tasks on the one hand, and generate new manifest files as part of my build process on the other.

The MANIFEST.MF format seems to be very simple, although there are some rules about line length and space, so I'm sure I can describe it a lot. However, it would be very helpful if there was already an API to read and write such files according to the specification.

Any suggestions?

+3


source to share


3 answers


Use JarFile#getManifest()

. It gives you an instance Manifest

by providing several convenience methods for accessing attributes.



JarFile jarFile = new JarFile(file);
Manifest manifest = jarFile.getManifest();
// ...

      

+3


source


In addition to the previous answer, you can get some information from the manifest via the package instance:



getClass().getPackage().getImplementationTitle(); // for example 

      

+1


source


Not really a read / write API, but a utility class for reading all files MANIFEST.MF

available in the classpath: jcabi-manifestests

Also see this post for more details: http://www.yegor256.com/2014/07/03/how-to-read-manifest-mf.html

0


source







All Articles