-
Notifications
You must be signed in to change notification settings - Fork 28
/
build.gradle.kts
129 lines (116 loc) · 3.92 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import kotlinx.validation.ExperimentalBCVApi
import org.jetbrains.dokka.gradle.DokkaExtension
import org.jetbrains.dokka.gradle.engine.parameters.VisibilityModifier
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)
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
}
}
dokka {
dokkaPublications.html {
outputDirectory.set(rootDir.resolve("docs/api/1.x"))
includes.from(project.layout.projectDirectory.file("README.md"))
}
}
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") {
configure<DokkaExtension> {
basePublicationsDirectory.set(layout.buildDirectory.dir("dokkaDir"))
dokkaSourceSets.configureEach {
skipDeprecated.set(true)
documentedVisibilities.add(VisibilityModifier.Public)
sourceLink {
localDirectory.set(layout.projectDirectory.dir("src"))
val relPath = rootProject.projectDir.toPath().relativize(projectDir.toPath())
remoteUrl(
providers.gradleProperty("POM_SCM_URL").map { scmUrl ->
"$scmUrl/tree/main/$relPath/src"
}
)
remoteLineSuffix.set("#L")
}
}
}
}
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) }
}
}
}
dependencies { dokka(project(":redacted-compiler-plugin-annotations")) }