forked from NickImpact/GTS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
338 lines (289 loc) · 10.9 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
import com.google.common.collect.Lists
import net.impactdev.gts.gradle.enums.ReleaseLevel
import net.impactdev.gts.gradle.tasks.PostToDiscord
import net.impactdev.gts.gradle.tasks.ReleaseNotesTask
import net.impactdev.gts.gradle.tasks.UploadToOre
import java.nio.charset.StandardCharsets
import java.nio.file.Files
import java.nio.file.Paths
buildscript {
repositories {
mavenCentral()
maven {
url "https://repository.jboss.org/nexus/content/groups/public/"
}
maven {
name = "forge"
url = "https://files.minecraftforge.net/maven"
}
}
dependencies {
classpath 'com.google.guava:guava:27.1-jre'
classpath 'org.hibernate.build.gradle:gradle-maven-publish-auth:2.0.1'
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '4.1.+', changing: true
}
}
plugins {
id 'java'
id 'com.github.johnrengelman.shadow' version '5.2.0'
id 'net.kyori.blossom' version '1.1.0'
}
allprojects {
group = 'net.impactdev.gts'
version = "6.1.9-SNAPSHOT"
}
sourceCompatibility = targetCompatibility = "1.8" // Need this here so eclipse task generates correctly.
compileJava {
sourceCompatibility = targetCompatibility = "1.8"
}
allprojects {
task gitHash {
def process = 'git rev-parse HEAD'.execute()
process.waitFor()
ext.commit = process.exitValue() ? 'Unknown' : process.text.trim().replace('\n', '')
}
task gitMessage {
def process = 'git log -1 --format=%B'.execute()
process.waitFor()
ext.message = process.exitValue() ? 'Unknown' : process.text.trim()
}
ext {
sponge = "7.3.0"
run = ""
if(System.getenv().containsKey("BUILD_NUMBER")) {
run = "-${System.getenv("BUILD_NUMBER")}"
}
}
}
subprojects {
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'com.github.johnrengelman.shadow'
apply plugin: 'net.kyori.blossom'
apply plugin: 'net.minecraftforge.gradle'
minecraft {
// The mappings can be changed at any time, and must be in the following format.
// snapshot_YYYYMMDD Snapshot are built nightly.
// stable_# Stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not always work.
// Simply re-run your setup task after changing the mappings to update your workspace.
mappings channel: "stable", version: "39-1.12"
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
version = "${project.version}${project.ext.run}"
repositories {
mavenCentral()
maven { url = 'https://jitpack.io' }
maven {
name = "Impact-Dev"
url = "https://maven.impactdev.net/repository/development/"
}
maven {
name = 'sonatype-oss'
url = 'https://oss.sonatype.org/content/repositories/snapshots/'
}
}
jar {
exclude 'Impactor*.jar'
}
shadowJar {
dependencies {
include project(':')
}
}
dependencies {
minecraft "net.minecraftforge:forge:1.12.2-14.23.5.2855"
shadow "net.impactdev.impactor:api:3.1.2"
shadow 'com.google.guava:guava:27.1-jre'
shadow 'com.google.code.gson:gson:2.8.6'
shadow 'com.github.ben-manes.caffeine:caffeine:2.8.2'
shadow group: 'org.mariuszgromada.math', name: 'MathParser.org-mXparser', version: '4.4.2'
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile 'com.google.guava:guava:27.1-jre'
testCompile group: 'org.mariuszgromada.math', name: 'MathParser.org-mXparser', version: '4.4.2'
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
dependsOn shadowJar
}
artifacts {
archives javadocJar
}
}
task genChangelog(type: ReleaseNotesTask) {
dependsOn(gitHash)
dependsOn(gitMessage)
version = project.version
hash = gitHash.ext.commit
sponge = project.ext.sponge
message = gitMessage.ext.message
level = ReleaseLevel.get(version)
}
task copyJars(type: Copy) {
dependsOn subprojects.build
from subprojects.collect { it.tasks.withType(Jar) }
into "$buildDir/allJars"
exclude '*-all.jar'
exclude '*-sources.jar'
exclude 'api*.jar'
exclude 'common*.jar'
exclude 'spigot*.jar'
exclude 'sponge*.jar'
exclude 'plugin*.jar'
exclude 'reforged*.jar'
exclude 'gens*.jar'
exclude 'generations*.jar'
exclude 'bungee*.jar'
exclude 'pixelmon*.jar'
exclude 'velocity*.jar'
}
task writeChangelogToFile {
dependsOn(genChangelog)
dependsOn(copyJars)
doLast {
java.nio.file.Path path = project.projectDir.toPath().resolve("$buildDir").resolve("allJars").resolve("${project.version}.md")
if(!Files.exists(path)) {
Files.createDirectories(path.getParent())
Files.createFile(path)
}
Files.write(path, genChangelog.result.getBytes(StandardCharsets.UTF_8))
if(!Files.exists(path)) {
throw new GradleException("File not written correctly: " + path)
} else {
System.out.println("File written to path: " + path)
// File written to path: /home/runner/work/GTS/GTS/build/allJars/6.1.8.md
}
}
}
task publishToOre(type: UploadToOre) {
dependsOn(genChangelog)
dependsOn(copyJars)
notes = { genChangelog.result } as Provider<String>
level = genChangelog.level
file = new File(this.getProjectDir(), Paths.get("build", "allJars", "GTS-Sponge-${project.version}.jar").toString())
pluginID = "gts"
apiKey = project.properties['ore_api_key']?.toString() ?: System.getenv("ORE_API_KEY")
}
task sendToDiscordPlugins(type: PostToDiscord) {
dependsOn(copyJars)
webhookID = project.properties['discord_webhook_id_plugin']?.toString() ?: System.getenv("DISCORD_WEBHOOK_ID_PLUGIN")
webhookToken = project.properties['discord_webhook_token_plugin']?.toString() ?: System.getenv("DISCORD_WEBHOOK_TOKEN_PLUGIN")
memberRole = project.properties['discord_member_id']?.toString() ?: System.getenv("DISCORD_WEBHOOK_MEMBER_ROLE")
content = "GTS {{content:version}} is now available!"
version = project.version
level = ReleaseLevel.get(version)
files = Lists.newArrayList(
new File(this.getProjectDir(), Paths.get("build", "allJars", "GTS-Sponge-${project.version}.jar").toString()),
new File(this.getProjectDir(), Paths.get("build", "allJars", "GTS-Bungee-${project.version}.jar").toString()),
new File(this.getProjectDir(), Paths.get("build", "allJars", "GTS-Velocity-${project.version}.jar").toString())
)
force = true
}
task sendToDiscordReforgedExtension(type: PostToDiscord) {
dependsOn(copyJars)
webhookID = project.properties['discord_webhook_id_reforged']?.toString() ?: System.getenv("DISCORD_WEBHOOK_ID_REFORGED")
webhookToken = project.properties['discord_webhook_token_reforged']?.toString() ?: System.getenv("DISCORD_WEBHOOK_TOKEN_REFORGED")
memberRole = project.properties['discord_member_id']?.toString() ?: System.getenv("DISCORD_WEBHOOK_MEMBER_ROLE")
content = "GTS Extension {{content:version}} for Reforged is now available!"
version = project.version
level = ReleaseLevel.get(version)
files = Lists.newArrayList(
new File(this.getProjectDir(), Paths.get("build", "allJars", "GTS-Extension-Reforged-${project.version}.jar").toString())
)
force = true
}
task sendToDiscordGenerationsExtension(type: PostToDiscord) {
dependsOn(copyJars)
webhookID = project.properties['discord_webhook_id_generations']?.toString() ?: System.getenv("DISCORD_WEBHOOK_ID_GENERATIONS")
webhookToken = project.properties['discord_webhook_token_generations']?.toString() ?: System.getenv("DISCORD_WEBHOOK_TOKEN_GENERATIONS")
memberRole = project.properties['discord_member_id']?.toString() ?: System.getenv("DISCORD_WEBHOOK_MEMBER_ROLE")
content = "GTS Extension {{content:version}} for Generations is now available!"
version = project.version
level = ReleaseLevel.get(version)
files = Lists.newArrayList(
new File(this.getProjectDir(), Paths.get("build", "allJars", "GTS-Extension-Generations-${project.version}.jar").toString())
)
force = true
}
task publishToDiscord {
dependsOn(sendToDiscordPlugins)
dependsOn(sendToDiscordReforgedExtension)
dependsOn(sendToDiscordGenerationsExtension)
}
apply plugin: 'maven-publish'
apply plugin: 'maven-publish-auth'
publishing {
repositories {
maven {
name = "ImpactDev-Public"
url = "https://maven.impactdev.net/repository/development/"
credentials {
username System.getenv('NEXUS_USER')
password System.getenv('NEXUS_PW')
}
}
}
publications {
api(MavenPublication) {
def project = project(':api')
from project.components.java
groupId project.group
artifactId "api"
version project.version
}
common(MavenPublication) {
def project = project(':common')
from project.components.java
groupId project.group
artifactId "common"
version project.version
}
bungee(MavenPublication) {
def project = project(':bungee')
from project.components.java
groupId project.group
artifactId "bungee"
version project.version
}
velocity(MavenPublication) {
def project = project(':velocity')
from project.components.java
groupId project.group
artifactId "velocity"
version project.version
}
sponge(MavenPublication) {
def project = project(':sponge')
from project.components.java
groupId project.group
artifactId "sponge-common"
version project.version
}
plugin(MavenPublication) {
def project = project(':plugin')
from project.components.java
groupId project.group
artifactId "plugin-sponge"
version project.version
}
reforged(MavenPublication) {
def project = project(':pixelmon:reforged')
from project.components.java
groupId project.group
artifactId "reforged-sponge"
version project.version
}
// generations(MavenPublication) {
// def project = project(':pixelmon:generations')
// from project.components.java
// groupId project.group
// artifactId "generations-sponge"
// version project.version
// }
}
}
build.dependsOn shadowJar
build.dependsOn writeChangelogToFile