@@ -615,12 +615,7 @@ private void printBreakdowns() {
615615
616616 public void printEpilog (String imageName , NativeImageGenerator generator , ImageClassLoader classLoader , Throwable error , OptionValues parsedHostedOptions ) {
617617 executor .shutdown ();
618-
619- if (error != null && !NativeImageOptions .ErrorFileToStdout .getValue ()) {
620- Path errorReportPath = NativeImageOptions .getErrorFilePath ();
621- ReportUtils .report ("GraalVM Native Image Error Report" , errorReportPath , p -> VMErrorReporter .generateErrorReport (p , classLoader , error ), false );
622- BuildArtifacts .singleton ().add (ArtifactType .MARKDOWN , errorReportPath );
623- }
618+ createAdditionalArtifacts (imageName , generator , classLoader , error , parsedHostedOptions );
624619
625620 if (imageName == null || generator == null ) {
626621 printErrorMessage (error );
@@ -633,12 +628,14 @@ public void printEpilog(String imageName, NativeImageGenerator generator, ImageC
633628 double totalSeconds = Utils .millisToSeconds (getTimer (TimerCollection .Registry .TOTAL ).getTotalTime ());
634629 recordJsonMetric (ResourceUsageKey .TOTAL_SECS , totalSeconds );
635630
631+ if (jsonHelper != null ) {
632+ BuildArtifacts .singleton ().add (ArtifactType .JSON , jsonHelper .printToFile ());
633+ }
636634 Map <ArtifactType , List <Path >> artifacts = generator .getBuildArtifacts ();
637-
638635 if (!artifacts .isEmpty ()) {
639- l ().printLineSeparator ();
640- printArtifacts (imageName , generator , parsedHostedOptions , artifacts , error );
636+ BuildArtifacts .singleton ().add (ArtifactType .TXT , reportBuildArtifacts (NativeImageGenerator .generatedFiles (HostedOptionValues .singleton ()), imageName , artifacts ));
641637 }
638+ printArtifacts (artifacts );
642639
643640 l ().printHeadlineSeparator ();
644641
@@ -654,6 +651,17 @@ public void printEpilog(String imageName, NativeImageGenerator generator, ImageC
654651 printErrorMessage (error );
655652 }
656653
654+ private static void createAdditionalArtifacts (String imageName , NativeImageGenerator generator , ImageClassLoader classLoader , Throwable error , OptionValues parsedHostedOptions ) {
655+ if (error != null && !NativeImageOptions .ErrorFileToStdout .getValue ()) {
656+ Path errorReportPath = NativeImageOptions .getErrorFilePath ();
657+ ReportUtils .report ("GraalVM Native Image Error Report" , errorReportPath , p -> VMErrorReporter .generateErrorReport (p , classLoader , error ), false );
658+ BuildArtifacts .singleton ().add (ArtifactType .MARKDOWN , errorReportPath );
659+ }
660+ if (generator .getBigbang () != null && ImageBuildStatistics .Options .CollectImageBuildStatistics .getValue (parsedHostedOptions )) {
661+ BuildArtifacts .singleton ().add (ArtifactType .JSON , reportImageBuildStatistics (imageName , generator .getBigbang ()));
662+ }
663+ }
664+
657665 private void printErrorMessage (Throwable error ) {
658666 if (error == null ) {
659667 return ;
@@ -677,7 +685,11 @@ private void printErrorMessage(Throwable error) {
677685 }
678686 }
679687
680- private void printArtifacts (String imageName , NativeImageGenerator generator , OptionValues parsedHostedOptions , Map <ArtifactType , List <Path >> artifacts , Throwable error ) {
688+ private void printArtifacts (Map <ArtifactType , List <Path >> artifacts ) {
689+ if (artifacts .isEmpty ()) {
690+ return ;
691+ }
692+ l ().printLineSeparator ();
681693 l ().yellowBold ().a ("Produced artifacts:" ).reset ().println ();
682694 // Use TreeMap to sort paths alphabetically.
683695 Map <Path , List <String >> pathToTypes = new TreeMap <>();
@@ -686,15 +698,6 @@ private void printArtifacts(String imageName, NativeImageGenerator generator, Op
686698 pathToTypes .computeIfAbsent (path , p -> new ArrayList <>()).add (artifactType .name ().toLowerCase ());
687699 }
688700 });
689- if (error == null && jsonHelper != null ) {
690- Path jsonMetric = jsonHelper .printToFile ();
691- pathToTypes .computeIfAbsent (jsonMetric , p -> new ArrayList <>()).add ("json" );
692- }
693- if (generator .getBigbang () != null && ImageBuildStatistics .Options .CollectImageBuildStatistics .getValue (parsedHostedOptions )) {
694- Path buildStatisticsPath = reportImageBuildStatistics (imageName , generator .getBigbang ());
695- pathToTypes .computeIfAbsent (buildStatisticsPath , p -> new ArrayList <>()).add ("raw" );
696- }
697- pathToTypes .computeIfAbsent (reportBuildArtifacts (NativeImageGenerator .generatedFiles (HostedOptionValues .singleton ()), imageName , artifacts ), p -> new ArrayList <>()).add ("txt" );
698701 pathToTypes .forEach ((path , typeNames ) -> {
699702 l ().a (" " ).link (path ).dim ().a (" (" ).a (String .join (", " , typeNames )).a (")" ).reset ().println ();
700703 });
0 commit comments