Document that repackage should not be used on the command-line

This commit clarifies how we intend the spring-boot:repackage goal to
be used. As it operates on the source jar (or war) that must be
effectively up-to-date to produce an accurate result, the package phase
must have run.

Contrary to build-image that was designed to be used on the command-line
by forking a package lifecycle first, repackage does not do that. This
commit also clarifies that by providing a more focused error message.

Closes gh-22317
This commit is contained in:
Stéphane Nicoll
2024-08-05 16:05:00 +02:00
parent 218e7aa993
commit 7607bf1ab8
2 changed files with 8 additions and 0 deletions

View File

@@ -221,6 +221,10 @@ public class RepackageMojo extends AbstractPackagerMojo {
private void repackage() throws MojoExecutionException {
Artifact source = getSourceArtifact(this.classifier);
File target = getTargetFile(this.finalName, this.classifier, this.outputDirectory);
if (source.getFile() == null) {
throw new MojoExecutionException(
"Source file is not available, make sure 'package' runs as part of the same lifecycle");
}
Repackager repackager = getRepackager(source.getFile());
Libraries libraries = getLibraries(this.requiresUnpack);
try {