-
Notifications
You must be signed in to change notification settings - Fork 40.8k
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
mvn spring-boot:build-image fails when 'classifier' is set to non-default value #26721
Comments
@kdvolder Using a goal like that in isolation is not working great with Maven. It really is supposed to be invoked using a phase, not a goal. We're trying to do our best with what Maven allows us to do but it is far from perfect. If you run
Going forward, please push the sample project on GitHub and share the link. You describing the steps and us following them is really a waste of time for everybody compared to cloning a project and running a command. |
I tried Sorry about not attaching a sample. I did my best to describe the issue as clearly as possible, so that the steps would be easy to reproduce. And there really isn't anything in the sample project except what initializer generated and a few lines of extra xml. So it seemed a bit pointless to me to attach this. But anyhow, I'll keep in mind for the next time. And I still have the project here so I'll attach it now: |
Thanks, that's an interesting piece of information.
The point I was trying to make is that the time you spent describing what you did and the time we spent to read and replicate what you've described can be eliminated by providing the project. Surely it still requires some description but we're reducing greatly the chances of making a mistake while trying to replicate the description in our own project. Thanks for sharing the sample project. |
Point about sample project taken. I guess I didn't think about it that way. The steps in themselves seem interesting to me as they clearly document what exactly is interesting about the sample (i.e. it only has one small change from a 'run of the mill' project, and surely that would be a good clue as to what the cause of the problem might be. But I could have given these steps as well as attached the sample, and it would have made the bug report strictly better and even easier to reproduce. So I should have thought of that. |
I suggest that since it works without the "classifier" configuration, there might be a bug in Spring Boot and we should be able to fix it. You can easily reproduce this with any app downloaded from start.spring.io, by adding the classifier to the Spring Boot Maven plugin config, and then running |
@dsyer this is already triaged as a bug... |
If you change the spring-boot-maven-plugin plugin configuration from this:
to this:
then it works. Maybe this will help to understand the problem |
@asandoval95 It's seems that your suggestion does not work as expected. With your configuration, the generated image size is about 230MB. It's greater than the first generated image when executing the command mvn package spring-boot:build-image But this issue is tagged as a bug. |
Is this fixed in 3.x? |
Since it’s still open, I doubt it. The workaround should still be fine though. |
When running I don't have enough Maven expertise to tell if we can change that somehow. |
The reason this is happening is because when you run Looking at |
Previously, if a classifier was set and build-image was executed from the command-line, the build will fail as the plugin was unable to find the original jar. This is because it relies on the attached artifacts of the project, and those are not set when package has run as part of a forked lifecycle. This commit makes sure that the backup file is found by convention first, the same way it is done for the target file. Closes spring-projectsgh-26721
Spring-boot version: 2.5.0 (also originally this happened to me with version 2.4.3, but I reproduced in 2.5.0 to file this bug).
Steps:
First create a new empty maven project with start.spring.io
Then add a 'classifier' to the spring-boot maven plugin configuration:
Then run
Relevant error excerpt (full output end of this issue):
It seems like the
build-image
task is confused by the changes in config affecting the 'repackage' operation. It is looking for the 'original' (i.e. prior to repackaging) jar in the wrong place.Perhaps this is something I am doing wrong? It is entirely possible. If so I apologise.
However, this feels like a bug to me as it seems reasonable to expect the
repackage
and thebuild-image
tasks to be aware of eachother. They are both part of the same spring-boot maven plugin and the docs seem to even suggest they are tightly coupled and are supposed to work together.So far the only workaround that I have found for this problem is to simply refrain from configuring a classifier.
Full output:
The text was updated successfully, but these errors were encountered: