-
Notifications
You must be signed in to change notification settings - Fork 17
/
build.gradle.kts
156 lines (150 loc) · 5.72 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
import com.vanniktech.maven.publish.MavenPublishBaseExtension
import com.vanniktech.maven.publish.SonatypeHost
import org.jetbrains.dokka.gradle.DokkaTask
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
plugins {
alias(libs.plugins.git)
alias(libs.plugins.spotless)
}
apply(plugin = "com.vanniktech.maven.publish.base")
// The releaseVersion property is set on official releases in the release.yml workflow.
// If not specified, we attempt to calculate a snapshot version based on the last tagged release.
// So if the local build's last tag was v0.1.9, this will set snapshotVersion to 0.1.10-SNAPSHOT.
// If this fails for any reason, we'll fall back to using 0.0.0-SNAPSHOT version.
val versionDetails: groovy.lang.Closure<com.palantir.gradle.gitversion.VersionDetails> by extra
val details = versionDetails()
var snapshotVersion = "0.0.0-SNAPSHOT"
val matchResult = """^v(\d+)\.(\d+)\.(\d+)$""".toRegex().matchEntire(details.lastTag)
if (matchResult != null) {
val (major, minor, patch) = matchResult.destructured
snapshotVersion = "$major.$minor.${patch.toInt() + 1}-SNAPSHOT"
}
val releaseVersion = project.findProperty("releaseVersion") as String? ?: snapshotVersion
buildscript {
dependencies {
classpath(libs.dokka.core)
classpath(libs.maven.plugin)
classpath(libs.android.plugin)
classpath(libs.dokka.plugin)
classpath(libs.kotlin.plugin)
classpath(libs.spotless)
}
repositories {
mavenCentral()
google()
gradlePluginPortal()
}
}
allprojects {
version = releaseVersion
repositories {
gradlePluginPortal()
mavenCentral()
google()
}
apply(plugin = "com.diffplug.spotless")
spotless {
isEnforceCheck = false // Disables lint on gradle builds.
kotlin {
ktlint().editorConfigOverride(
mapOf(
"ktlint_experimental" to "enabled",
// Disabled until https://github.com/pinterest/ktlint/pull/2273 is released
"ktlint_standard_function-expression-body" to "disabled",
),
)
target("**/*.kt")
}
kotlinGradle {
ktlint().editorConfigOverride(
mapOf(
"ktlint_experimental" to "enabled",
// Disabled until https://github.com/pinterest/ktlint/pull/2273 is released
"ktlint_standard_function-expression-body" to "disabled",
),
)
target("**/*.kts")
}
}
tasks.withType<Jar>().configureEach {
if (name == "jar") {
val parentName = project.parent?.name ?: ""
val resolvedName = if (parentName != "connect-kotlin") {
"${project.name}-$parentName"
} else {
project.name
}
this.archiveBaseName.set(resolvedName)
manifest {
attributes("Automatic-Module-Name" to resolvedName)
attributes("Implementation-Version" to releaseVersion)
}
}
}
tasks.withType<DokkaTask>().configureEach {
dokkaSourceSets.configureEach {
skipDeprecated.set(true)
jdkVersion.set(8)
}
}
plugins.withId("com.vanniktech.maven.publish.base") {
configure<MavenPublishBaseExtension> {
val isAutoReleased = project.hasProperty("signingInMemoryKey")
publishToMavenCentral(SonatypeHost.S01)
if (isAutoReleased) {
signAllPublications()
}
pom {
description.set("Simple, reliable, interoperable. A better RPC.")
name.set("connect-library") // This is overwritten in subprojects.
group = "com.connectrpc"
url.set("https://github.com/connectrpc/connect-kotlin")
licenses {
license {
name.set("The Apache Software License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
distribution.set("repo")
}
}
developers {
developer {
id.set("connectrpc")
name.set("The Connect Authors")
}
}
scm {
url.set("https://github.com/connectrpc/connect-kotlin")
connection.set("scm:git:https://github.com/connectrpc/connect-kotlin.git")
developerConnection.set("scm:git:ssh://[email protected]/connectrpc/connect-kotlin.git")
}
}
}
}
}
subprojects {
tasks.withType<KotlinJvmCompile> {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_1_8)
languageVersion.set(KotlinVersion.KOTLIN_1_7)
apiVersion.set(KotlinVersion.KOTLIN_1_7)
if (JavaVersion.current().isJava9Compatible && project.name != "android") {
freeCompilerArgs.add("-Xjdk-release=1.8")
}
}
}
tasks.withType<JavaCompile> {
val defaultArgs = listOf("-Xdoclint:none", "-Xlint:none", "-nowarn")
if (JavaVersion.current().isJava9Compatible) {
doFirst {
options.compilerArgs = listOf("--release", "8") + defaultArgs
}
} else {
options.compilerArgs = defaultArgs
}
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
targetCompatibility = JavaVersion.VERSION_1_8.toString()
options.encoding = Charsets.UTF_8.toString()
}
}