Skip to content

Commit

Permalink
refactor(cyclonedx): Continue with remaining formats even if one failed
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Jul 16, 2024
1 parent fb1bef6 commit f1c8d1e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions plugins/reporters/cyclonedx/src/main/kotlin/CycloneDxReporter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import java.util.Date
import java.util.SortedSet
import java.util.UUID

import org.apache.logging.log4j.kotlin.logger

import org.cyclonedx.Version
import org.cyclonedx.generators.BomGeneratorFactory
import org.cyclonedx.model.AttachmentText
Expand Down Expand Up @@ -368,10 +370,14 @@ class CycloneDxReporter : Reporter {
outputFileExtensions.forEach { fileExtension ->
val outputFile = outputDir.resolve("$outputName.$fileExtension")

val bom = generateBom(bom, schemaVersion, fileExtension)

outputFile.bufferedWriter().use { it.write(bom) }
writtenFiles += outputFile
runCatching {
generateBom(bom, schemaVersion, fileExtension)
}.onSuccess { bom ->
outputFile.bufferedWriter().use { it.write(bom) }
writtenFiles += outputFile
}.onFailure {
logger.error("Unable to create CycloneDX report: ", it)
}
}

return writtenFiles
Expand Down

0 comments on commit f1c8d1e

Please sign in to comment.