forked from gurkenlabs/litiengine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
191 lines (173 loc) · 7.01 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
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")
}
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 buildVersion = "litiengine".v + if (isRelease) "" else "-SNAPSHOT"
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")
}
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(16))
}
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/javase/9/docs/api/")
}
}
}
}
extensions.findByType(PublishingExtension::class)?.apply {
if (project.path == ":") {
// Skip the root project
return@apply
}
configure<SigningExtension> {
sign(publications.findByName("mavenJava"))
}
repositories {
maven {
val releasesRepoUrl = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
val snapshotRepoUrl = uri("https://oss.sonatype.org/content/repositories/snapshots/")
url = if (isRelease) releasesRepoUrl else snapshotRepoUrl
credentials {
username = project.stringProperty("ossrhUsername") ?: ""
password = project.stringProperty("ossrhPassword") ?: ""
}
}
}
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]")
}
}
}
}
}
}
}