Skip to content

Commit

Permalink
fix(aosd): Always add a default part
Browse files Browse the repository at this point in the history
Signed-off-by: Hans Goth <[email protected]>
Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
GothHans authored and sschuberth committed Nov 19, 2024
1 parent 040695b commit 7d1bdde
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
17 changes: 14 additions & 3 deletions plugins/reporters/aosd/src/main/kotlin/Aosd2Reporter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,30 @@ class Aosd2Reporter(override val descriptor: PluginDescriptor = Aosd2ReporterFac
}
}

private fun Package.toExternalDependency(input: ReporterInput): ExternalDependency =
ExternalDependency(
private fun Package.toExternalDependency(input: ReporterInput): ExternalDependency {
val licenses = toLicenses(input)

// There has to be at least one part. As nothing is known about the logical layout of the external dependency,
// assume that there are no separate parts and always create a default one.
val defaultPart = AOSD2.Part(
name = "default",
providers = listOf(AOSD2.Provider(additionalLicenses = licenses))
)

return ExternalDependency(
id = id.toCoordinates(),
name = id.name,
scmUrl = vcsProcessed.url.takeUnless { it.isEmpty() },
description = description.takeUnless { it.isEmpty() },
version = id.version,
licenses = toLicenses(input),
licenses = licenses,
parts = listOf(defaultPart),
deployPackage = binaryArtifact.toDeployPackage(),
externalDependencies = input.ortResult.getDependencies(id, maxLevel = 1, omitExcluded = true).map {
it.toCoordinates()
}
)
}

private fun Package.toLicenses(input: ReporterInput): List<AOSD2.License> {
val licenses = mutableListOf<AOSD2.License>()
Expand Down
6 changes: 5 additions & 1 deletion plugins/reporters/aosd/src/main/kotlin/Model.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.encodeToStream
import kotlinx.serialization.EncodeDefault

/**
* The JSON format for importing product dependencies into AOSD 2.0, see https://www.aosd.cloud.audi/jsonschemadoc/.
Expand Down Expand Up @@ -136,8 +137,11 @@ internal data class AOSD2(
*/
@Serializable
data class Provider(
val additionalLicenses: List<License>,
@EncodeDefault
val additionalLicenses: List<License> = emptyList(),
@EncodeDefault
val modified: Boolean = false,
@EncodeDefault
val usage: Usage = Usage.DYNAMIC_LINKING
)

Expand Down

0 comments on commit 7d1bdde

Please sign in to comment.