Skip to content

Commit

Permalink
PackageManagerConfiguration: Add the property mustRunAfter
Browse files Browse the repository at this point in the history
Make it possible to configure that one package manager must run after a
list of other package managers. For example, this can be used if one
package manager depends on files that are generated by another package
manager.

Fixes oss-review-toolkit#5174.

Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.io>
  • Loading branch information
mnonnenmacher authored and porsche-rbieniek committed Jun 27, 2022
1 parent 04d1e35 commit b4ecd22
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion analyzer/src/main/kotlin/Analyzer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class Analyzer(private val config: AnalyzerConfiguration, private val labels: Ma
manager = manager,
definitionFiles = files,
labels = labels,
mustRunAfter = emptySet(),
mustRunAfter = config.packageManagers?.get(manager.managerName)?.mustRunAfter?.toSet().orEmpty(),
finishedPackageManagersState = state.finishedPackageManagersState,
onResult = { result -> state.addResult(manager, result) }
)
Expand Down
6 changes: 6 additions & 0 deletions model/src/main/kotlin/config/PackageManagerConfiguration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ import com.fasterxml.jackson.annotation.JsonInclude
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
data class PackageManagerConfiguration(
/**
* A list of package manager names that this package manager must run after. For example, this can be used, if
* another package manager generates files that this package manager requires to run correctly.
*/
val mustRunAfter: List<String>? = null,

/**
* Custom configuration options for the package manager. See the documentation of the respective class for available
* options.
Expand Down
6 changes: 6 additions & 0 deletions model/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ ort {
disabledPackageManagers = [Maven, NPM]

packageManagers {
Gradle {
# A list of package manager names that this package manager must run after. For example, this can be used, if
# another package manager generates files that this package manager requires to run correctly.
mustRunAfter = [NPM]
}

# Some package managers provide custom configuration options that are documented in the package manager class. At
# the example of DotNet, these can be set like:
DotNet {
Expand Down
4 changes: 4 additions & 0 deletions model/src/test/kotlin/config/OrtConfigurationTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ class OrtConfigurationTest : WordSpec({
allowDynamicVersions shouldBe true

packageManagers shouldNotBeNull {
get("Gradle") shouldNotBeNull {
mustRunAfter should containExactly("NPM")
}

get("DotNet") shouldNotBeNull {
options shouldNotBeNull {
this shouldContainExactly mapOf("directDependenciesOnly" to "true")
Expand Down

0 comments on commit b4ecd22

Please sign in to comment.