forked from Inventory-Tweaks/inventory-tweaks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
282 lines (234 loc) · 6.63 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
buildscript {
repositories {
jcenter()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
}
}
plugins {
//id "net.minecraftforge.gradle.forge" version "2.0.2"
id "com.matthewprenger.cursegradle" version "1.0.9"
}
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'idea'
dependencies {
compile 'org.jetbrains:annotations:13.0'
}
if(!hasProperty('mod_version')) {
mod_version = 'UNKNOWN'
}
def getGitCommitHash = { ->
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', '--short', 'HEAD'
standardOutput = stdout
}
return stdout.toString().trim()
} catch(ignored) {
return null;
}
}
def getGitDirtyIndex = { ->
try {
return exec {
commandLine 'git', 'diff-index', '--quiet', '--cached', 'HEAD'
ignoreExitValue = true
}.exitValue == 1
} catch(ignored) {
return false;
}
}
def getGitDirtyFiles = { ->
try {
return exec {
commandLine 'git', 'diff-files', '--quiet'
ignoreExitValue = true
}.exitValue == 1
} catch(ignored) {
return false;
}
}
def getGitChangelog = { ->
try {
def stdout = new ByteArrayOutputStream()
def gitHash = System.getenv("GIT_COMMIT")
def gitPrevHash = System.getenv("GIT_PREVIOUS_COMMIT")
def travisRange = System.getenv("TRAVIS_COMMIT_RANGE")
if(gitHash && gitPrevHash) {
exec {
commandLine 'git', 'log', '--pretty=tformat:%s - %aN', '' + gitPrevHash + '...' + gitHash
standardOutput = stdout
}
return stdout.toString().trim()
} else if(travisRange) {
exec {
commandLine 'git', 'log', '--pretty=tformat:%s - %aN', '' + travisRange
standardOutput = stdout
}
return stdout.toString().trim()
} else {
return "";
}
} catch(ignored) {
return "";
}
}
ext.git_version = getGitCommitHash()
ext.git_dirty = getGitDirtyIndex() || getGitDirtyFiles()
ext.build_number = System.getenv('BUILD_NUMBER')
if(!build_number) {
ext.build_number = System.getenv('TRAVIS_BUILD_NUMBER')
}
ext.git_separator = '.'
if(mod_version.contains('+')) {
if(build_number) {
version = mod_version + '.' + build_number
} else {
version = mod_version
}
ext.internal_version = version
} else {
version = mod_version
ext.internal_version = version
if(build_number) {
ext.internal_version += "+release." + build_number
} else {
ext.git_separator = '+'
}
}
if(git_version) {
ext.internal_version += git_separator + git_version
if(git_dirty) {
ext.internal_version += '.dirty'
}
} else {
ext.internal_version = version
}
group = mod_group
archivesBaseName = mod_name
minecraft {
version = forge_version
mappings = mcp_version
runDir = "run"
makeObfSourceJar = false
replace '@VERSION@', project.internal_version
replaceIn 'InvTweaksConst.java'
}
if(hasProperty('mod_core_plugin')) {
minecraft.coreMod = mod_core_plugin
jar {
manifest {
attributes 'FMLCorePlugin': mod_core_plugin, 'FMLCorePluginContainsFMLMod': mod_core_hasfmlmod
}
}
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
compileJava {
options.debug = true
options.debugOptions.debugLevel = 'source,lines,vars'
}
ext.keystore = System.getenv("KEYSTORE")
ext.keystorePass = System.getenv("KEYSTORE_PASSWORD")
ext.keyPass = System.getenv("KEY_PASSWORD")
ext.keyAlias = System.getenv("KEY_ALIAS")
task signJar(type: Exec, dependsOn: reobfJar) {
onlyIf {
project.keystore && project.keystorePass && project.keyPass && project.keyAlias
}
commandLine "jarsigner", "-keystore", keystore, "-storepass", keystorePass, "-keypass", keyPass,
"-tsa", "http://timestamp.comodoca.com", "-tsadigestalg", "SHA-512",
"-sigalg", "SHA512withECDSA", "-digestalg", "SHA-512", jar.archivePath, keyAlias
}
build.dependsOn signJar
task apiJar(type: Jar) {
onlyIf { project.hasProperty('api_filter') }
dependsOn classes
from sourceSets.main.allJava
from sourceSets.main.output
include api_filter
classifier 'api'
}
task deobfJar(type: Jar) {
dependsOn classes
from sourceSets.main.output
if(project.hasProperty('mod_core_plugin')) {
manifest {
attributes 'FMLCorePlugin': mod_core_plugin, 'FMLCorePluginContainsFMLMod': mod_core_hasfmlmod
}
}
classifier 'deobf'
}
artifacts {
archives apiJar
archives deobfJar
}
ext.curseKey = System.getenv("CURSE_API_KEY")
if(mod_version.endsWith("dev")) {
ext.curseType = 'alpha'
ext.curseVersion = version
} else if(mod_version.endsWith("beta")) {
ext.curseType = 'beta'
ext.curseVersion = version
} else {
ext.curseType = 'release'
ext.curseVersion = mod_version
}
tasks.curseforge.onlyIf { curseKey }
tasks.curseforge.dependsOn signJar, apiJar, deobfJar
if(hasProperty('curse_extra_versions')) {
ext.curseExtraVersions = curse_extra_versions.tokenize(',')
}
if(curseKey && hasProperty('curse_id')) {
curseforge {
apiKey = curseKey
project {
id = curse_id
changelog = getGitChangelog()
releaseType = curseType
addGameVersion minecraft.version
if(hasProperty('curseExtraVersions')) {
for(version in curseExtraVersions) {
addGameVersion version
}
}
addGameVersion 'Java 8'
mainArtifact(jar) {
displayName = "$curse_filename $curseVersion"
}
addArtifact(apiJar) {
displayName = "$curse_filename API $curseVersion"
}
addArtifact(deobfJar) {
displayName = "$curse_filename Deobfuscated $curseVersion"
}
}
}
}
processResources {
inputs.property 'version', internal_version
inputs.property 'mcversion', minecraft.version
from(sourceSets.main.resources.srcDirs) {
exclude '**/*.png'
exclude '**/*_at.cfg'
expand version: internal_version, mcversion: minecraft.version
}
from(sourceSets.main.resources.srcDirs) {
include '**/*.png'
include '**/*_at.cfg'
}
}
idea {
module {
inheritOutputDirs = true
}
project {
vcs = 'Git'
}
}