forked from GTNewHorizons/Thermos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
303 lines (268 loc) · 9.75 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
import groovy.json.JsonSlurper
import thermos.CreateChangelog
import thermos.VersionParser
buildscript {
repositories {
maven {
name 'forge'
url 'http://files.minecraftforge.net/maven/'
}
flatDir {
dirs 'libraries'
}
mavenCentral()
mavenLocal()
}
dependencies {
// classpath files('FGS.jar')
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
}
}
tasks.whenTaskAdded {
if (it.name.startsWith('publish')) it.dependsOn 'preparePublication'
}
task wrapper(type: Wrapper) {
gradleVersion = '2.8'
}
apply plugin: 'maven'
apply plugin: 'cauldron'
apply plugin: 'maven-publish'
apply plugin: 'signing'
repositories {
clear()
maven {
name 'forge'
url 'https://files.minecraftforge.net/maven/'
}
flatDir {
dirs 'libraries'
}
mavenCentral()
mavenLocal()
}
minecraft {
version = '1.7.10'
mcpVersion = '9.08'
mainClass = 'cpw.mods.fml.relauncher.ServerLaunchWrapper'
tweakClass = 'cpw.mods.fml.common.launcher.FMLTweaker'
installerVersion = "1.4"
srgExtra "PK: org/bukkit/craftbukkit org/bukkit/craftbukkit/v1_7_R4"
}
group = 'MooseCraft'
ext.buildInfoCached = null;
def buildInfo(String key) {
if (!buildInfoCached) {
buildInfoCached = [
nextBuildNumber: 'UNOFFICIAL',
version : 'NONE'
]
}
return key ? buildInfoCached[key] : buildInfoCached;
}
ext.gitInfoCached = null;
def gitInfo(String key) {
if (!gitInfoCached) {
if (file('.git').exists()) {
gitInfoCached = [
hash : ['git', 'log', "--format=%h", '-n', '1'].execute().text.trim(),
fullHash: ['git', 'log', "--format=%H", '-n', '1'].execute().text.trim(),
branch : System.getenv("CI_BUILD_REF_NAME") ?: ['git', 'symbolic-ref', '--short', 'HEAD'].execute().text.trim(),
message : ['git', 'log', "--format=%B", '-n', '1'].execute().text.trim()
]
} else {
gitInfoCached = [
hash : 'NOT_A_GIT',
fullHash: 'NOT_A_GIT',
branch : 'NOT_A_GIT',
message : 'NOT_A_GIT'
]
}
}
return key ? gitInfoCached[key] : gitInfoCached;
}
ext.mcVersion = "1.7.10"
ext.forgeVersion = VersionParser.parseForgeRevision(file('src/main/resources/fmlversion.properties'))
ext.revision = project.hasProperty('revision') ? project.getProperty('revision') : buildInfo('nextBuildNumber')
version = "${mcVersion}-${forgeVersion}.${revision}"
if (project.hasProperty('officialBuild')) println "Updated Thermos version: ${version}"
launch4j {
jreMinVersion = '1.8.0'
}
configurations {
compile.extendsFrom exported
libraries
bootstrap
}
dependencies {
bootstrap 'pw.prok:KBootstrap:0.2.+'
libraries 'pw.prok:KBootstrap:0.3.2@jar'
libraries 'pw.prok:Damask:0.1.2@jar'
libraries 'commons-cli:commons-cli:1.3@jar'
libraries 'org.slf4j:slf4j-simple:1.6.2@jar'
libraries 'org.eclipse.jetty:jetty-servlet:9.0.3.v20130506@jar'
libraries 'commons-io:commons-io:2.4@jar'
libraries 'net.sf.opencsv:opencsv:2.0@jar'
libraries 'com.beust:jcommander:1.30@jar'
libraries 'net.minecraft:launchwrapper:1.12@jar'
libraries 'org.ow2.asm:asm-all:5.0.3'
libraries 'com.typesafe.akka:akka-actor_2.11:2.3.3'
libraries 'com.typesafe:config:1.2.1'
libraries 'org.scala-lang:scala-actors-migration_2.11:1.1.0'
libraries 'org.scala-lang:scala-compiler:2.11.7'
libraries 'org.scala-lang.plugins:scala-continuations-library_2.11:1.0.2'
libraries 'org.scala-lang.plugins:scala-continuations-plugin_2.11.2:1.0.2'
libraries 'org.scala-lang:scala-library:2.11.7'
libraries 'org.scala-lang:scala-parser-combinators:2.11.0-M4'
libraries 'org.scala-lang:scala-reflect:2.11.7'
libraries 'org.scala-lang:scala-swing:2.11.0-M7'
libraries 'org.scala-lang:scala-xml:2.11.0-M4'
libraries 'net.sf.jopt-simple:jopt-simple:5.0.1'
libraries 'lzma:lzma:0.0.1'
libraries 'org.yaml:snakeyaml:1.9'
libraries 'commons-lang:commons-lang:2.6'
libraries 'org.avaje:ebean:2.7.3'
libraries 'jline:jline:2.6'
libraries 'net.md-5:SpecialSource:1.7.4'
libraries 'net.sourceforge.argo:argo:2.25'
libraries 'com.googlecode.json-simple:json-simple:1.1'
libraries 'org.xerial:sqlite-jdbc:3.7.2'
libraries 'mysql:mysql-connector-java:5.1.14'
libraries 'javax.persistence:persistence-api:1.0.2'
libraries 'net.minecraft:server:1.7.10'
//compile name: 'server-1.7.10'
libraries 'pw.prok:KImagine:0.2.0@jar'
//compile name: 'KImagine-0.2.0'
libraries 'org.apache.httpcomponents:httpclient:4.4.1'
libraries 'net.openhft:affinity:3.0.1'
libraries 'org.fusesource.jansi:jansi:1.11'
libraries 'com.koloboke:koloboke-impl-jdk8:1.0.0'
libraries 'java3d:vecmath:1.3.1'
}
packageUniversal {
from { configurations.exported.collect { it.isDirectory() ? it : zipTree(it) } }
}
def String repeat(String string, int times) {
StringBuilder builder = new StringBuilder(string.length() * times)
times.times { builder.append(string) }
builder as String
}
def generateClasspath() {
def classpath = ''
configurations.libraries.resolvedConfiguration.resolvedArtifacts.collect { it.moduleVersion.id }.each {
def jar = "${it.group.replace('.', '/')}/${it.name}/${it.version}/${it.name}-${it.version}.jar"
classpath += " ${'libraries/'}${jar}"
}
return classpath.trim()
}
def generateManifest() {
[
'Thermos-Git-Branch' : gitInfo('branch'),
'Thermos-Git-Hash' : gitInfo('fullHash'),
'Thermos-Group' : project.group,
'Thermos-Channel' : project.name,
'Thermos-Version' : project.version,
'Implementation-Vendor' : 'jefgen',
'Implementation-Title' : project.name,
'Implementation-Version': project.version,
'Specification-Vendor' : 'Bukkit Team',
'Specification-Title' : 'Bukkit',
'Specification-Version' : '1.7.10-R0.1-SNAPSHOT',
'Forge-Version' : VersionParser.parseForgeVersion(file('forge/src/main/java/net/minecraftforge/common/ForgeVersion.java'), file('src/main/resources/fmlversion.properties')),
'TweakClass' : 'cpw.mods.fml.common.launcher.FMLTweaker',
'Main-Class' : 'cpw.mods.fml.relauncher.ServerLaunchWrapper',
'Class-Path' : generateClasspath()
]
}
tasks.packageUniversal {
classifier = 'server'
setManifest {}
manifest.attributes(generateManifest())
}
task jar(type: Jar, dependsOn: packageUniversal) {
destinationDir file("${buildDir}/distributions")
from zipTree(tasks.packageUniversal.archivePath)
manifest.attributes(generateManifest())
}
tasks.createChangelog.onlyIf { false }
tasks.packageInstaller.onlyIf { false }
task packageChangelog(type: CreateChangelog) {
onlyIf { project.hasProperty('officialBuild') }
classifier = 'changelog'
extension = 'txt'
oldChangelogUrl = "https://thermos.mcimaginarium.co.uk/changelog.txt"
hash = gitInfo('hash')
message = gitInfo('message')
version = project.version
}
task bundleStub(type: Jar) {
classifier = 'stub'
manifest.attributes([
'Main-Class': 'cpw.mods.fml.relauncher.ServerLaunchWrapper',
'Class-Path': "bin/${project.group.replace('.', '/')}/${project.name}/${project.version}/${project.name}-${project.version}.jar"
])
}
task packageBundle(type: Zip) {
classifier = 'bundle'
from fileTree("libraries")
from bundleStub
rename bundleStub.archiveName, 'Thermos.jar'
}
task signJars(type: Sign, dependsOn: [packageUniversal, packageChangelog, packageBundle, jar, 'generatePomFileForMavenPublication']) {
sign packageUniversal
sign packageChangelog
sign packageBundle
sign jar
}
task signPom(type: Sign, dependsOn: 'generatePomFileForMavenPublication') {
outputs.upToDateWhen { false }
sign file("${buildDir}/publications/maven/pom-default.xml")
}
task preparePublication(dependsOn: [signJars, signPom]) {}
def getPomSignature = {
return project.tasks.signPom.signatureFiles.collect { it }[0]
}
def getSignatureFiles = {
def allFiles = project.tasks.signJars.signatureFiles.collect { it }
def signedServer = allFiles.find { it.name.contains('-server') }
def signedChangelog = allFiles.find { it.name.contains('-changelog') }
def signedBundle = allFiles.find { it.name.contains('-bundle') }
def signedJar = (allFiles - [signedServer, signedChangelog, signedBundle])[0]
return [
[archive: signedServer, classifier: 'server', extension: 'jar.asc'],
[archive: signedChangelog, classifier: 'changelog', extension: 'txt.asc'],
[archive: signedBundle, classifier: 'bundle', extension: 'zip.asc'],
[archive: signedJar, classifier: null, extension: 'jar.asc']
]
}
publishing {
}
tasks.generateProjectCauldron << {
def file = new File('eclipse/cauldron/build.gradle')
file.append('''
repositories {
clear()
maven {
name 'forge'
url 'http://files.minecraftforge.net/maven/'
}
flatDir {
dirs '../../libraries'
}
mavenCentral()
mavenLocal()
}
dependencies {
''')
configurations.libraries.resolvedConfiguration.resolvedArtifacts.collect { it.moduleVersion.id }.each { module ->
if (['net.minecraft:server:', 'org.ow2.asm:asm-all'].findAll { (module as String).startsWith it }.size() > 0) {
return
}
file.append(" compile '${module}'\n")
}
file.append('}')
}
task resolveAllDependencies {
doLast {
configurations.each { it.resolve() }
}
}