forked from oss-review-toolkit/ort
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathno_gpl_declared.kts
32 lines (27 loc) · 1014 Bytes
/
no_gpl_declared.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// Use this rule like:
//
// $ ort evaluate -i scanner/src/funTest/assets/file-counter-expected-output-for-analyzer-result.yml --rules-resource /rules/no_gpl_declared.kts
// Define a custom rule matcher.
fun PackageRule.LicenseRule.isGpl() =
object : RuleMatcher {
override val description = "isGpl($license)"
override fun matches() = license.contains("GPL")
}
// Define the rule set.
val ruleSet = ruleSet(ortResult) {
// Define a rule that is executed for each package.
packageRule("NO_GPL") {
// Define a rule that is executed for each license of the package.
licenseRule("NO_GPL", LicenseView.All) {
require {
+isGpl()
}
error(
"The package '${pkg.id.toCoordinates()}' has the ${licenseSource.name} license '$license'.",
"Remove the dependency on this package."
)
}
}
}
// Populate the list of errors to return.
ruleViolations += ruleSet.violations