55 lines
1.6 KiB
Kotlin
55 lines
1.6 KiB
Kotlin
import groovy.json.JsonSlurper
|
|
|
|
plugins {
|
|
alias(libs.plugins.kotlin.jvm)
|
|
}
|
|
|
|
kotlin {
|
|
jvmToolchain(17)
|
|
|
|
sourceSets {
|
|
main {
|
|
kotlin.srcDir("src/main/java")
|
|
}
|
|
test {
|
|
kotlin.srcDir("src/test/java")
|
|
}
|
|
}
|
|
}
|
|
dependencies {
|
|
testImplementation(libs.junit)
|
|
}
|
|
|
|
tasks.test {
|
|
useJUnit()
|
|
testLogging {
|
|
events("failed", "skipped")
|
|
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
|
|
}
|
|
}
|
|
|
|
tasks.register("verifyDependencyLicenses") {
|
|
group = "verification"
|
|
description = "Ensures every resolved JVM runtime/test artifact has a reviewed license entry."
|
|
|
|
doLast {
|
|
@Suppress("UNCHECKED_CAST")
|
|
val manifest = JsonSlurper().parse(rootProject.file("config/dependency-licenses.json")) as Map<String, Any>
|
|
@Suppress("UNCHECKED_CAST")
|
|
val components = manifest.getValue("components") as List<Map<String, Any>>
|
|
val reviewedCoordinates = components.mapNotNull { it["coordinates"] as String? }.toSet()
|
|
val resolvedCoordinates = configurations.getByName("testRuntimeClasspath")
|
|
.resolvedConfiguration
|
|
.resolvedArtifacts
|
|
.map { artifact ->
|
|
val id = artifact.moduleVersion.id
|
|
"${id.group}:${id.name}:${id.version}"
|
|
}
|
|
.toSet()
|
|
val missing = resolvedCoordinates - reviewedCoordinates
|
|
check(missing.isEmpty()) {
|
|
"Dependencies missing reviewed license entries: ${missing.sorted().joinToString()}"
|
|
}
|
|
}
|
|
}
|