forked from gurkenlabs/litiengine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
231 lines (209 loc) · 6.73 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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
import com.github.vlsi.gradle.crlf.CrLfSpec
import com.github.vlsi.gradle.crlf.LineEndings
import com.github.vlsi.gradle.properties.dsl.props
import com.github.vlsi.gradle.properties.dsl.stringProperty
import com.github.vlsi.gradle.properties.dsl.toBool
import com.github.vlsi.gradle.publishing.dsl.simplifyXml
import com.github.vlsi.gradle.publishing.dsl.versionFromResolution
plugins {
id("com.github.vlsi.crlf")
id("com.github.vlsi.gradle-extensions")
id("com.diffplug.spotless")
id("com.github.vlsi.stage-vote-release")
}
val skipSpotless by props(false)
val skipJavadoc by props()
val enableMavenLocal by props(false)
val enableGradleMetadata by props()
val isRelease = project.stringProperty("release").toBool()
val String.v: String get() = rootProject.extra["$this.version"] as String
val projectVersion = "litiengine".v
releaseParams {
tlp.set("litiengine")
organizationName.set("gurkenlabs")
componentName.set("litiengine")
prefixForProperties.set("gh")
svnDistEnabled.set(false)
sitePreviewEnabled.set(false)
release.set(isRelease)
if (!isRelease) {
rcTag.set("v$projectVersion$snapshotSuffix")
}
nexus {
mavenCentral()
}
voteText.set {
"""
${it.componentName} v${it.version}-rc${it.rc} is ready for preview.
Git SHA: ${it.gitSha}
Staging repository: ${it.nexusRepositoryUri}
""".trimIndent()
}
}
tasks.closeRepository.configure { enabled = isRelease }
val buildVersion = "$projectVersion${releaseParams.snapshotSuffix}"
allprojects {
group = "de.gurkenlabs"
version = buildVersion
repositories {
if (enableMavenLocal) {
mavenLocal()
}
if (!isRelease) {
maven { url = uri("https://oss.sonatype.org/content/repositories/snapshots/") }
}
maven { url = uri("https://plugins.gradle.org/m2/") }
mavenCentral()
gradlePluginPortal()
}
configurations.all {
resolutionStrategy.cacheChangingModulesFor(0, "seconds")
}
if (!skipSpotless) {
apply(plugin = "com.diffplug.spotless")
spotless {
plugins.withType<JavaPlugin>().configureEach {
java {
removeUnusedImports()
eclipse().configFile("${project.rootDir}/config/gurkenlabs.eclipseformat.xml")
}
}
}
}
tasks.withType<AbstractArchiveTask>().configureEach {
// Ensure builds are reproducible
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
dirMode = "775".toInt(8)
fileMode = "664".toInt(8)
}
if (!enableGradleMetadata) {
tasks.withType<GenerateModuleMetadata> {
enabled = false
}
}
plugins.withType<JavaPlugin> {
apply<IdeaPlugin>()
apply<EclipsePlugin>()
configure<JavaPluginExtension> {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
withSourcesJar()
if (!skipJavadoc && isRelease) {
withJavadocJar()
}
}
tasks {
withType<JavaCompile>().configureEach {
options.encoding = "UTF-8"
}
withType<Jar>().configureEach {
manifest {
attributes["Bundle-License"] = "MIT"
attributes["Implementation-Title"] = project.name
attributes["Implementation-Version"] = project.version
attributes["Specification-Vendor"] = "Gurkenlabs"
attributes["Specification-Version"] = project.version
attributes["Specification-Title"] = "LITIENGINE"
attributes["Implementation-Vendor"] = "Gurkenlabs"
attributes["Implementation-Vendor-Id"] = project.group
}
CrLfSpec(LineEndings.LF).run {
into("META-INF") {
filteringCharset = "UTF-8"
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
// This includes either project-specific license or a default one
if (file("$projectDir/LICENSE").exists()) {
textFrom("$projectDir/LICENSE")
} else {
textFrom("$rootDir/LICENSE")
}
}
}
}
withType<Javadoc>().configureEach {
(options as StandardJavadocDocletOptions).apply {
quiet()
locale = "en"
docEncoding = "UTF-8"
charSet = "UTF-8"
encoding = "UTF-8"
docTitle = "${project.name.capitalize()} API"
windowTitle = "${project.name.capitalize()} API"
header = "<b>${project.name.capitalize()}</b>"
addBooleanOption("Xdoclint:none", true)
addBooleanOption("html5", true)
links("https://docs.oracle.com/en/java/javase/17/docs/api/")
}
}
}
}
plugins.withType<MavenPublishPlugin>().configureEach {
configure<PublishingExtension> {
if (project.path == ":") {
// Skip the root project
return@configure
}
val useInMemoryKey by props()
if (useInMemoryKey) {
apply(plugin = "signing")
configure<SigningExtension> {
useInMemoryPgpKeys(
project.stringProperty("signing.inMemoryKey"),
project.stringProperty("signing.password")
)
}
}
publications {
withType<MavenPublication> {
// Use the resolved versions in pom.xml
// Gradle might have different resolution rules, so we set the versions
// that were used in Gradle build/test.
versionFromResolution()
pom {
simplifyXml()
description.set(project.description!!)
name.set(
(project.findProperty("artifact.name") as? String)
?: project.name.capitalize().replace("-", " ")
)
url.set("https://litiengine.com")
organization {
name.set("Gurkenlabs")
url.set("https://gurkenlabs.de/")
}
issueManagement {
system.set("GitHub")
url.set("https://github.com/gurkenlabs/litiengine/issues")
}
licenses {
license {
name.set("MIT")
url.set("https://github.com/gurkenlabs/litiengine/blob/master/LICENSE")
distribution.set("repo")
}
}
scm {
url.set("'https://github.com/gurkenlabs/litiengine/")
connection.set("scm:git:git://github.com/gurkenlabs/litiengine.git")
developerConnection.set("scm:git:[email protected]:gurkenlabs/litiengine.git")
}
developers {
developer {
id.set("steffen")
name.set("Steffen Wilke")
email.set("[email protected]")
}
developer {
id.set("matthias")
name.set("Matthias Wilke")
email.set("[email protected]")
}
}
}
}
}
}
}
}