@@ -24,6 +24,7 @@ import com.fasterxml.jackson.module.kotlin.readValue
24
24
25
25
import com.github.ajalt.clikt.core.CliktCommand
26
26
import com.github.ajalt.clikt.parameters.options.convert
27
+ import com.github.ajalt.clikt.parameters.options.default
27
28
import com.github.ajalt.clikt.parameters.options.option
28
29
import com.github.ajalt.clikt.parameters.options.required
29
30
import com.github.ajalt.clikt.parameters.types.file
@@ -44,13 +45,18 @@ import org.ossreviewtoolkit.model.Scope
44
45
import org.ossreviewtoolkit.model.VcsInfo
45
46
import org.ossreviewtoolkit.model.VcsType
46
47
import org.ossreviewtoolkit.model.config.Excludes
48
+ import org.ossreviewtoolkit.model.config.OrtConfiguration
47
49
import org.ossreviewtoolkit.model.config.RepositoryConfiguration
48
50
import org.ossreviewtoolkit.model.config.ScopeExclude
49
51
import org.ossreviewtoolkit.model.config.ScopeExcludeReason
50
52
import org.ossreviewtoolkit.model.mapper
51
53
import org.ossreviewtoolkit.model.orEmpty
54
+ import org.ossreviewtoolkit.model.utils.addPackageCurations
55
+ import org.ossreviewtoolkit.plugins.packagecurationproviders.api.PackageCurationProviderFactory
52
56
import org.ossreviewtoolkit.utils.common.expandTilde
53
57
import org.ossreviewtoolkit.utils.ort.Environment
58
+ import org.ossreviewtoolkit.utils.ort.ORT_CONFIG_FILENAME
59
+ import org.ossreviewtoolkit.utils.ort.ortConfigDirectory
54
60
55
61
internal class CreateAnalyzerResultFromPackageListCommand : CliktCommand (
56
62
" A command which turns a package list file into an analyzer result."
@@ -71,6 +77,14 @@ internal class CreateAnalyzerResultFromPackageListCommand : CliktCommand(
71
77
.convert { it.absoluteFile.normalize() }
72
78
.required()
73
79
80
+ private val configFile by option(
81
+ " --config" ,
82
+ help = " The path to the ORT configuration file that configures the scan results storage."
83
+ ).convert { it.expandTilde() }
84
+ .file(mustExist = true , canBeFile = true , canBeDir = false , mustBeWritable = false , mustBeReadable = true )
85
+ .convert { it.absoluteFile.normalize() }
86
+ .default(ortConfigDirectory.resolve(ORT_CONFIG_FILENAME ))
87
+
74
88
override fun run () {
75
89
val packageList = packageListFile.mapper().copy().apply {
76
90
// Use camel case already now (even if in all places snake case is used), because there is a plan
@@ -92,6 +106,9 @@ internal class CreateAnalyzerResultFromPackageListCommand : CliktCommand(
92
106
)
93
107
)
94
108
109
+ val ortConfig = OrtConfiguration .load(emptyMap(), configFile)
110
+ val packageCurationProviders = PackageCurationProviderFactory .create(ortConfig.packageCurationProviders)
111
+
95
112
val ortResult = OrtResult (
96
113
analyzer = AnalyzerRun .EMPTY .copy(
97
114
result = AnalyzerResult (
@@ -110,7 +127,7 @@ internal class CreateAnalyzerResultFromPackageListCommand : CliktCommand(
110
127
)
111
128
)
112
129
)
113
- )
130
+ ).addPackageCurations(packageCurationProviders)
114
131
115
132
writeOrtResult(ortResult, ortFile)
116
133
}
0 commit comments