Skip to content

Commit 8897036

Browse files
Merge pull request #685 from geoand/#684
Set proper error message when building native image without prior packaging
2 parents 3a2f1e1 + 9a02236 commit 8897036

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

cli/maven/src/main/java/org/jboss/shamrock/maven/NativeImageMojo.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ public NativeImageMojo() {
126126
@Override
127127
public void execute() throws MojoExecutionException, MojoFailureException {
128128

129+
if (! buildDir.isDirectory() || ! new File(buildDir, "lib").isDirectory()) {
130+
throw new MojoFailureException("Unable to find the required build output. " +
131+
"Please ensure that the 'build' goal has been properly configured for the project - since it is a prerequisite of the 'native-image' goal");
132+
}
133+
129134
try(AppCreator appCreator = AppCreator.builder()
130135
// configure the build phase we want the app to go through
131136
.addPhase(new NativeImagePhase()

core/creator/src/main/java/org/jboss/shamrock/creator/phase/nativeimage/NativeImagePhase.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ public void provideOutcome(AppCreator ctx) throws AppCreatorException {
237237
final String runnerJarName = runnerJar.getFileName().toString();
238238

239239
Path outputLibDir = outputDir.resolve(runnerJarOutcome.getLibDir().getFileName());
240+
boolean outputLibDirCopied = false;
240241
if (Files.exists(outputLibDir)) {
241242
outputLibDir = null;
242243
} else {
@@ -245,6 +246,7 @@ public void provideOutcome(AppCreator ctx) throws AppCreatorException {
245246
} catch (IOException e) {
246247
throw new AppCreatorException("Failed to copy the runnable jar and the lib to the docker project dir", e);
247248
}
249+
outputLibDirCopied = true;
248250
}
249251

250252
final Config config = SmallRyeConfigProviderResolver.instance().getConfig();
@@ -411,7 +413,7 @@ public void provideOutcome(AppCreator ctx) throws AppCreatorException {
411413
if(runnerJarCopied) {
412414
IoUtils.recursiveDelete(runnerJar);
413415
}
414-
if(outputLibDir != null) {
416+
if(outputLibDirCopied) {
415417
IoUtils.recursiveDelete(outputLibDir);
416418
}
417419
}

0 commit comments

Comments
 (0)