-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.gradle.kts
171 lines (149 loc) · 4.69 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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
import java.nio.charset.StandardCharsets
import java.util.*
@Suppress("DSL_SCOPE_VIOLATION")
plugins {
`java-library`
`maven-publish`
alias(libs.plugins.pkl)
alias(libs.plugins.nexusPublish)
alias(libs.plugins.spotless)
signing
}
private val isReleaseBuild = System.getProperty("releaseBuild") != null
version = if (isReleaseBuild) version else "$version-SNAPSHOT"
val originalRemoteName = System.getenv("PKL_ORIGINAL_REMOTE_NAME") ?: "origin"
spotless {
ratchetFrom = "$originalRemoteName/main"
format("pkl") {
target("*.pkl")
licenseHeaderFile(rootProject.file("buildSrc/src/main/resources/license-header.line-comment.txt"), "/// ")
}
java {
googleJavaFormat(libs.versions.googleJavaFormat.get())
target("src/*/java/**/*.java")
target("samples/*/src/*/java/**/*.java")
licenseHeaderFile(rootProject.file("buildSrc/src/main/resources/license-header.star-block.txt"))
}
kotlin {
ktfmt(libs.versions.ktfmt.get()).googleStyle()
target("samples/*/src/*/kotlin/**/*.kt")
licenseHeaderFile(rootProject.file("buildSrc/src/main/resources/license-header.star-block.txt"))
}
}
nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
}
}
}
java {
sourceCompatibility = JavaVersion.VERSION_17
}
dependencies {
compileOnly(libs.springBoot)
// `api` instead of `implementation`
// so that users of pkl-spring don't need to add pkl-config-java-all
// to be able to compile their generated config classes
api(libs.pklConfigJavaAll)
testImplementation(libs.springTest)
testImplementation(libs.springBoot)
testImplementation(libs.springBootTest)
testImplementation(libs.springBootAutoConfigure)
testImplementation(libs.junitApi)
testImplementation(libs.assertJ)
testRuntimeOnly(libs.junitEngine)
}
pkl {
javaCodeGenerators {
register("configClasses") {
generateGetters.set(true)
generateSpringBootConfig.set(true)
sourceSet.set(sourceSets.test.get())
sourceModules.set(files("src/test/resources/application.pkl"))
}
}
}
tasks.compileTestJava {
// required by Boot 3.x (usually handled by Boot's Gradle plugin)
options.compilerArgs = options.compilerArgs + "-parameters"
}
tasks.jar {
manifest {
attributes("Automatic-Module-Name" to "org.pkl.spring")
}
}
tasks.test {
useJUnitPlatform()
reports {
html.required.set(true)
}
}
tasks.javadoc {
classpath = sourceSets.main.get().output + sourceSets.main.get().compileClasspath
source = sourceSets.main.get().allJava
title = "${project.name} ${project.version} API"
}
val sourcesJar by tasks.registering(Jar::class) {
archiveClassifier.set("sources")
from(sourceSets.main.get().allSource)
}
val javadocJar by tasks.registering(Jar::class) {
archiveClassifier.set("javadoc")
from(tasks.javadoc)
}
publishing {
publications {
create<MavenPublication>("library") {
from(components["java"])
artifact(sourcesJar)
artifact(javadocJar)
pom {
name.set("pkl-spring")
url.set("https://github.com/apple/pkl-spring")
description.set("Spring Boot extension for configuring Boot apps with Pkl.")
licenses {
license {
name = "Apache 2.0"
url = "https://github.com/apple/pkl-spring/blob/main/LICENSE.txt"
}
}
developers {
developer {
id.set("pkl-authors")
name.set("The Pkl Authors")
email.set("pkl-oss@group.apple.com")
}
}
scm {
connection.set("scm:git:git://github.com/apple/pkl.git")
developerConnection.set("scm:git:ssh://github.com/apple/pkl.git")
url.set("https://github.com/apple/pkl/tree/${if (isReleaseBuild) version else "main"}")
}
issueManagement {
system.set("GitHub Issues")
url.set("https://github.com/apple/pkl-spring/issues")
}
ciManagement {
system.set("Circle CI")
url.set("https://app.circleci.com/pipelines/github/apple/pkl-spring")
}
}
}
}
}
val printVersion by tasks.registering {
doFirst { println(version) }
}
signing {
// provided as env vars `ORG_GRADLE_PROJECT_signingKey` and `ORG_GRADLE_PROJECT_signingPassword`
// in CI.
val signingKey = (findProperty("signingKey") as String?)
?.let { Base64.getDecoder().decode(it).toString(StandardCharsets.US_ASCII) }
val signingPassword = findProperty("signingPassword") as String?
if (signingKey != null && signingPassword != null) {
useInMemoryPgpKeys(signingKey, signingPassword)
}
sign(publishing.publications["library"])
}