Cannot find JAR in outputDirectory path when using spring-boot-maven-plugin
See original GitHub issueEnvironment:
- 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
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
cannot get resources folder into jar when using spring boot ...
Im trying to build an executable jar that runs with spring boot, but I cant get the spring xml from the resources folder...
Read more >Spring Boot Maven Plugin Documentation
It allows you to package executable jar or war archives, run Spring Boot applications, generate build information and start your Spring Boot ...
Read more >Maven JAR plugin skipping generated-resources folder ...
Related Query · cannot get resources folder into jar when using spring boot maven plugin · Maven JAR plugin skipping generated-resources folder ·...
Read more >Running a Spring Boot App with Maven vs an Executable Jar
Get started with Spring 5 and Spring Boot 2, through the Learn Spring ... the Spring Boot Maven plugin is the recommended tool...
Read more >Apache Maven Dependency Plugin – dependency:copy ...
(example /outputDirectory/junit-3.8.1-jar ) Default value is: false . User property is: mdep.useSubDirectoryPerArtifact .
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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:<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.<outputDirectory>
inspring-boot-maven-plugin
. Jib won’t make use of a Spring Boot fat JAR anyway.<outputDirectory>
inmaven-jar-plugin
to match the directory set inspring-boot-maven-plugin
, e.g., (You may need to runmvn package
once more.)@hellozin Thank you for the report! We are trying to reproduce the issue.