How to write in the manifest file?


My manifest file is not updated, I used the plugin maven-war-plugin to write, but nothing happened, if I change the name of the directory of the manifest file I get an error manifest file not found while packaging , but when I put it in the right place nothing happens, the content of the file is unchanged.

<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.4</version> <configuration> <archive> <addMavenDescriptor/> <compress/> <forced/> <index/> <manifest> <addClasspath/> <addDefaultImplementationEntries/> <addDefaultSpecificationEntries/> <addExtensions/> <classpathLayoutType/> <classpathMavenRepositoryLayout/> <classpathPrefix/> <customClasspathLayout/> <mainClass/> <packageName/> </manifest> <manifestEntries> <key>value</key> </manifestEntries> <manifestFile>src/main/webapp/META-INF/test/MANIFEST.MF</manifestFile> <pomPropertiesFile/> </archive> </configuration> </plugin>

and the content of my manifest file is:

Manifest-Version: 1.0

Any idea, why it doesn't work or how it can be done correctly?


Do not use an empty tag. You should set the boolean parameter to true:

<manifest> <addClasspath>true</addClasspath> </manifest>

See the <a href="http://maven.apache.org/plugins/maven-war-plugin/examples/war-manifest-guide.html" rel="nofollow">official doc</a>


the whole solution :

add to your pom.xml file the maven war plugin or another plugin that supports the archive tag inside its configuration :

<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.4</version> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> </manifest> <manifestEntries> <Build-Time>${maven.build.timestamp}</Build-Time> <Build-Host>${agent.name}</Build-Host> <Build-User>${user.name}</Build-User> <Build-Maven>Maven ${maven.version}</Build-Maven> <Build-Java>${java.version}</Build-Java> <Build-OS>${os.name}</Build-OS> <Build-Label>${project.version}</Build-Label> <Build-Path>${basedir}</Build-Path> </manifestEntries> <manifestFile>src/main/webapp/META-INF/MANIFEST.MF</manifestFile> </archive> </configuration> </plugin>

we can specify the format of the build time also by adding the tag properties for the pom configuration :

<properties> <maven.build.timestamp.format>dd/MM/yyyy</maven.build.timestamp.format> </properties>

those properties are written automatically in the Manifest file inside the war after each build :

Manifest-Version: 1.0 Build-Time: 15/09/2014 Build-Java: 1.7.0_60 Class-Path: commons-codec-1.9.jar javax.mail-1.5.0.jar activation-1.1.jar joda-time-2.3.jar spring-ldap -core-2.0.1.RELEASE.jar spring-data-commons-1.6.1.RELEASE.jar jcl-ove r-slf4j-1.7.1.jar Built-By: aXSEDZ Created-By: Apache Maven Build-Host: Build-Path: C:\WSLocal\5portal\5portalweb Build-OS: Windows 7 Build-Jdk: 1.7.0_60 Build-Maven: Maven null Build-Label: 0.0.5-SNAPSHOT Build-User: aXSEDZ Archiver-Version: Plexus Archiver

After that read the file as a resource file, in my case i access it throw a spring context :

Properties props = new Properties(); try { WebApplicationContext webAppContext = ContextLoaderListener.getCurrentWebApplicationContext(); if (webAppContext != null) { InputStream inputStream = webAppContext.getServletContext().getResourceAsStream("/META-INF/MANIFEST.MF"); props.load(inputStream); } } catch (IOException e) { }


  • Exception in thread “main” java.lang.NullPointerException : While trying to the run the jar file
  • Python BZ2 IOError: invalid data stream
  • Display Manifest properties in JSF2
  • Android permissions - Manifest or android.manifest
  • find the region part of live using c#
  • Android Studio cannot find resources when building for device with version > 5.0
  • Receive custom intent without activity restart
  • JConsole Main class
  • EditText is covered by Keyboard
  • ConnectivityManager.CONNECTIVITY_ACTION deprecated
  • Xamarin Android | Layout style
  • How to get current document uri in XSLT?
  • Multicolored edittext hint
  • Redux Form - Not able to type anything in input
  • How can the INSERT … ON CONFLICT (id) DO UPDATE… syntax be used with a sequence ID?
  • Problems compiling files using JOGL
  • Installed module is empty
  • How can I sort a a table with VBA with given text condition?
  • chrome.tabs.executeScript only fires when the Developer Console is open
  • HTTP/2 streams vs HTTP/1.1 connections
  • Bad request using file_get_contents for PUT request in PHP
  • Python urlparse: small issue
  • All Classes Conforming to Protocol Inherit Default Implementation
  • Display issues when we change from one jquery mobile page to another in firefox
  • Deselecting radio buttons while keeping the View Model in synch
  • Read text file and split every line in MSBuild
  • C# - Serializing and deserializing static member
  • Java applet as stand-alone Windows application?
  • SSO with signing and signature validation doesn't work
  • Deserializing XML into class C#
  • JSON with duplicate key names losing information when parsed
  • Jquery - Jquery Wysiwyg return html as a string
  • R: gsub and capture
  • jqPlot EnhancedLegendRenderer plugin does not toggle series for Pie charts
  • Comma separated Values
  • How to include full .NET prerequisite for Wix Burn installer
  • Error creating VM instance in Google Compute Engine
  • costura.fody for a dll that references another dll
  • jQuery Masonry / Isotope and fluid images: Momentary overlap on window resize
  • How to load view controller without button in storyboard?