-
Notifications
You must be signed in to change notification settings - Fork 9
/
build.gradle.kts
80 lines (69 loc) · 2.19 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
import com.palantir.gradle.gitversion.VersionDetails
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import groovy.lang.Closure
import org.gradle.jvm.toolchain.internal.CurrentJvmToolchainSpec
plugins {
kotlin("jvm") version "1.9.22"
id("com.github.johnrengelman.shadow") version "7.1.0"
id("com.palantir.git-version") version "0.12.3"
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
id("com.diffplug.spotless") version "5.17.1"
}
val versionDetails: Closure<VersionDetails> by extra
allprojects {
if (name !in setOf("minimized", "semanticdb-kotlin")) {
apply(plugin = "com.diffplug.spotless")
spotless {
kotlin {
ktfmt().dropboxStyle()
}
}
}
group = "com.sourcegraph"
version = (project.properties["version"] as String).let {
if (it != "unspecified" && !it.startsWith("refs"))
return@let it.removePrefix("v")
val lastTag = versionDetails().lastTag
val tag =
if (lastTag.startsWith("v")) lastTag.removePrefix("v")
else "0.0.0"
val lastNum = tag.split(".").last().toInt() + 1
"${tag.split(".").subList(0, 2).joinToString(".")}.$lastNum-SNAPSHOT"
}
}
repositories {
mavenCentral()
}
nexusPublishing {
repositories {
sonatype {
username.set(System.getenv("SONATYPE_USERNAME"))
password.set(System.getenv("SONATYPE_PASSWORD"))
}
}
}
subprojects {
tasks.withType<PublishToMavenRepository> {
doFirst {
println("Publishing ${publication.groupId}:${publication.artifactId}:${publication.version} to ${repository.url}")
}
if (!(version as String).endsWith("SNAPSHOT")) {
finalizedBy(rootProject.tasks.closeAndReleaseStagingRepository)
}
}
}
allprojects {
afterEvaluate {
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
kotlin {
jvmToolchain {
(this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(8))
}
}
tasks.withType<JavaCompile> {
sourceCompatibility = "1.8"
}
}
}