Is it possible to somehow configure the spring boot maven plugin to include resources from a dependency.
E.g. if in my spring boot project I have:
<dependency>
<groupId>co.company</groupId>
<artifactId>example</artifactId>
</dependency>
and in that JAR file there is a properties file such as example.properties
jar -tf example.jar | grep example.properties | wc -l
results in 1.
However, when I build the spring boot JAR, this properties file is not added to the src/main/resources
. The JAR containing it is included in BOOT-INF/lib/example.jar
However, in my case. I'd like to extract the content of src/main/resources
out into the boot BOOT-INF/classes/
directory of the spring boot JAR so that things like auto configuration can pick it up.
In the real world, i'm trying to do this with:
src/main/resources
of the boot JAR).I think the solution for this problem would be very similar to the solution for another question you asked.
You can use the unpack
goal of the maven-dependency-plugin
in your Spring Boot module:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>module-a</artifactId>
<version>${project.version}</version>
<includes>**/*.yaml</includes>
</artifactItem>
</artifactItems>
<outputDirectory>${project.build.directory}/classes/BOOT-INF/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
That will copy the resources from module-a
to BOOT-INF
directory of your boot-module
. I've posted a more complete example on GitHub.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With