-
Notifications
You must be signed in to change notification settings - Fork 26
/
build.gradle.kts
105 lines (95 loc) · 3.16 KB
/
build.gradle.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
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
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import kotlinx.validation.ExperimentalBCVApi
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmCompilerOptions
import org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinBasePlugin
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
buildscript {
dependencies {
// Include our included build
classpath("dev.zacsweers.redacted:redacted-compiler-plugin-gradle")
}
}
plugins {
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.dokka) apply false
alias(libs.plugins.ksp) apply false
alias(libs.plugins.mavenPublish) apply false
alias(libs.plugins.spotless)
alias(libs.plugins.binaryCompatibilityValidator)
}
apiValidation {
ignoredProjects += listOf("sample", "sample-jvm")
@OptIn(ExperimentalBCVApi::class)
klib {
// This is only really possible to run on macOS
// strictValidation = true
enabled = true
}
}
spotless {
format("misc") {
target("*.gradle", "*.md", ".gitignore")
trimTrailingWhitespace()
indentWithSpaces(2)
endWithNewline()
}
kotlin {
target("**/*.kt")
ktfmt(libs.versions.ktfmt.get()).googleStyle()
trimTrailingWhitespace()
endWithNewline()
licenseHeaderFile("spotless/spotless.kt")
targetExclude("**/spotless.kt", "**/build/**")
}
kotlinGradle {
target("**/*.kts", "*.kts")
ktfmt(libs.versions.ktfmt.get()).googleStyle()
trimTrailingWhitespace()
endWithNewline()
}
}
subprojects {
group = project.property("GROUP") as String
version = project.property("VERSION_NAME") as String
pluginManager.withPlugin("java") {
configure<JavaPluginExtension> {
toolchain { languageVersion.set(libs.versions.jdk.map(JavaLanguageVersion::of)) }
}
tasks.withType<JavaCompile>().configureEach {
options.release.set(libs.versions.jvmTarget.map(String::toInt))
}
}
plugins.withType<KotlinBasePlugin> {
project.tasks.withType<KotlinCompilationTask<*>>().configureEach {
compilerOptions {
progressiveMode.set(true)
if (this is KotlinJvmCompilerOptions) {
if (project.name != "sample") {
jvmTarget.set(libs.versions.jvmTarget.map(JvmTarget::fromTarget))
}
freeCompilerArgs.addAll("-Xjvm-default=all")
}
}
}
if ("sample" !in project.path) {
configure<KotlinProjectExtension> { explicitApi() }
}
}
pluginManager.withPlugin("org.jetbrains.dokka") {
tasks.named<DokkaTask>("dokkaHtml") {
outputDirectory.set(rootProject.file("docs/0.x"))
dokkaSourceSets.configureEach { skipDeprecated.set(true) }
}
}
plugins.withId("com.vanniktech.maven.publish") {
configure<MavenPublishBaseExtension> { publishToMavenCentral(automaticRelease = true) }
// configuration required to produce unique META-INF/*.kotlin_module file names
tasks.withType<KotlinCompile>().configureEach {
compilerOptions { moduleName.set(project.property("POM_ARTIFACT_ID") as String) }
}
}
}