This repository has been archived by the owner on Dec 4, 2021. It is now read-only.
forked from NucleusPowered/Nucleus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
357 lines (299 loc) · 10.3 KB
/
build.gradle
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
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
buildscript {
repositories {
jcenter()
maven {
name 'Sponge maven repo'
url 'https://repo.spongepowered.org/maven'
}
}
dependencies {
classpath 'org.spongepowered:spongegradle:0.8.2-SNAPSHOT'
}
}
plugins {
id 'idea'
id 'eclipse'
id 'com.github.hierynomus.license' version '0.12.1'
id 'ninja.miserable.blossom' version '1.0.1'
// id 'maven'
id 'com.github.johnrengelman.shadow' version '1.2.3'
id 'java'
// id 'org.spongepowered.plugin' version '0.8.2-SNAPSHOT'
}
allprojects {
task gitHash {
def process = 'git rev-parse --short HEAD'.execute()
process.waitFor()
ext.hash = process.exitValue() ? 'unknown' : process.text.trim().replace('\n', '')
}
task gitCommitMessage(type: Exec) {
commandLine 'git', 'log', '-1', '--format=%B'
standardOutput = new ByteArrayOutputStream()
ext.message = {
standardOutput.toString().replaceAll('[\\r?\\n]+$', '')
}
}
apply plugin: 'java'
}
project.ext.versionno = '1.4.4'
project.ext.minecraftversion = '1.12.2'
project.ext.spongeapiversion = '7.0'
project.ext.suffix = '-SNAPSHOT'
project.ext.hash = ''
String docVer
boolean isSnapshot
boolean isPR
boolean isMajor
if (project.properties.containsKey('override-doc-ver')) {
docVer = project.properties.get('override-doc-ver')
isSnapshot = false
} else {
docVer = project.ext.versionno + "-S" + project.ext.spongeapiversion
isSnapshot = project.ext.suffix.endsWith('SNAPSHOT')
isPR = project.ext.suffix.contains('PR')
isMajor = project.ext.versionno.endsWith('.0')
}
// Add Git hash for unique version numbers, but only for non-snapshot versions
if (project.ext.suffix != '') {
project.ext.hash = '-' + gitHash.hash
}
rootProject.version = project.versionno + project.suffix + '-S' + project.spongeapiversion
project.ext.fileVersion = project.versionno + project.suffix + project.ext.hash + '-S' + project.spongeapiversion
project(":nucleus-api") {
repositories {
jcenter()
maven {
name 'Sponge maven repo'
url 'https://repo.spongepowered.org/maven'
}
}
version = rootProject.versionno + rootProject.suffix + '-S' + rootProject.spongeapiversion
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
archiveName = "Nucleus-${version}-api-javadocs.jar"
}
}
if (!project.hasProperty("nosign")) {
apply plugin: 'signing'
apply plugin: 'org.spongepowered.plugin'
apply plugin: 'org.spongepowered.ore'
}
description = 'The Ultimate Essentials Plugin.'
ext.url = 'http://nucleuspowered.org'
group 'io.github.nucleuspowered'
ext.spongeapi = '7.1.0-SNAPSHOT'
def qsmlDep = "uk.co.drnaylor:quickstart-moduleloader:0.10.1"
def geoIpDep = 'com.maxmind.geoip2:geoip2:2.10.0'
def neutrinoDep = 'io.github.nucleuspowered:neutrino:1.1.3'
defaultTasks 'licenseFormat build'
repositories {
jcenter()
maven {
name 'Sponge maven repo'
url 'http://repo.spongepowered.org/maven'
}
maven {
name 'drnaylor-minecraft'
url 'http://repo.drnaylor.co.uk/artifactory/list/minecraft'
}
maven {
name 'drnaylor'
url 'http://repo.drnaylor.co.uk/artifactory/list/quickstart'
}
maven {
url 'https://jitpack.io'
}
}
dependencies {
compile project(":nucleus-ap")
compile project(":nucleus-api", {
ext.versionno = versionno
ext.suffix = suffix
})
compile "org.spongepowered:spongeapi:" + project.ext.spongeapi
compile qsmlDep
compile neutrinoDep
// For Geo IP
compile geoIpDep
testCompile "junit:junit:4.12"
testCompile "org.mockito:mockito-all:1.10.19"
testCompile "org.powermock:powermock-module-junit4:1.6.4"
testCompile "org.powermock:powermock-api-mockito:1.6.4"
testCompile "org.hamcrest:hamcrest-junit:2.0.0.0"
}
license {
ext.name = project.name
exclude "**/*.info"
exclude "assets/**"
exclude "*.properties"
exclude "*.txt"
header file('HEADER.txt')
sourceSets = project.sourceSets
ignoreFailures false
strictCheck true
mapping {
java = 'SLASHSTAR_STYLE'
}
}
def getVersion = {
rootProject.version
}
blossom {
replaceTokenIn('src/main/java/io/github/nucleuspowered/nucleus/PluginInfo.java')
replaceToken '@name@', project.name
replaceToken '@version@', getVersion
replaceToken '@description@', project.description
replaceToken '@url@', project.url
replaceToken '@gitHash@', gitHash.hash
}
jar {
manifest {
attributes 'Implementation-Title': project.name,
'SpongeAPI-Version': project.spongeapi,
'Implementation-Version': getVersion(),
'Git-Hash': gitHash.hash
}
archiveName = getVersion
}
shadowJar {
dependencies {
include(project(":nucleus-api"))
include(dependency(qsmlDep))
include(dependency(geoIpDep))
include(dependency(neutrinoDep))
include(dependency("com.maxmind.db:maxmind-db"))
include(dependency("com.fasterxml.jackson.core:jackson-core"))
include(dependency("com.fasterxml.jackson.core:jackson-databind"))
include(dependency("com.fasterxml.jackson.core:jackson-annotations"))
}
relocate 'com.maxmind.geoip2', 'io.github.nucleuspowered.relocate.com.maxmind.geoip2'
relocate 'com.maxmind.db', 'io.github.nucleuspowered.relocate.com.maxmind.db'
relocate 'com.fasterxml.jackson', 'io.github.nucleuspowered.relocate.com.fasterxml.jackson'
if (!project.hasProperty('norelocate')) {
relocate 'uk.co.drnaylor', 'io.github.nucleuspowered.relocate.uk.co.drnaylor'
relocate 'io.github.nucleuspowered.neutrino', 'io.github.nucleuspowered.relocate.nucleus.neutrino'
relocate 'io.github.lukehutch', 'io.github.nucleuspowered.relocate.io.github.lukehutch'
}
exclude "io/github/nucleuspowered/nucleus/api/NucleusAPIMod.class"
archiveName = "Nucleus-${rootProject.version}-MC${project.ext.minecraftversion}-plugin.jar"
//shadowJar.archiveName = shadowName
// archiveName = "Nucleus-${version}-MC${project.ext.minecraftversion}-plugin.jar"
}
shadowJar.dependsOn(':nucleus-api:build')
task cleanJars() {
project.file('output').listFiles().each {
x -> if (x.name.endsWith("jar") || x.name.endsWith("asc") || x.name.endsWith("md")) { x.delete() }
}
}
task copyJars(type: Copy, dependsOn: ':nucleus-api:build') {
from([project(":nucleus-api").jar, project(":nucleus-api").javadocJar, shadowJar])
into project.file('output')
}
artifacts {
archives shadowJar
shadow shadowJar
}
// Release notes
task relnotes {
doLast {
String complete
if (isSnapshot) {
// read the snapshot.md file
String contents = new File('changelogs/templates/snapshot.md').getText("UTF-8")
complete = contents
.replace('{{hash}}', gitHash.hash)
.replace('{{message}}', gitCommitMessage.message())
.replace('{{sponge}}', project.ext.spongeapiversion)
} else {
String contents
if (isPR) {
contents = new File('changelogs/templates/release-pr.md').getText("UTF-8")
} else if (isMajor) {
contents = new File('changelogs/templates/release-big.md').getText("UTF-8")
} else {
contents = new File('changelogs/templates/release.md').getText("UTF-8")
}
String notes = new File('changelogs/templates/' + docVer + ".md").getText("UTF-8")
complete = contents
.replace('{{hash}}', gitHash.hash)
.replace('{{info}}', notes)
.replace('{{sponge}}', project.ext.spongeapiversion)
}
ext.notes = complete
}
}
task printRelNotes(dependsOn: relnotes) {
doLast {
println(relnotes.notes)
}
}
task writeRelNotes(dependsOn: relnotes) {
doLast {
new File("$projectDir/changelogs/${version}.md").text = relnotes.notes
}
}
task writeRelNotesInOutput(dependsOn: relnotes) {
doLast {
new File("$projectDir/output/${version}.md").text = relnotes.notes
}
}
// SIGNING & ORE DEPLOY
if (!project.hasProperty("nosign")) {
signing {
required {
project.properties.hasProperty("signing.keyId")
}
if (project.properties.containsKey('gpg2')) {
useGpgCmd() // requires gpg2
}
// sign configurations.archives
// we want to add the signatures to this configuration too, as this
// is what we use to upload to Ore
configuration=configurations.shadow
sign configurations.shadow
}
task signArchives(dependsOn: 'signShadow') {
// dummy task to make the ore deploy plugin work
}
task copyAsc(type: Copy, dependsOn: 'signArchives') {
from([signShadow.getSignatureFiles()])
into project.file('output')
}
task buildAndSign {
dependsOn 'build'
dependsOn 'signArchives'
dependsOn 'signShadow'
dependsOn 'copyAsc'
}
signArchives.dependsOn(shadowJar)
copyAsc.dependsOn(signArchives)
signShadow.dependsOn(shadowJar).mustRunAfter(shadowJar)
copyAsc.dependsOn(signShadow)
oreDeploy.dependsOn(buildAndSign)
oreDeploy.setRecommended(project.properties.containsKey("oreDeploy.recommended"))
if (project.properties.containsKey("oreDeploy.channel")) {
oreDeploy.setChannel(project.properties.get("oreDeploy.channel").toString())
} else if (project.properties.containsKey("oreDeploy.select")) {
if (isPR) {
oreDeploy.setChannel("prerelease")
} else if (isSnapshot) {
oreDeploy.setChannel("testing")
} else {
oreDeploy.setChannel("Release")
oreDeploy.setRecommended(true)
}
} else {
oreDeploy.setChannel("testing")
}
oreDeploy.setDeploy(project.configurations.shadow) // yet another hack
}
blossomSourceReplacementJava.dependsOn(gitHash)
jar.dependsOn(gitHash)
relnotes.dependsOn([gitHash, gitCommitMessage])
compileJava.dependsOn(":nucleus-ap:build")
clean.dependsOn(cleanJars)
copyJars.mustRunAfter(cleanJars)
build.dependsOn(shadowJar)
build.dependsOn(copyJars)
build.dependsOn(writeRelNotesInOutput)