don't dream your life, live your dreams !
Contents
By default the manifest can be found here in your artifact : “META-INF/MANIFEST.MF”.
The manifest file can be set :
Some plugins helps you to custom your manifest.
For jar artifacts :
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>${maven-jar-plugin.version}</version> <configuration> <archive> <index>true</index> <manifest> <addClasspath>true</addClasspath> </manifest> <manifestEntries> <mode>development</mode> <url>${project.url}</url> <key>value</key> </manifestEntries> </archive> </configuration> </plugin> </plugins> </build> |
For war artifacts :
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>${maven-war-plugin.version}</version> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> </manifest> <manifestEntries> <mode>development</mode> <url>${project.url}</url> <key>value</key> </manifestEntries> </archive> </configuration> </plugin> </plugins> </build> |
// get manifest as input stream : InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(resourceName); // read manifest: Manifest manifest = new Manifest(); manifest.read(inputStream); |
To get the main Attributes for the Manifest :
Attributes mainAttributes = manifest.getMainAttributes(); for(Object attribute : mainAttributes.keySet()) { Attributes.Name attributeName = (Attributes.Name) attribute; String attributeValue = mainAttributes.getValue(attributeName); } |
To get entires for the Manifest :
Map<String, Attributes> entries = manifest.getEntries(); for(Object attribute : entries.keySet()) { Attributes.Name attributeName = (Attributes.Name) attribute; String attributeValue = entries.getValue(attributeName); } |
Copyright © 2024 My linux world - by Marc RABAHI
Design by Marc RABAHI and encelades.
admin