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