forked from SleepyTrousers/EnderIO-1.5-1.12
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
358 lines (301 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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
buildscript {
repositories {
jcenter()
mavenCentral()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
classpath "gradle.plugin.net.intellisun:modDependencies:1.0.1-alpha.2" // https://github.com/IntelliSun-MC/modDependencies
}
}
plugins {
id 'com.matthewprenger.cursegradle' version "1.0.7"
}
apply plugin: 'maven'
apply plugin: 'eclipse'
def dev = System.getenv("RELEASE") == null || System.getenv("RELEASE").equalsIgnoreCase("false")
ext.user = parseConfig(file('user.properties'))
if (ext.user != null) {
ext.user.each { k, v ->
project.ext.set(k, v)
}
}
task copyJars(type: Copy) {
from subprojects.collect {
it.tasks.withType(Jar)
}
into "$buildDir/libs"
}
// task apiJar(type: Jar) {
// }
build.dependsOn copyJars
allprojects {
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'net.intellisun.moddependencies'
group = "com.enderio"
archivesBaseName = project.name.toLowerCase()
if (System.getenv('BUILD_NUMBER') != null)
{
ext.version_suffix = ''
if (System.getenv('NIGHTLY') != null)
{
ext.module_version = 'nightly-0.' + System.getenv('BUILD_NUMBER')
}
else
{
ext.module_version = version_major + '.' + version_minor + '.' + System.getenv('BUILD_NUMBER')
if (project.hasProperty('version_appendix') && project.version_appendix != '')
ext.version_suffix = '-' + version_appendix
}
}
else
{
if (!project.hasProperty('module_build_number') || project.module_build_number == '0') {
ext.module_build_number = '0'
if (System.getenv('MODULE_BUILD_NUMBER') != null)
project.module_build_number = System.getenv('MODULE_BUILD_NUMBER')
else try {
ext.module_build_number = "git rev-parse --short HEAD".execute().text.trim()
} catch (all) {}
}
ext.version_suffix = ''
if (project.hasProperty('version_appendix') && project.version_appendix != '')
ext.version_suffix = "-${version_appendix}"
ext.module_version = version_major + '.' + version_minor + '.' + module_build_number
}
version = "${minecraft_version}-${module_version}"// ${version_suffix}"
if (!project.hasProperty('include_in_build'))
project.ext.include_in_build = true
else
project.include_in_build = project.include_in_build != 'false'
if (!project.include_in_build)
println "Project ${project.name} is forcefully excluded from the build"
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8
compileJava {
sourceCompatibility = targetCompatibility = JavaVersion.VERSION_1_8
}
minecraft {
version = "${minecraft_version}-${forge_version}"
mappings = mcp_mappings
runDir = "run"
}
sourceSets {
main {
java {
srcDir 'src/main/java'
}
resources {
srcDir 'src/main/resources'
}
}
}
repositories {
mavenCentral()
maven { url = "http://tehnut.info/maven" }
// maven { url = "http://dl.tsr.me/artifactory/libs-release-local" }
maven { url = "http://maven.tterrag.com" }
maven { url = "http://dvs1.progwml6.com/files/maven" }
maven { url = "http://files.minecraftforge.net/maven" }
maven { url = "http://maven.cil.li/" }
maven { url = "http://maven.ic2.player.to" }
maven { url = "http://maven.epoxide.xyz" }
ivy {
url "http://ae-mod.info/builds"
layout "pattern", {
artifact "[module]-[revision](-[classifier])(.[ext])"
}
}
mavenLocal()
}
if (JavaVersion.current().isJava8Compatible()) {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
task apiJar(type: Jar) {
classifier = 'api'
}
task mkKeyStore(type:Exec) {
workingDir projectDir
commandLine 'keytool', '-genkey', '-alias', 'signFiles', '-keystore', 'eiostore.jks', '-storepass', '123456', '-noprompt', '-dname', 'CN='+getCN(), '-keypass', '123456'
}
task signJar(type: SignJar, dependsOn: reobfJar) {
inputFile = jar.archivePath
outputFile = jar.archivePath
keyStore = 'eiostore.jks'
alias = 'signFiles'
storePass = '123456'
keyPass = '123456'
}
task rmKeyStore(type: Delete) {
delete 'eiostore.jks'
}
build.dependsOn rmKeyStore
rmKeyStore.dependsOn signJar
signJar.dependsOn mkKeyStore
artifacts {
archives sourceJar
archives apiJar
}
}
def buildprojects = subprojects.findAll { sp -> sp.include_in_build }
subprojects {
apply plugin: 'eclipse-wtp'
dependencies {
if (!project.hasProperty('use_local_ender_core')) {
deobfCompile "com.enderio.core:EnderCore:${endercore_version}"
}
compile fileTree(dir: "lib", include: '*.jar')
compile fileTree(dir: "${project.rootDir}/lib", include: '*.jar')
}
processResources {
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
from(sourceSets.main.resources.srcDirs) {
include '**/*.info'
include '**/*.properties'
expand 'version': project.version, 'mcversion': project.minecraft.version
}
from(sourceSets.main.resources.srcDirs) {
exclude '**/*.info'
exclude '**/*.properties'
}
}
apiJar {
from sourceSets.main.allSource
from sourceSets.main.output
include 'crazypants/enderio/api/**/*'
}
build.dependsOn sourceJar, apiJar
}
subprojects {
if (file('dependencies.gradle').exists())
apply from: 'dependencies.gradle'
minecraft {
replace '@VERSION@', project.version
if (project.hasProperty('dependencyString'))
replace 'DEFAULT_DEPENDENCIES;', "\"${dependencyString}\";"
}
}
jar.doFirst {
File target = new File(project.sourceSets.main.output.resourcesDir, "assets/enderio/lang")
target.mkdirs()
buildprojects.each { subproject ->
new File(subproject.sourceSets.main.output.resourcesDir, 'assets/enderio/lang/').eachFileMatch( ~".*\\.lang\$" ) { langfile ->
new File(target, langfile.name) << "\n" << langfile.text
}
}
def mcmod = ""
buildprojects.each { subproject ->
mcmod += new File(subproject.sourceSets.main.output.resourcesDir, 'mcmod.info').text
}
new File(project.sourceSets.main.output.resourcesDir, "mcmod.info") << mcmod.replaceAll(/\]\s*\[/, ',')
def sound = ""
buildprojects.each { subproject ->
sound += new File(subproject.sourceSets.main.output.resourcesDir, 'assets/enderio/sounds.json').text
}
new File(project.sourceSets.main.output.resourcesDir, "assets/enderio/sounds.json") << sound.replaceAll(/\}\s*\{/, ',')
println "Created derived resources in ${target}"
}
subprojects.each { subproject ->
evaluationDependsOn(subproject.path)
}
jar.dependsOn subprojects.tasks['classes']
jar {
from project.sourceSets.main.output.resourcesDir
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
buildprojects.each { subproject ->
from subproject.sourceSets.main.output.classesDirs
from subproject.sourceSets.main.output.resourcesDir
}
}
apiJar.dependsOn subprojects.tasks['classes']
apiJar {
buildprojects.each { subproject ->
from subproject.sourceSets.api.output.classesDirs
from subproject.sourceSets.api.output.resourcesDir
}
}
tasks.curseforge.enabled = !dev && project.hasProperty('curseforge_key')
curseforge {
if (project.hasProperty('curseforge_key')) {
apiKey = project.curseforge_key
}
project {
id = project.curse_projectId
changelog = """
<p>You need <strong>either</strong> the main file <strong>or</strong> a selection of the "split" jars, not both!</p>
<p> </p>
<p><a href="http://ci.tterrag.com/job/EnderIO-Modules/job/EnderIO-Base/#BUILD#/changes">Changelog (this build)</a> /
<a href="http://ci.tterrag.com/job/EnderIO-Modules/job/EnderIO-Base/changes">Changelog (all builds)</a></p>
<p> </p>
<p>#EXTRA#</p>
""".replaceAll('#BUILD#', System.getenv('BUILD_NUMBER') == null ? '0' : System.getenv('BUILD_NUMBER')).replaceAll('#EXTRA#', System.getenv('CHANGELOG') == null || System.getenv('CHANGELOG').equals('none') ? '' : System.getenv('CHANGELOG'))
changelogType = 'html'
releaseType = 'alpha' // for now
mainArtifact(jar) {
displayName = "Ender IO - ${module_version}"
}
relations {
requiredLibrary 'endercore'
optionalLibrary 'waila'
optionalLibrary 'jei'
optionalLibrary 'the-one-probe'
optionalLibrary 'baubles'
optionalLibrary 'chisel'
optionalLibrary 'hwyla'
optionalLibrary 'opencomputers'
optionalLibrary 'forestry'
optionalLibrary 'ctm'
optionalLibrary 'tesla'
optionalLibrary 'applied-energistics-2'
optionalLibrary 'actually-additions'
optionalLibrary 'extreme-reactors'
optionalLibrary 'biomes-o-plenty'
optionalLibrary 'botania'
optionalLibrary 'buildcraft'
optionalLibrary 'chisels-bits'
optionalLibrary 'extra-utilities'
optionalLibrary 'immersive-engineering'
optionalLibrary 'industrial-craft'
optionalLibrary 'natura'
optionalLibrary 'railcraft'
optionalLibrary 'thermal-foundation'
optionalLibrary 'tinkers-construct'
}
addArtifact apiJar
buildprojects.each { subproject ->
addArtifact subproject.jar
addArtifact subproject.sourceJar
}
}
}
gradle.taskGraph.whenReady {
gradle.taskGraph.allTasks.each {
if(!it.project.include_in_build) {
it.onlyIf { false }
}
}
}
String getCN() {
def firsts = ['Donald', 'Lex', 'The', 'Arthur', 'Bridget', 'Dorian', 'Ford', 'Guy', 'James', 'Jessica', 'John', 'Michael', 'Robinson', 'Zaphod', 'Bell', 'Penelope']
def lasts = ['Duck', 'Luthor', 'Doctor', 'Master', 'Dent', 'Jones', 'Gray', 'Prefect', 'Montag', 'Moriarty', 'Rabbit', 'Watson', 'Smith', 'Corleone', 'Crusoe', 'Beeblebrox', 'Cranel', 'Akk']
def rand = new Random()
return firsts[rand.nextInt(firsts.size())] + ' ' + lasts[rand.nextInt(lasts.size())]
}
def parseConfig(File config) {
if (!config.exists())
return null
config.withReader {
def prop = new Properties()
prop.load(it)
return (new ConfigSlurper().parse(prop))
}
}