3

In my spring boot project, during the build process, I'm generating the fat jar and boot jar for my application.

Usecase: I have a scenario where I need to exclude the resource folder from the fat jar at the same time I need to include the same resource folder into my boot jar.

Below snippet, I have used in my project

<build>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>true</filtering>
            <excludes>
                <exclude>**/*</exclude>
            </excludes>
        </resource>
    </resources>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <classifier>boot</classifier>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.6</version>
            <executions>
                <execution>
                    <goals>
                        <goal>test-jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Using the above snippet, resource folders are getting excluded in both fat and boot jars. can someone please guide me to achieve this use-case?

Java version: 1.8

Maveen version: 3.6.3

Spring Boot version: v2.1.2.RELEASE

Ramakrishnan M
  • 482
  • 1
  • 6
  • 16

0 Answers0