i've created a .jar with Intellij, but the final product manifest is:
Manifest-Version: 1.0
Created-By: 1.7.0_51 (Oracle Corporation)
In my Ide the manifest code is:
Manifest-Version: 1.0
Main-Class: Grafica.ProvaSchermata
Why during the artifacts building the manifest change?
Sorry for my bad English.
i've changed the file pom.xml , with tag. :
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>Grafica.ProvaSchermata</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
Related
Given this plugin config in a Maven pom.xml:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>acme.Main</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
Why would MANIFEST.MF be missing Implementation-Version and Implementation-Title, given that all docs that I can get my hands on, either don't mention it, or imply its creation is a default?
The complete generated Manifest is:
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven 3.8.6
Built-By: stewart
Build-Jdk: 17.0.5
Main-Class: org.springframework.boot.loader.JarLauncher
Start-Class: acme.Main
Spring-Boot-Version: 2.7.5
Spring-Boot-Classes: BOOT-INF/classes/
Spring-Boot-Lib: BOOT-INF/lib/
Spring-Boot-Classpath-Index: BOOT-INF/classpath.idx
Spring-Boot-Layers-Index: BOOT-INF/layers.idx
Apparently, behind the scenes, spring-boot-maven-plugin still relies on the Manifest created by maven-jar-plugin, because that's the base .jar that is being repackaged.
Having established that, we then find that
Starting with version 2.1, Maven Archiver no longer creates the
Implementation and Specification details in the manifest by default.
If you want them in your manifest you have to say so explicitly in
your configuration.
Thus, what is needed is to add the following to the pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
</archive>
</configuration>
</plugin>
I have an issue that after read two pages in google about it I can still not found the solution.
I want just create a manifest file into my war file and introduce the version of my application. I´m using mave-war-plugin of apache.
Using version 2.0.2 I achieve to create the manifest file, but just with the default information:
Manifest-Version: 1.0
Built-By: ***********
Build-Jdk: 1.7.0_25
Created-By: Apache Maven 3.1.1
Archiver-Version: Plexus Archiver
The code of 2.0.2 is this one:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
<manifestEntries>
<Implementation-Version>2.1.0</Implementation-Version>
</manifestEntries>
</archive>
</configuration>
</plugin>
But like I said, I cannot introduce the new attribute "Implementation-Version"
And if I try to use the last version of the plugin I cannot create the manifest file at all.
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Implementation-Version>2.1.0</Implementation-Version>
</manifestEntries>
</archive>
</configuration>
</plugin>
I´m using Maven 3 and I dont have create any MANIFEST.FM file in META-INF.
I try to create my own MANIFEST.FM in my META-INF. with this template, to see if would be possible to just set the values but nothing as well. Like I said I try everything!
Specification-Title: ****
Specification-Vendor: Company Name
Implementation-Title: Portal web
Implementation-Version: ${Implementation-Version}
Implementation-Vendor:*****
Build-Jdk: ${jdk.version}
After continue investigating, I see that my war file has 2 overlays. So after read about it I add into the main overlay, the plugin with the modification of the Manifest.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<archive>
<manifestEntries>
<Version>${project.version}</Version>
</manifestEntries>
</archive>
</configuration>
</plugin>
And in the child wars the plugin like.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.0.2</version>
</plugin>
But then the manifest is created with the default values, and the maven folder with the pom.properties, but in the child wars nothing is created in the META-INF
Regards.
I have the following in my project's pom.xml which I think should display the version of Maven being used in the resulting WAR file:
<build>
...
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<archive>
<manifest>
<addClasspath>false</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>
</archive>
</configuration>
</plugin>
...
</plugins>
...
</build>
The MANIFEST.MF that is created looks correct see below apart from the Build-Maven line in which the ${maven.version} is not substituted with the actual version number 3.0.4 in this case.
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: stocjon
Build-Jdk: 1.6.0_35
Build-Host:
Build-Java: 1.6.0_35
Build-Label: 1.0.0-SNAPSHOT
Build-Maven: Maven ${maven.version}
Build-OS: Windows XP
Build-Path: C:\Development\project_name
Build-Time: 15:38:50 21-Sep-2012
Build-User: user_name
Any ideas why Maven version is not being populated in the MANIFEST.MF ?
Help would be much appreciated.
Thanks
Jon
You need to add this plugin:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>maven-version</goal>
</goals>
</execution>
</executions>
</plugin>
Check here for details.
We no more need the build-helper-maven-plugin since the feature (MSHARED-38) was added to the component maven-archiver : 2.5 in Feb. 2012 (release notes).
And this component is used by the Maven plugins like maven-jar-plugin, maven-war-plugin, maven-ear-plugin, etc.
The versions of these plugins using this feature are :
maven-jar-plugin : 2.4 (MJAR-148), released in Feb. 2012
maven-war-plugin : 2.2 (MWAR-273), released in Feb. 2012
maven-ear-plugin : 2.8 (MEAR-145), released in Sept. 2012
maven-assembly-plugin : 2.4 (MASSEMBLY-634), released in Nov. 2012
maven-ejb-plugin : 2.4 (MEJB-56), EDIT : released on 24/Aug/14
etc.
So now we'll have this entry by default in the archive's manifest.mf :
Created-By: Apache Maven ${maven.version}
At least as of version 2.4 of the maven-jar plugin, the following entries are added by default to the MANIFEST.MF file in META-INF in the jar:
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Built-By: abcUser
Created-By: Apache Maven 3.3.3
Build-Jdk: 1.8.0_77
To add the project version and other implementation details, simply add the following to the maven-jar-plugin (either in the pluginManagement section or in the build -> plugins section:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
</archive>
</configuration>
</plugin>
To add something like a build time, add the following:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
<manifestEntries>
<Build-Time>${maven.build.timestamp}</Build-Time>
</manifestEntries>
</archive>
</configuration>
</plugin>
The Build-Time format can be changed by using the following property in the <properties> section of your pom.xml:
<maven.build.timestamp.format>yyyy-MM-dd HH:mm z</maven.build.timestamp.format>
The output of all the above is something like:
Manifest-Version: 1.0
Implementation-Title: UI
Implementation-Version: 2.0.5-SNAPSHOT
Archiver-Version: Plexus Archiver
Built-By: abcUser
Implementation-Vendor-Id: com.xyz.abc.dbe
Build-Time: 2016-12-23 12:04 UTC
Created-By: Apache Maven 3.3.3
Build-Jdk: 1.8.0_77
Implementation-Vendor: XYZ Corporation
For completeness - this worked for me:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.1</version>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
</archive>
</configuration>
</plugin>
This puts in my manifest -
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: Old.Curmudgeon
Build-Jdk: 1.5.0_22
Implementation-Title: JarFileName-1.0.2
Implementation-Version: 1.0.2
Implementation-Vendor-Id: our.id
Take a look how it's suggested by jcabi-manifests: http://manifests.jcabi.com/versioning.html
Also, see this blog post for more details: http://www.yegor256.com/2014/07/03/how-to-read-manifest-mf.html
In order to get the build machine I added the following plugin:
<plugin>
<groupId>org.codehaus.groovy.maven</groupId>
<artifactId>gmaven-plugin</artifactId>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>project.properties["hostname"] = InetAddress.getLocalHost().getHostName()</source>
</configuration>
</execution>
</executions>
</plugin>
I could then retrieve the host machine name through ${hostname}.
I am trying to set my build server information into META-INF/MANIFEST.MF. It works very well when using maven-jar-plugin with manifestEntries . The problem is that when I am packaging the Jar with maven-assembly-plugin to a single Jar with dependencies (like in here: How can I create an executable JAR with dependencies using Maven?) I can't see my manifest entries anymore. My guess is that my MANIFEST.MF is being dropped, while the assembly runs, but I could not find the way to set it after the manifest completes.
This is how my pom.xml build section looks like:
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<testSourceDirectory>src/test/java</testSourceDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2</version>
<configuration>
<archive>
<manifest>
<mainClass>ConvertorMain</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
<executions>
<execution>
<id>make-my-jar-with-dependencies</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<finalName>${project.artifactId}</finalName>
<archive>
<manifestEntries>
<Application-Version>${app.version.major}.${app.version.minor}.0</Application-Version>
<Built-By>${user}</Built-By>
<Git-Branch>${git.branch}</Git-Branch>
<Git-Commit>${git.commit}</Git-Commit>
</manifestEntries>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
</configuration>
</plugin>
</plugins>
...
</build>
Without the jar-with-dependencies, the MAINFEST.MF will contain:
Manifest-Version: 1.0
Git-Commit: 35ff1f997b0c01daf44ed23425a3dc93307faaf7
Build-Jdk: 1.7.0_03
Built-By: Build Server
Git-Branch: origin/HEAD
Created-By: Apache Maven
Application-Version: 0.2.57
Archiver-Version: Plexus Archiver
Then, unzip -q -c convertor-1.0-jar-with-dependencies.jar META-INF/MANIFEST.MF dumps:
Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Created-By: Apache Maven
Built-By: eranh
Build-Jdk: 1.6.0_35
Main-Class: ConvertorMain
You have simply to copy the archive section from your maven-jar-plugin configuration into the maven-assembly-plugin as well.
I need to have Maven insert the version number from the POM file into the manifest located in the WAR file under /WEB-INF/manifest.mf.
How do I do this? I was able to easily file documentation for doing this in a JAR file using the maven-jar-plugin, but that does not work on a WAR file.
Thanks for the help!
Figured it out using the maven-war-plugin. See the configuration below:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<archive>
<manifestEntries>
<version>${project.version}</version>
</manifestEntries>
</archive>
</configuration>
</plugin>
Or you can use the addDefaultImplementationEntries or addDefaultSpecificationEntries flags which will add several entries including the project.version property.
addDefaultImplementationEntries
Implementation-Title: ${project.name}
Implementation-Version: ${project.version}
Implementation-Vendor-Id: ${project.groupId}
Implementation-Vendor: ${project.organization.name}
Implementation-URL: ${project.url}
addDefaultSpecificationEntries
Specification-Title: ${project.name}
Specification-Version: ${project.version}
Specification-Vendor: ${project.organization.name}
Default value for both is false. If a property is not defined (e.g. project.organization.name), then that line will be excluded from the manifest.
This could go into the maven-war-plugin configuration as follows:
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.2</version>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
</archive>
</configuration>
</plugin>
Put ${project.version} in your manifest.mf where you want the version to be. In order for this to work, I believe you need the resources plugin so that manven will 'filter' resources as they are included in your war file.