jib
jib copied to clipboard
Add support to read from `configuration.outputDirectory` parameter in the spring-boot-maven-plugin
Environment:
- Jib version: 3.1.2
- Build tool: Maven 3.6.3
- OS: mac OS 10.15.7(19H2)
Description of the issue:
When I build(or dockerBuild) with below configuration shows up this error message.
Obtaining project build output files failed; make sure you have packaged your project before trying to build the image. (Did you accidentally run "mvn clean jib:build" instead of "mvn clean package jib:build"?)
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.3.2.RELEASE</version>
<configuration>
<outputDirectory>lib</outputDirectory>
</configuration>
</plugin>
$ mvn clean package jib:dockerBuild
...
Caused by: java.io.IOException: Obtaining project build output files failed; make sure you have packaged your project before trying to build the image. (Did you accidentally run "mvn clean jib:build" instead of "mvn clean package jib:build"?)
...
Caused by: java.nio.file.NoSuchFileException: /path/to/my-project/target/my-application.jar.original
Build success when remove configuration.outputDirectory
.
It seems not read outputDirectory configuration if spring-boot-maven-plugin
is used.
(I guessed by looking at this code.)
Is it intended behavior?
Expected behavior:
Build success when using outputDirectory
in spring-boot-maven-plugin
Steps to reproduce:
- use spring-boot-maven-plugin
- set
outputDirectory
-
mvn clean package jib:dockerBuild
@hellozin Thank you for the report! We are trying to reproduce the issue.
It's a bug (or limitation) in that the output directory is unaccounted for. Note that Jib doesn't use the repackaged Spring Boot fat JAR but a standard thin-JAR packaged by maven-jar-plugin
. The current code to read Spring Boot configuration is just to correctly find the path for the thin-JAR (because the Spring Boot plugin renames the original JAR before replacing it). Some workarounds:
- Don't do "packaged" containerization. That is, remove
<containerizingMode>packaged
. We normally recommend the non-packaged mode unless there is a specific reason, because the non-packaged mode builds a bit more optimized image. - Don't set
<outputDirectory>
inspring-boot-maven-plugin
. Jib won't make use of a Spring Boot fat JAR anyway. - Set
<outputDirectory>
inmaven-jar-plugin
to match the directory set inspring-boot-maven-plugin
, e.g.,
(You may need to run<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <outputDirectory>lib</outputDirectory> </configuration> </plugin>
mvn package
once more.)
I would like to work on this issue.
@RandyLovevivi Sure, we would love to have some contributions from the society. Let us know if you need any help!
Hey @RandyLovevivi, are you still working on this issue?
@AnvarKhatik there hasn't been much activity on this issue for a while so we're happy to review your contribution if you're interested in taking it on.
@mpeddada1 @ddixit14 can I pick up this issue ?