-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
129 lines (108 loc) · 3.61 KB
/
build.gradle.kts
File metadata and controls
129 lines (108 loc) · 3.61 KB
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.google.cloud.tools.jib.gradle.JibExtension
import net.ltgt.gradle.errorprone.errorprone
buildscript {
configurations.classpath {
resolutionStrategy {
// Fix https://github.com/jreleaser/jreleaser/issues/1643
force("org.eclipse.jgit:org.eclipse.jgit:5.13.5.202508271544-r")
}
}
}
plugins {
idea
id("com.diffplug.spotless") version "8.4.0"
id("com.google.cloud.tools.jib") version "3.5.3" apply false
id("com.palantir.consistent-versions") version "3.15.0"
id("net.ltgt.errorprone") version "5.1.0" apply false
id("org.jreleaser") version "1.23.0"
}
version = "git describe --tags".runCommand().trim() +
(if (!"git status -s".runCommand().isEmpty()) ".dirty" else "")
tasks.register("printVersion") {
doLast {
println(rootProject.version)
}
}
allprojects {
group = "com.markelliot.result"
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")
dependencies {
"errorprone"("com.google.errorprone:error_prone_core")
"errorprone"("com.jakewharton.nopen:nopen-checker")
"compileOnly"("com.jakewharton.nopen:nopen-annotations")
}
spotless {
java {
googleJavaFormat("1.17.0").aosp()
licenseHeaderFile("${rootProject.projectDir}/.spotless/java-license-header.txt")
}
}
tasks.withType<JavaCompile> {
options.errorprone.disable("UnusedVariable")
}
the<JavaPluginExtension>().sourceCompatibility = JavaVersion.VERSION_17
tasks["check"].dependsOn("spotlessCheck")
}
spotless {
kotlinGradle {
ktlint()
}
}
tasks.register("format").get().dependsOn("spotlessApply")
}
fun booleanEnv(envVar: String): Boolean? = 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()
}
jreleaser {
signing {
active.set(org.jreleaser.model.Active.ALWAYS)
armored.set(true)
publicKey.set(System.getenv("SIGNING_PUBLIC_KEY"))
secretKey.set(System.getenv("SIGNING_SECRET_KEY"))
passphrase.set(System.getenv("SIGNING_PASSWORD"))
}
deploy {
maven {
mavenCentral {
create("sonatype") {
active.set(org.jreleaser.model.Active.ALWAYS)
url.set("https://central.sonatype.com/api/v1/publisher")
username.set(System.getenv("SONATYPE_USERNAME"))
password.set(System.getenv("SONATYPE_PASSWORD"))
stagingRepository("build/staging-deploy")
}
}
}
}
}