-
Notifications
You must be signed in to change notification settings - Fork 8
/
build.gradle.kts
121 lines (99 loc) · 3.36 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
import com.google.cloud.tools.jib.gradle.JibExtension
import net.ltgt.gradle.errorprone.errorprone
plugins {
idea
id("com.diffplug.spotless") version "7.0.0.BETA1"
id("com.google.cloud.tools.jib") version "3.4.3" apply false
id("com.palantir.consistent-versions") version "2.23.0"
id("com.markelliot.versions") version "0.43.0"
id("io.github.gradle-nexus.publish-plugin") version "2.0.0"
id("net.ltgt.errorprone") version "4.0.1" apply false
id("org.inferred.processors") version "3.7.0" apply false
}
version = "git describe --tags".runCommand().trim() +
(if (!"git status -s".runCommand().isEmpty()) ".dirty" else "")
task("printVersion") {
doLast {
println(rootProject.version)
}
}
tasks.updateGradleWrapper {
enabled = true
}
allprojects {
group = "com.markelliot.barista"
version = rootProject.version
}
allprojects {
apply(plugin = "idea")
apply(plugin = "com.diffplug.spotless")
// lives in allprojects because of consistent-versions
repositories {
mavenCentral()
}
plugins.withType<ApplicationPlugin> {
apply(plugin = "com.google.cloud.tools.jib")
val imageName = "${project.name}:${project.version}"
configure<JibExtension> {
from {
image = "azul/zulu-openjdk:17"
}
to {
image = imageName
tags = setOf("latest")
}
}
tasks.register("docker").get().dependsOn("jibDockerBuild")
}
plugins.withType<JavaLibraryPlugin> {
apply(plugin = "net.ltgt.errorprone")
apply(plugin = "org.inferred.processors")
dependencies {
"errorprone"("com.google.errorprone:error_prone_core")
"errorprone"("com.jakewharton.nopen:nopen-checker")
"compileOnly"("com.jakewharton.nopen:nopen-annotations")
}
spotless {
java {
palantirJavaFormat()
licenseHeaderFile("${rootProject.projectDir}/.spotless/java-license-header.txt")
}
}
tasks.withType<JavaCompile> {
options.errorprone.disable("UnusedVariable")
}
tasks.withType<Javadoc> {
(options as StandardJavadocDocletOptions).addStringOption("Xdoclint:-missing")
}
the<JavaPluginExtension>().sourceCompatibility = JavaVersion.VERSION_17
tasks["check"].dependsOn("spotlessCheck")
}
spotless {
kotlinGradle {
ktlint()
}
}
tasks.register("format").get().dependsOn("spotlessApply")
}
fun booleanEnv(envVar: String): Boolean? {
return System.getenv(envVar)?.toBoolean()
}
fun String.runCommand(): String {
val proc =
ProcessBuilder(*split(" ").toTypedArray())
.redirectOutput(ProcessBuilder.Redirect.PIPE)
.redirectError(ProcessBuilder.Redirect.INHERIT)
.start()
proc.waitFor(10, TimeUnit.SECONDS)
return proc.inputStream.bufferedReader().readText()
}
nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
username.set(System.getenv("MAVEN_CENTRAL_USER"))
password.set(System.getenv("MAVEN_CENTRAL_PASSWORD"))
}
}
}