Do no include runtime/provided/optional maven dependencies in image
See original GitHub issueDescription:
I am working on a spring-boot project and I have a runtime dependency on spring-boot-devtools
that is used during development.
When I build the image using jib-maven-plugin
spring-boot-devtools
is copied in /libs
directory even if the scope is runtime.
Expected: I expected the jar to be ignored the same way spring-boot maven plugin does not include it in the fat jar.
Step to reproduce: Create a maven project add a dependency with <scope>runtime</scope> configure jib-maven-plugin plugin build and run docker image docker exec -it <container> /bin/bash list the content of the libs/ directory the runtime dependency will be in the directory
Environment: jib-maven-plugin: version 0.10.0 OS: Mac OS X Maven: version 3.5.4 java: version 1.8.0_181
jib-maven-plugin
Configuration:
[...]
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>${jib-maven-plugin.version}</version>
<configuration>
<from>
<image>${docker.registry.host}/${docker.from.image}</image>
<credHelper>ecr-login</credHelper>
</from>
<to>
<image>${docker.registry.host}/${project.artifactId}:${build.number}</image>
<credHelper>ecr-login</credHelper>
<tags>
<tag>${build.number}</tag>
<tag>latest</tag>
</tags>
</to>
<container>
<appRoot>${docker.root.dir}</appRoot>
<mainClass>${main.class}</mainClass>
<useCurrentTimestamp>${docker.use-current-timestamp}</useCurrentTimestamp>
</container>
</configuration>
</plugin>
</plugins>
</build>
[...]
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:8 (5 by maintainers)
Top GitHub Comments
The Maven docs for
runtime
says:Although you’ve marked
spring-boot-devtools
as optional, the docs say:Which I interpret to mean that any project that depends on your project won’t pull in
spring-boot-devtools
. Butspring-boot-devtools
is still a dependency for your project and will be pulled in.I think you’ll need to use a Maven profile if you want to exclude
spring-boot-devtools
.For those coming to this thread to find a way to exclude
spring-too-devtools
, see #2336.