forked from cashapp/licensee
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
134 lines (120 loc) · 3.59 KB
/
build.gradle
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.kotlin.serialization)
id("java-gradle-plugin")
alias(libs.plugins.publish)
alias(libs.plugins.dokka)
alias(libs.plugins.spotless)
alias(libs.plugins.download)
}
gradlePlugin {
plugins {
licensee {
id = "app.cash.licensee"
displayName = "Licensee"
description = "Gradle plugin which validates the licenses of your dependency graph match what you expect"
implementationClass = "app.cash.licensee.LicenseePlugin"
}
}
}
tasks.named("validatePlugins") {
enableStricterValidation = true
}
dependencies {
compileOnly gradleApi()
compileOnly libs.androidGradleApi
compileOnly libs.kotlinGradlePlugin
implementation libs.kotlinx.serialization
implementation libs.maven.modelBuilder
testImplementation libs.junit
testImplementation libs.truth
testImplementation libs.testParameterInjector
testImplementation gradleTestKit()
}
kotlin {
jvmToolchain(11)
target {
compilations.configureEach {
// Ensure compatibility with old Gradle versions. Keep in sync with LicenseePlugin.kt.
compilerOptions.options.apiVersion.set(KotlinVersion.KOTLIN_1_8)
}
}
}
tasks.named("test") {
dependsOn(':publishAllPublicationsToTestingRepository')
systemProperty('licenseeVersion', VERSION_NAME)
systemProperty('line.separator', '\n')
testLogging {
if (System.getenv("CI") == "true") {
events = ["failed", "skipped", "passed"]
}
exceptionFormat "full"
}
// AGP 8+ requires JVM 17+.
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(20)
}
// Required to test configuration cache in tests when using withDebug()
// https://github.com/gradle/gradle/issues/22765#issuecomment-1339427241
jvmArgs(
"--add-opens",
"java.base/java.util=ALL-UNNAMED",
"--add-opens",
"java.base/java.util.concurrent.atomic=ALL-UNNAMED",
"--add-opens",
"java.base/java.lang.invoke=ALL-UNNAMED",
"--add-opens",
"java.base/java.net=ALL-UNNAMED",
)
}
def fixtures = file('src/test/fixtures')
def minimalJarBase64 = 'UEsFBgAAAAAAAAAAAAAAAAAAAAAAAA=='
tasks.register('writeFixtureJars') { task ->
task.doFirst {
fixtures.eachFileRecurse { File file ->
if (file.toString().contains('/repo/') && file.name.endsWith('.jar')) {
file.bytes = minimalJarBase64.decodeBase64()
}
}
}
}
def checkFixtureJars = tasks.register('checkFixtureJars') { task ->
task.doFirst {
fixtures.eachFileRecurse { File file ->
if (file.toString().contains('/repo/') && file.name.endsWith('.jar')) {
def fileBase64 = file.readBytes().encodeBase64().toString()
if (fileBase64 != minimalJarBase64) {
throw new RuntimeException(
"Expected '$minimalJarBase64' but was '$fileBase64'\n\n" +
"Invoke 'writeFixtureJars' task to fix.")
}
}
}
}
}
tasks.named('check') { check ->
check.dependsOn(checkFixtureJars)
}
tasks.register('updateLicenses', de.undercouch.gradle.tasks.download.Download) { task ->
task.src('https://spdx.org/licenses/licenses.json')
task.dest(file('src/main/resources/app/cash/licensee'))
}
publishing {
repositories {
maven {
name = "testing"
url = "${rootProject.projectDir}/build/localMaven"
}
}
}
spotless {
kotlin {
target('**/*.kt')
targetExclude("**/src/test/test-build-logic/build/**")
ktlint('0.48.1').editorConfigOverride([
'ktlint_standard_filename': 'disabled',
])
licenseHeaderFile(rootProject.file('gradle/license-header.txt'))
}
}