Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spring-boot:build-image hangs if finalName is specified in Spring Boot plugin configuration #25590

Closed
haninaguib opened this issue Mar 10, 2021 · 8 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@haninaguib
Copy link

haninaguib commented Mar 10, 2021

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

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 10, 2021
@scottfrederick
Copy link
Contributor

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.

@scottfrederick scottfrederick added for: stackoverflow A question that's better suited to stackoverflow.com and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 10, 2021
@scottfrederick
Copy link
Contributor

If spring-boot:build-image appears to hang, you might be running into #23115.

@haninaguib
Copy link
Author

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

@scottfrederick scottfrederick added status: waiting-for-triage An issue we've not yet triaged and removed for: stackoverflow A question that's better suited to stackoverflow.com labels Mar 10, 2021
@scottfrederick scottfrederick self-assigned this Mar 10, 2021
@scottfrederick
Copy link
Contributor

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.

@scottfrederick scottfrederick added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Mar 10, 2021
@scottfrederick scottfrederick added this to the 2.3.x milestone Mar 10, 2021
@scottfrederick
Copy link
Contributor

scottfrederick commented Mar 12, 2021

@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?

@haninaguib
Copy link
Author

haninaguib commented Mar 13, 2021

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.

@scottfrederick
Copy link
Contributor

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.

@snicoll
Copy link
Member

snicoll commented Mar 14, 2021

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.

@scottfrederick scottfrederick modified the milestones: 2.3.x, 2.3.10 Mar 19, 2021
@scottfrederick scottfrederick changed the title spring-boot:build-image hangs on Running creator if finalName is specified in pom spring-boot:build-image hangs if finalName is specified in Spring Boot plugin configuration Mar 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

5 participants