14

I want to add SplashScreen-Image: <image name> to the manifest file.

How do I do this with Spring Boot's Maven Plugin? If this is not possible, how do I create a single executable jar using maven with additional properties?

M.P. Korstanje
  • 10,426
  • 3
  • 36
  • 58

1 Answers1

31

The answer was kinda obvious in hindsight. Spring-Boot's maven plugin rewrites the original manifest file so using the maven jar plugin the manifest can be written as normal. Like this:

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
                <archive>
                    <manifestEntries>
                        <splashscreen-image>${image.name}</splashscreen-image>
                    </manifestEntries>
                </archive>
            </configuration>
        </plugin>

    </plugins>
</build>
M.P. Korstanje
  • 10,426
  • 3
  • 36
  • 58
  • 9
    If you're using `war` make sure to use `maven-war-plugin` in place of `maven-jar-plugin` – hdost Jun 28 '16 at 21:36
  • maven-jar-plugin works perfectly if ZIP is used with spring-boot-maven-plugin. +1 – aprodan Oct 11 '17 at 20:57
  • What code do you use to fetch that manifest property from within your spring-boot app? – chrisinmtown Nov 06 '17 at 12:12
  • 1
    Thanks. I was looking to do the same. Your solution worked for me. – Dinesh Arora Feb 09 '18 at 20:20
  • 1
    Doesn't work for me with spring boot 1.5.22.RELEASE – D. Naumovich Oct 08 '21 at 09:07
  • @D.Naumovich it's the plugin version (`mvn dependency:resolve-plugins`) that matters here, I had the same impression as you with `org.springframework.boot:spring-boot-maven-plugin:jar:2.7. 3` but in reality the plugin does not regenerate everything if the jar already exists, so you may re-test with `clean package` instead of `package` when changing `maven-jar-plugin` plugin configuration – boly38 Jan 04 '23 at 09:44