This repository has been archived by the owner on Aug 12, 2022. It is now read-only.
forked from TechCatOther/ultramine_core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
332 lines (300 loc) · 11 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
import org.gradle.api.internal.artifacts.publish.ArchivePublishArtifact
import org.gradle.api.internal.file.copy.CopyAction
import org.gradle.api.internal.java.JavaLibrary
import org.ultramine.gradle.task.ReobfTask
import org.ultramine.gradle.task.SideSplitTask
import org.ultramine.gradle.task.SpeicialClassTransformTask
apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'eclipse'
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
compileJava.options.encoding = 'UTF-8'
if(compile_incremental == "true")
compileJava.options.incremental = true
ext.commit = null
ext.previousCommit = null
ext.versionFile = null
ext.revision = 0
group = project_group
version = (concat_mc_version_to=='version' ? (minecraft_version+'-') : '') + computeVersion()
repositories {
maven {
name 'forge'
url 'http://files.minecraftforge.net/maven'
}
mavenCentral()
maven {
name 'sonatypeSnapshot'
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
maven {
name 'minecraft'
url 'https://libraries.minecraft.net/'
}
}
configurations {
compileCommon
compileClient
compileServer
runtimeCommon
runtimeClient
runtimeServer
compile.extendsFrom compileCommon, compileClient, compileServer
packageClient.extendsFrom compileCommon, compileClient, runtimeCommon, runtimeClient
packageServer.extendsFrom compileCommon, compileServer, runtimeCommon, runtimeServer
packageAll.extendsFrom compileCommon, compileClient, compileServer, runtimeCommon, runtimeClient, runtimeServer
runtime.setExtendsFrom([packageAll])
//packageClient, packageServer & packageAll is not linking to IDE and must not be used for adding dependencies
}
dependencies {
compileCommon 'net.minecraft:launchwrapper:1.11'
compileCommon 'com.google.code.findbugs:jsr305:1.3.9'
compileCommon 'org.ow2.asm:asm-debug-all:5.0.3'
compileCommon 'com.typesafe.akka:akka-actor_2.11:2.3.3'
compileCommon 'com.typesafe:config:1.2.1'
compileCommon 'org.scala-lang:scala-actors-migration_2.11:1.1.0'
compileCommon 'org.scala-lang:scala-compiler:2.11.1'
compileCommon 'org.scala-lang.plugins:scala-continuations-library_2.11:1.0.2'
compileCommon 'org.scala-lang.plugins:scala-continuations-plugin_2.11.1:1.0.2'
compileCommon 'org.scala-lang:scala-library:2.11.1'
compileCommon 'org.scala-lang:scala-parser-combinators_2.11:1.0.1'
compileCommon 'org.scala-lang:scala-reflect:2.11.1'
compileCommon 'org.scala-lang:scala-swing_2.11:1.0.1'
compileCommon 'org.scala-lang:scala-xml_2.11:1.0.2'
compileCommon 'net.sf.jopt-simple:jopt-simple:4.5'
compileCommon 'lzma:lzma:0.0.1'
compileClient 'com.mojang:realms:1.3.5'
compileCommon 'org.apache.commons:commons-compress:1.8.1'
compileCommon 'org.apache.httpcomponents:httpclient:4.3.3'
compileCommon 'commons-logging:commons-logging:1.1.3'
compileCommon 'org.apache.httpcomponents:httpcore:4.3.2'
compileCommon 'java3d:vecmath:1.3.1'
compileCommon 'net.sf.trove4j:trove4j:3.0.3'
compileCommon 'com.ibm.icu:icu4j-core-mojang:51.2'
compileClient 'com.paulscode:codecjorbis:20101023'
compileClient 'com.paulscode:codecwav:20101023'
compileClient 'com.paulscode:libraryjavasound:20101123'
compileClient 'com.paulscode:librarylwjglopenal:20100824'
compileClient 'com.paulscode:soundsystem:20120107'
compileCommon 'io.netty:netty-all:4.0.10.Final'
compileCommon 'com.google.guava:guava:17.0'
compileCommon 'org.apache.commons:commons-lang3:3.3.2'
compileCommon 'commons-io:commons-io:2.4'
compileCommon 'commons-codec:commons-codec:1.9'
compileClient 'net.java.jinput:jinput:2.0.5'
compileClient 'net.java.jutils:jutils:1.0.0'
compileCommon 'com.google.code.gson:gson:2.2.4'
compileCommon 'com.mojang:authlib:1.5.16'
compileCommon 'org.apache.logging.log4j:log4j-api:2.0-beta9'
compileCommon 'org.apache.logging.log4j:log4j-core:2.0-beta9'
compileClient 'org.lwjgl.lwjgl:lwjgl:2.9.1'
compileClient 'org.lwjgl.lwjgl:lwjgl_util:2.9.1'
compileClient 'tv.twitch:twitch:5.16'
compileCommon 'org.yaml:snakeyaml:1.16'
compileCommon 'com.lmax:disruptor:3.2.1'
compileCommon 'org.apache.commons:commons-dbcp2:2.1.1'
compileCommon 'net.openhft:koloboke-api-jdk8:0.6.8'
compileServer 'jline:jline:2.13', {transitive = false}
runtimeCommon 'net.openhft:koloboke-impl-jdk8:0.6.8'
runtimeServer 'mysql:mysql-connector-java:5.1.31'
}
task injectVersion(type: SpeicialClassTransformTask) {
dependsOn tasks.compileJava
inputDir = tasks.compileJava.destinationDir
replace {
replaceIn 'org.ultramine.server.UltramineServerModContainer'
replace '@version@', version
}
}
task reobf(type: ReobfTask) {
dependsOn tasks.compileJava, tasks.injectVersion
classpath = sourceSets.main.compileClasspath;
srg = 'conf/mcp2notch.srg'
inputDir = tasks.compileJava.destinationDir
overrideInputDir = tasks.injectVersion.outputDir
}
task sidesplit(type: SideSplitTask) {
dependsOn tasks.reobf
inputDir = tasks.reobf.outputDir
}
task processServerResources(type: ProcessResources) {
from sourceSets.main.resources.srcDirs
into new File(buildDir, 'resources_server')
exclude 'assets/minecraft/font'
exclude 'assets/minecraft/shaders'
exclude 'assets/minecraft/texts'
exclude 'assets/minecraft/textures'
exclude 'assets/fml/textures'
}
task processClientResources(type: ProcessResources) {
from sourceSets.main.resources.srcDirs
into new File(buildDir, 'resources_client')
exclude 'org/ultramine/defaults'
}
task jar_server(type: Jar) {
dependsOn(tasks.sidesplit, tasks.processServerResources)
from fileTree(tasks.sidesplit.getServerClasses()), tasks.processServerResources
classifier = 'server'
manifest {
attributes(
'Main-Class': 'cpw.mods.fml.relauncher.ServerLaunchWrapper',
'TweakClass': 'cpw.mods.fml.common.launcher.FMLTweaker',
'Class-Path': configurations.packageServer.collect { 'libraries/' + it.getName() }.join(' ')
)
}
}
task jar_client(type: Jar) {
dependsOn(tasks.sidesplit, tasks.processClientResources)
from fileTree(tasks.sidesplit.getClientClasses()), tasks.processClientResources
classifier = 'client'
}
task jar_universal(type: Jar) {
dependsOn(tasks.reobf, tasks.processResources)
from tasks.reobf.getOutputDir(), tasks.processResources
classifier = 'universal'
}
jar {
classifier = 'dev'
}
task jar_source(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}
task storeLastRevision {
inputs.property("version", version)
outputs.dir file("$buildDir/versions")
doLast {
doStoreLastRevision()
}
}
tasks.build.dependsOn tasks.storeLastRevision
task changelog {
inputs.property("prev_commit", previousCommit)
inputs.property("commit", commit)
ext.changelogFile = file("$buildDir/libs/$project.name-$version-changelog.txt")
outputs.file changelogFile
doLast {
doGenerateChangelog(changelogFile);
}
}
artifacts {
if(produce_universal_jar == 'true') archives jar_universal
if(produce_server_jar == 'true') archives jar_server
if(produce_client_jar == 'true') archives jar_client
}
tasks.publish.dependsOn changelog
publishing {
publications {
if(publish_jars.contains('dev'))
mavenDevJar(MavenPublication) {
from new JavaLibrary(new ArchivePublishArtifact(tasks.jar), configurations.packageAll.getAllDependencies())
artifacts.matching({it.classifier == "dev"}).all({it.classifier = null})
artifact tasks.jar_source
artifact tasks.changelog.getProperty('changelogFile'), {classifier = 'changelog'}
}
if(publish_jars.contains('universal'))
mavenUnivarsalJar(MavenPublication) {
from new JavaLibrary(new ArchivePublishArtifact(tasks.jar_universal), configurations.packageAll.getAllDependencies())
artifacts.matching({it.classifier == "universal"}).all({it.classifier = null})
artifactId = project.name + '-universal'
}
if(publish_jars.contains('server'))
mavenServerJar(MavenPublication) {
from new JavaLibrary(new ArchivePublishArtifact(tasks.jar_server), configurations.packageServer.getAllDependencies())
artifacts.matching({it.classifier == "server"}).all({it.classifier = null})
artifactId = project.name + '-server'
}
if(publish_jars.contains('client'))
mavenClientJar(MavenPublication) {
from new JavaLibrary(new ArchivePublishArtifact(tasks.jar_client), configurations.packageClient.getAllDependencies())
artifacts.matching({it.classifier == "client"}).all({it.classifier = null})
artifactId = project.name + '-client'
}
}
repositories {
if(project.hasProperty('publish_url') && !publish_url.isEmpty())
maven {
url publish_url
}
}
}
task dumpLibs(type: Copy) {
into "$buildDir/libs/libraries"
from configurations.runtime
}
String getGitDesc() {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--tags', '--long'
standardOutput = stdout
errorOutput = stdout
}.rethrowFailure().assertNormalExitValue()
return stdout.toString().trim()
}
String computeVersion() {
if(project.hasProperty('override_version'))
return override_version
String mmversion; // major.minor
try {
String[] parts = getGitDesc().split('-')
if(parts.length != 3) throw new GradleException('no git tags found')
if(!parts[0].startsWith('v')) throw new GradleException('last git tag is not a version')
mmversion = parts[0].substring(1) //removing 'v'
commit = parts[2].substring(1) //removing 'g'
} catch (Exception e) {
if(release_type != 'indev') throw e
return 'indev'
}
if(release_type != 'stable') {
int ind = mmversion.lastIndexOf('.')
mmversion = mmversion.substring(0, ind+1) + ((mmversion.substring(ind+1) as int) + 1) + '.0-' + release_type
}
if(project.hasProperty('override_revision')) {
revision = override_revision as int
} else if(release_type != 'indev' || project.hasProperty('increment_revision')) {
File verfile = versionFile = file("$buildDir/versions/$mmversion")
String filetext;
if(verfile.exists() && !(filetext = verfile.getText().trim()).isEmpty()) {
String[] fileparts = filetext.split(':')
if(fileparts.length != 2) throw new GradleException('Version file is corrupted: ' + verfile.getAbsolutePath())
revision = fileparts[1] as int;
previousCommit = fileparts[0];
if(!commit.equals(fileparts[0]) || project.hasProperty('increment_revision')) {
revision++;
}
}
}
return (revision > 0 || release_type == 'stable') ? (mmversion+'.'+revision) : mmversion;
}
void doStoreLastRevision() {
if(versionFile != null) {
versionFile.getParentFile().mkdirs()
versionFile.write(commit+':'+revision)
file("$buildDir/versions/versions").append(commit+':'+version+'\n');
}
}
void doGenerateChangelog(File file) {
BufferedWriter writer = file.newWriter();
writer.writeLine("Changelog for $name-$version");
if(previousCommit == null) {
writer.writeLine('\tempty');
} else {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'log', '--abbrev-commit', '--pretty=short', previousCommit + '..HEAD'
standardOutput = stdout
errorOutput = stdout
}.rethrowFailure().assertNormalExitValue()
for(String s : stdout.toString().trim().split('\n')) {
s = s.trim();
if(s.isEmpty() || s.startsWith('Author'))
continue;
if(s.startsWith('commit'))
writer.writeLine('\t' + s.substring(7) + ':');
else
writer.writeLine('\t\t' + s);
}
}
writer.close();
}