@@ -428,27 +428,37 @@ private void copyFile(Path sourceFile, Path target, boolean overwrite) {
428428 }
429429
430430 void complete () {
431- if (Files .exists (outputDir )) {
432- copyFiles (outputDir , bundlePath .resolve (nativeImage .imageName + "." + outputDir .getFileName ()), true );
431+ assert status .buildImage || status .writeBundle : "Superfluous bundle operations" ;
432+
433+ Path workDir = nativeImage .config .getWorkingDirectory ();
434+
435+ if (status .buildImage ) {
436+ Path externalOutputDir = bundlePath .resolve (nativeImage .imageName + "." + outputDir .getFileName ());
437+ copyFiles (outputDir , externalOutputDir , true );
438+ nativeImage .showNewline ();
439+ nativeImage .showMessage ("Bundle output written to " + workDir .relativize (externalOutputDir ));
433440 }
434441
435442 try {
436- writeBundle ();
443+ if (status .writeBundle ) {
444+ Path bundleFilePath = writeBundle ();
445+ if (!status .buildImage ) {
446+ nativeImage .showNewline ();
447+ }
448+ nativeImage .showMessage ("Bundle written to " + workDir .relativize (bundleFilePath ));
449+ }
437450 } finally {
451+ nativeImage .showNewline ();
438452 nativeImage .deleteAllFiles (rootDir );
439453 }
440454 }
441455
442- public void setBundleLocation (Path imagePath , String imageName ) {
456+ void setBundleLocation (Path imagePath , String imageName ) {
443457 bundlePath = imagePath ;
444458 bundleName = imageName + bundleFileExtension ;
445459 }
446460
447- void writeBundle () {
448- if (!status .writeBundle ) {
449- return ;
450- }
451-
461+ private Path writeBundle () {
452462 String originalOutputDirName = outputDir .getFileName ().toString () + originalDirExtension ;
453463 Path originalOutputDir = rootDir .resolve (originalOutputDirName );
454464 if (Files .exists (originalOutputDir )) {
@@ -503,7 +513,8 @@ void writeBundle() {
503513 throw NativeImage .showError ("Failed to write bundle-file " + pathSubstitutionsFile , e );
504514 }
505515
506- try (JarOutputStream jarOutStream = new JarOutputStream (Files .newOutputStream (bundlePath .resolve (bundleName )), new Manifest ())) {
516+ Path bundleFilePath = this .bundlePath .resolve (bundleName );
517+ try (JarOutputStream jarOutStream = new JarOutputStream (Files .newOutputStream (bundleFilePath ), new Manifest ())) {
507518 try (Stream <Path > walk = Files .walk (rootDir )) {
508519 walk .forEach (bundleEntry -> {
509520 if (Files .isDirectory (bundleEntry )) {
@@ -524,6 +535,8 @@ void writeBundle() {
524535 } catch (IOException e ) {
525536 throw NativeImage .showError ("Failed to create bundle file " + bundleName , e );
526537 }
538+
539+ return bundleFilePath ;
527540 }
528541
529542 private static final String substitutionMapSrcField = "src" ;
0 commit comments