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
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>