I am working on a spring boot project ( Project A ) that would be included in other projects ( Project B, Project C ... ) . I have several dependencies in Project A, but in the project importing Project A, some or only one may be required. I am trying to find a way to exclude the jar dependencies while packaging Project A so that the required ones will be provided by Project B during run time. I would like to have the dependencies available when the Project A is run independently for testing purposes.
Already tried the following
I have tried using:
<scope>provided</scope>
<optional>true</optional>
Still the jars end up in the final artifact.
Also tried adding the following to the spring-boot-maven-plugin
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<excludeArtifactIds>spring-boot-starter-redis</excludeArtifactIds>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
This would just remove the spring-boot dependency , but the jars for the children of this dependency would still end up in the final artifact.
See Question&Answers more detail:os