@@ -484,7 +484,7 @@ func installDependencies(workspace project.GoWorkspace) {
484
484
}
485
485
486
486
// Run the extractor.
487
- func extract (workspace project.GoWorkspace ) {
487
+ func extract (workspace project.GoWorkspace ) bool {
488
488
extractor , err := util .GetExtractorPath ()
489
489
if err != nil {
490
490
log .Fatalf ("Could not determine path of extractor: %v.\n " , err )
@@ -519,8 +519,11 @@ func extract(workspace project.GoWorkspace) {
519
519
cmd .Stderr = os .Stderr
520
520
err = cmd .Run ()
521
521
if err != nil {
522
- log .Fatalf ("Extraction failed: %s\n " , err .Error ())
522
+ log .Printf ("Extraction failed for %s: %s\n " , workspace .BaseDir , err .Error ())
523
+ return false
523
524
}
525
+
526
+ return true
524
527
}
525
528
526
529
// Build the project and run the extractor.
@@ -542,7 +545,8 @@ func installDependenciesAndBuild() {
542
545
// Remove temporary extractor files (e.g. auto-generated go.mod files) when we are done
543
546
defer project .RemoveTemporaryExtractorFiles ()
544
547
545
- for _ , workspace := range workspaces {
548
+ // Attempt to extract all workspaces; we will tolerate individual extraction failures here
549
+ for i , workspace := range workspaces {
546
550
goVersionInfo := workspace .RequiredGoVersion ()
547
551
548
552
// This diagnostic is not required if the system Go version is 1.21 or greater, since the
@@ -606,7 +610,35 @@ func installDependenciesAndBuild() {
606
610
}
607
611
}
608
612
609
- extract (workspace )
613
+ workspaces [i ].Extracted = extract (workspace )
614
+ }
615
+
616
+ // Find all projects which could not be extracted successfully
617
+ var unsuccessfulProjects = []string {}
618
+
619
+ for _ , workspace := range workspaces {
620
+ if ! workspace .Extracted {
621
+ unsuccessfulProjects = append (unsuccessfulProjects , workspace .BaseDir )
622
+ }
623
+ }
624
+
625
+ // If all projects could not be extracted successfully, we fail the overall extraction.
626
+ if len (unsuccessfulProjects ) == len (workspaces ) {
627
+ log .Fatalln ("Extraction failed for all discovered Go projects." )
628
+ }
629
+
630
+ // If there is at least one project that could not be extracted successfully,
631
+ // emit a diagnostic that reports which projects we could not extract successfully.
632
+ // We only consider this a warning, since there may be test projects etc. which
633
+ // do not matter if they cannot be extracted successfully.
634
+ if len (unsuccessfulProjects ) > 0 {
635
+ log .Printf (
636
+ "Warning: extraction failed for %d project(s): %s\n " ,
637
+ len (unsuccessfulProjects ),
638
+ strings .Join (unsuccessfulProjects , ", " ))
639
+ diagnostics .EmitExtractionFailedForProjects (unsuccessfulProjects )
640
+ } else {
641
+ log .Println ("Success: extraction succeeded for all discovered projects." )
610
642
}
611
643
}
612
644
0 commit comments