Moritz
Moritz

Reputation: 2516

How to make Spring Boot include the manifest file in its repackaged WAR?

I'm building a Spring Boot application using spring-boot-starter-parent version 2.1.0-RELEASE and need it to produce a deployable WAR file containing a MANIFEST.MF in the META-INF/ directory. I've set up the Maven WAR plugin to include the manifest in the build artifact:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-war-plugin</artifactId>
  <version>3.2.2</version>
  <configuration>
    <archive>
      <manifest>
        <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
      </manifest>
    </archive>
  </configuration>
</plugin>

However, the final build artifact doesn't include a manifest file. I noticed that Spring Boot performs a repackaging after the Maven WAR plugin packaged the WAR file in the first place:

[INFO] --- spring-boot-maven-plugin:2.1.0.RELEASE:repackage (repackage)

And indeed the artifact.war.original in the target directory does contain the manifest.

How do I make Spring Boot to include the manifest in the final WAR file as well?

Upvotes: 2

Views: 2561

Answers (2)

Gayan Mettananda
Gayan Mettananda

Reputation: 1518

Use the spring-boot-maven-plugin for this as below.

<packaging>war</packaging>

<build>
    <outputDirectory>${basedir}/src/main/webapp/WEB-INF/classes</outputDirectory>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>2.1.2.RELEASE</version>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <mainClass>com.yourMainClass</mainClass>
            </configuration>
        </plugin>
    </plugins>
</build>

Upvotes: 0

Antoniossss
Antoniossss

Reputation: 32507

You don't need that in "repacked" WAR (at least not in the place you want it to be) as it contains custom loading mechanisms. Repacked WAR is still 'deployable'

Upvotes: 0

Related Questions