If specify a finalName in my pom.xml file and then try to run spring-boot:build-image it hangs. I suspect I may need to configure the spring-boot:build-image task , but cannot find much documentation.
Springboot version: 2.4.3
Comment From: scottfrederick
I suspect I may need to configure the spring-boot:build-image task , but cannot find much documentation.
Configuration options for the spring-boot:build-image
task are documented here, with an example here.
As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements. Please post questions to Stack Overflow. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug.
Comment From: scottfrederick
If spring-boot:build-image
appears to hang, you might be running into #23115.
Comment From: haninaguib
I think it is a bug.
Here is a repo that shows the issue https://github.com/haninaguib/spring-issue-25590
It is a vanilla start.spring.io (maven, jdk11, starter-web) and the second commit only specifies the finalName in pom.xml
The issue is it complains about not being able to find demo.jar.original (since spring named it demo-0.0.1-SNAPSHOT.jar, ie there is now demo.jar and demo-0.0.1-SNAPSHOT.jar in the target directory and no demo.jar.original).
This is not about the docker image name but the springboot project finalName
Comment From: scottfrederick
Thanks very much for the sample. I'm able to reproduce this now, and the plugin is indeed not correctly identifying the jar file that should be used to build the image when finalName
is set.
Comment From: scottfrederick
@haninaguib I'm looking into the best way to fix this issue, but the way that finalName
property is configured in your example project is not how the Spring Boot plugin is intended to work. The property in the plugin is intended to be readonly
- read by the plugin from the project configuration but not directly configured by the user in the POM.
The name of the generated artifact should be configured in the <build>
section of the POM, not in the Spring Boot plugin configuration. That is, it should be:
<build>
<finalName>demo</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
instead of:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<finalName>demo</finalName>
</configuration>
</plugin>
</plugins>
</build>
Is there a reason why you were attempting to set the Spring Boot plugin finalName
to something different than the overall build finalName
, or does changing the configuration to match the first example meet your needs?
Comment From: haninaguib
The project I was working on was setup that way, not sure why (original developers are long gone), and moving it to build level fixes the issue in the original project. As far as I am concerned it is a user error and not an issue with spring boot. Not sure why I did not notice this when I created the sample project, sorry to take up your time.
Comment From: scottfrederick
The fact that Maven is allowing the finalName
to be set in the Boot plugin configuration separate from the <build>
configuration, and that it causes the build to hang, are definitely things that we need to fix. I appreciate you bringing it to our attention, even if it was unintentional.
Comment From: snicoll
Unfortunately, there's nothing we can do about that, I think. It is a Maven bug that's opened for quite a while. I've tried to fix it in #16202, but that introduced a regression so we changed that again in #16456.