-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
345 lines (285 loc) · 8.97 KB
/
build.gradle
File metadata and controls
345 lines (285 loc) · 8.97 KB
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
buildscript {
repositories {
mavenLocal()
jcenter()
mavenCentral()
maven { url = "https://files.minecraftforge.net/maven" }
maven {
name = 'gradle'
url 'https://plugins.gradle.org/m2/'
}
maven {
name = 'sonatype'
url = 'https://oss.sonatype.org/content/groups/public'
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
}
}
plugins {
id 'com.matthewprenger.cursegradle' version '1.4.0'
id "com.wynprice.cursemaven" version "2.1.1"
id 'idea'
id 'java'
}
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
options.compilerArgs = [
'-Xlint:deprecation' // deprecation, rawtypes, cast, unchecked, all
]
}
javadoc {
failOnError = false
}
apply plugin: 'net.minecraftforge.gradle.forge'
eclipse.project {
buildCommand 'org.eclipse.buildship.core.gradleprojectbuilder'
natures 'org.eclipse.buildship.core.gradleprojectnature'
}
apply from: 'gradle/secret.gradle'
def versionInfo = getModVersion()
System.out.println(versionInfo)
version = "${versionInfo['version']}"
def build_num = getBuildNumber()
version = "${mod_version}"
group = "${group}"
archivesBaseName = "${name}"
sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
compileJava {
sourceCompatibility = targetCompatibility = '1.8'
}
String GCBuild = "261"
String GCVersion = "1.12.2-4.0.2.${GCBuild}"
repositories {
ivy {
url "https://micdoodle8.com/new-builds/"
layout 'pattern', {
artifact "[organization]/${GCBuild}/[module]-[revision].jar"
}
metadataSources {
artifact()
}
}
maven {
name = 'curseforge'
url = 'https://minecraft.curseforge.com/api/maven/'
}
maven {
name 'DVS1 Maven FS'
url 'http://dvs1.progwml6.com/files/maven'
}
mavenCentral()
maven {
url = "https://mod-buildcraft.com/maven/"
}
}
dependencies {
compile "com.mod-buildcraft:buildcraft-api:7.99.24.6"
compile "mezz.jei:jei_${mc_version}:${jei_version}:api"
runtime "mezz.jei:jei_${mc_version}:${jei_version}"
compile "GC-1.12-dev:GalacticraftCore-Dev:${GCVersion}"
compile "GC-1.12-dev:Galacticraft-API:${GCVersion}"
compile "GC-1.12-dev:Galacticraft-Planets-Dev:${GCVersion}"
compile "GC-1.12-dev:MicdoodleCore-Dev:${GCVersion}"
compileOnly 'org.projectlombok:lombok:1.18.12'
annotationProcessor 'org.projectlombok:lombok:1.18.12'
testCompileOnly 'org.projectlombok:lombok:1.18.12'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.12'
compile 'org.reflections:reflections:0.9.12'
}
apply from: 'gradle/curseforge.gradle'
minecraft {
version = project.forge_mc_version + '-' + project.forge_version
runDir = 'run'
mappings = project.mcp_mappings_version
replace "BUILD_NUM = 0", "BUILD_NUM = " + build_num
replaceIn "AmunRa.java"
if (project.hasProperty('coreplugin')) {
clientJvmArgs += '-Dfml.coreMods.load=' + project.coreplugin
serverJvmArgs += '-Dfml.coreMods.load=' + project.coreplugin
}
if (project.hasProperty('mc_username')) {
clientRunArgs += ['--username', project.mc_username]
if (project.hasProperty('mc_password')) {
clientRunArgs += ['--password', project.mc_password]
}
}
if (project.hasProperty('mc_uuid')) {
clientRunArgs += ['--uuid', project.mc_uuid]
}
// disable server gui
serverRunArgs += 'nogui'
// skip the screen to confirm that you want to load a world with missing registry entries
serverJvmArgs += '-Dfml.doNotBackup=true'
clientJvmArgs += '-Dfml.doNotBackup=true'
// skip having to confirm on server
serverJvmArgs += '-Dfml.queryResult=confirm'
//skip jansi warnings in the log
serverJvmArgs += '-Dlog4j.skipJansi=true'
clientJvmArgs += '-Dlog4j.skipJansi=true'
if (project.hasProperty('client_args')) {
clientJvmArgs += project.client_args
}
if (project.hasProperty('server_args')) {
serverJvmArgs += project.server_args
}
}
processResources {
inputs.property 'version', project.version
inputs.property 'mcversion', project.minecraft.version
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
expand 'version': "${versionInfo['version_short']}", 'mcversion': project.minecraft.version
}
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
rename '(amunra_at.cfg)', 'META-INF/$1'
}
import java.util.regex.Matcher
jar {
appendix = "${project.mc_version}"
}
task apiJar(type: Jar) {
appendix = "${project.mc_version}"
classifier = 'apiClasses'
from apiClasses
}
task deobfJar(type: Jar) {
appendix = "${project.mc_version}"
classifier = 'deobf'
from sourceSets.main.output
}
task sourcesJar(type: Jar) {
appendix = "${project.mc_version}"
classifier = 'sources'
from sourceSets.main.allJava
}
task javadocJar(type: Jar, dependsOn: javadoc) {
appendix = "${project.mc_version}"
classifier = 'javadoc'
from javadoc.getDestinationDir()
}
artifacts {
if (project.hasProperty('doAPIJar')) {
archives apiJar
}
if (project.hasProperty('doDeobfJar')) {
archives deobfJar
}
if (project.hasProperty('doSourceJar')) {
archives sourcesJar
}
if (project.hasProperty('doJavadocJar')) {
archives javadocJar
}
}
// Version stuff
boolean getBooleanProperty(final String property) {
if (project.hasProperty(property)) {
return ((String) project.findProperty(property)).toBoolean()
} else {
return false
}
}
def getModVersion() {
try {
return getGitVersion()
} catch (Exception ex) {
System.out.println("Git version failed, falling back to old method")
return getVersion('VERSION', getModFile())
}
}
def getGitVersion() {
// Call git command
def outStream = new ByteArrayOutputStream()
def result = exec {
executable = 'git'
args = [ 'describe', '--long' ]
standardOutput = outStream
}
def fullVersion = outStream.toString().trim()
def matcher = fullVersion =~ /(\d+).(\d+).(\d+)-(.*)/
def maj = matcher[0][1]
def min = matcher[0][2]
def rev = matcher[0][3]
def bn = getBuildNumber()
return makeVersionMap(maj, min, rev, bn, matcher[0][4])
}
static def makeVersionMap(maj, min, rev, bn, githash) {
def out = [:]
out['build.major.number'] = maj.toString()
out['build.minor.number'] = min.toString()
out['build.revision.number'] = rev.toString()
out['build.githash'] = githash
out['build.number'] = bn.toString()
out['version_short'] = "${maj}.${min}.${rev}".toString()
out['version'] = "${maj}.${min}.${rev}+${bn}".toString()
return out
}
// Modified old version getter
def getVersion(String type, String mod_file) {
String maj = '0'
String min = '0'
String rev = '0'
String bn = getBuildNumber()
File file = file(mod_file)
def prefix = ~/^(?:public|protected|private) static final String $type = ".*$/
file.eachLine { String s ->
s = s.trim()
if (s ==~ prefix || prefix.matcher(s).matches()) {
String[] bits = s.split("=")
String interesting = bits[1].trim()
interesting = interesting.substring(1, interesting.length() - 2)
String[] pts = interesting.trim().split("\\.")
maj = pts[0] ?: '0'
min = pts[1] ?: '0'
rev = pts[2] ?: '0'
}
}
return makeVersionMap(maj, min, rev, bn, 'unknown')
}
// Used by old getVersion
String getModFile() {
String path = ''
FileTree tree = fileTree(dir: 'src/main/java' )
tree.include '**/*.java'
tree.visit { element ->
if (element.file.isFile()) {
element.file.eachLine { String s ->
s = s.trim()
if (s.startsWith('@Mod(')) {
path = "src/main/java/$element.relativePath"
}
}
}
}
return path
}
// Build number tracking
String getBuildNumber() {
def versionFile = file('version.properties')
if (versionFile.canRead()) {
Properties versionProps = new Properties()
versionProps.load(new FileInputStream(versionFile))
return versionProps['build_num'].toString()
}
return "1"
}
task incrementBuild {
doFirst {
def versionFile = file('version.properties')
if (versionFile.canRead()) {
Properties versionProps = new Properties()
versionProps.load(new FileInputStream(versionFile))
def num = versionProps['build_num'].toInteger() + 1
println("incrementing BuildNumber to: " + num)
versionProps['build_num'] = num.toString()
versionProps.store(versionFile.newWriter(), null)
} else {
println("version.properties file not found! Ignoring.")
}
}
}
build.finalizedBy incrementBuild // only increment on successful builds