-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
293 lines (248 loc) · 8.39 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
import java.time.Year
buildscript {
repositories {
jcenter()
maven {
name = "Forge"
url = "http://files.minecraftforge.net/maven"
}
maven {
name = "Sonatype"
url = 'https://oss.sonatype.org/content/groups/public'
}
}
dependencies {
classpath 'com.matthewprenger:CurseGradle:1.0-SNAPSHOT'
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
}
}
apply plugin: 'com.matthewprenger.cursegradle'
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'maven'
//Only edit below this line, the above code adds and enables the nessasary things for Forge to be setup.
def username = "${mod_name}"
if (project.hasProperty('dev_mail')) {
username = "${dev_mail}"
}
else if(project.hasProperty('dev_username')) {
username = "${project.dev_username}"
}
version = "${project.mc_version}-${project.mod_version}"
group = project.maven_group // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = project.modid
sourceCompatibility = targetCompatibility = project.jvm_version // Need this here so eclipse task generates correctly.
compileJava {
sourceCompatibility = targetCompatibility = project.jvm_version
}
repositories {
maven {
//JEI files
url = "http://dvs1.progwml6.com/files/maven"
}
maven {
// location of a maven mirror for JEI files, as a fallback
name = "ModMaven"
url = "http://modmaven.k-4u.nl"
}
maven {
//fallback for almost everything, this is CurseForge :P
name = "CurseForge"
url = "https://minecraft.curseforge.com/api/maven/"
}
maven {
//get dependencies from github
name = "JitPack"
url = "https://jitpack.io"
}
}
minecraft {
version = "${project.mc_version}-${project.forge_version}"
if(project.hasProperty('runDir')) {
runDir = project.runDir
}
else if(file('../run').exists()) {
runDir = "../run"
}
else
{
runDir = "run"
}
mappings = project.forge_mappings
makeObfSourceJar = false
replace "@VERSION@", project.mod_version
def fingerPrintKey = project.hasProperty('public_key') ? findProperty('public_key').replace(":", "").toLowerCase(Locale.ROOT) : "undefined"
replace "@FINGERPRINTKEY@", fingerPrintKey
replace "@UPDATEJSON@", project.hasProperty('update_json') ? findProperty('update_json') : ""
replaceIn project.reference_class
clientRunArgs += "--username=${username}"
if(project.hasProperty('dev_password')) {
clientRunArgs += "--password=${dev_password}"
}
//coremod
clientJvmArgs += "-Dfml.coreMods.load=com.github.upcraftlp.pistonexpansion.asm.PistonExpansionLoadingPlugin"
serverJvmArgs += "-Dfml.coreMods.load=com.github.upcraftlp.pistonexpansion.asm.PistonExpansionLoadingPlugin"
//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"
// disable server gui
serverRunArgs += "nogui"
//skip jansi warnings in the log
serverJvmArgs += '-Dlog4j.skipJansi=true'
clientJvmArgs += '-Dlog4j.skipJansi=true'
}
dependencies {
//JEI at runtime (no build dependency, this is for testing purposes ONLY!)
runtime "mezz.jei:jei_${project.mc_version}:${project.jei_version}"
}
compileJava {
options.encoding = 'UTF-8'
}
if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
task coreJar(type: Jar) {
from(sourceSets.main.output) {
include 'com/github/upcraftlp/pistonexpansion/asm/**'
}
manifest.mainAttributes(
"Implementation-Title": project.name + "-core",
"Implementation-Version": "${project.mod_version}",
"Built-On": "${project.mc_version}-${project.forge_version}",
"FMLCorePlugin": "com.github.upcraftlp.pistonexpansion.asm.PistonExpansionLoadingPlugin"
)
classifier 'core'
}
reobf {
coreJar {
mappingType = 'SEARGE'
}
}
task signCoreJar(type: SignJar, dependsOn: reobfCoreJar) {
onlyIf {
project.hasProperty('sign_keyStore')
}
keyPass = findProperty('sign_keyPass')
keyStore = findProperty('sign_keyStore')
storePass = findProperty('sign_storePass')
alias = findProperty('sign_alias')
inputFile = coreJar.archivePath
outputFile = coreJar.archivePath
}
jar {
dependsOn signCoreJar
exclude 'com/github/upcraftlp/pistonexpansion/asm/**'
from(coreJar.archivePath.absolutePath) {
include '*'
}
manifest.mainAttributes(
"Implementation-Title": project.name,
"Implementation-Version": "${project.mod_version}",
"Built-On": "${project.mc_version}-${project.forge_version}",
"Maven-Artifact":"${project.group}:${project.archivesBaseName}:${project.version}",
"FMLAT": "${project.modid}_at.cfg",
"ContainedDeps": coreJar.archivePath.name
)
classifier '' //this is the main jar!
}
//sign Jar
task signJar(type: SignJar, dependsOn: reobfJar) {
onlyIf {
project.hasProperty('sign_keyStore')
}
keyPass = findProperty('sign_keyPass')
keyStore = findProperty('sign_keyStore')
storePass = findProperty('sign_storePass')
alias = findProperty('sign_alias')
inputFile = jar.archivePath
outputFile = jar.archivePath
}
tasks.build.dependsOn signJar
tasks.curseforge.dependsOn build
artifacts {
archives coreJar
}
def curseRelations = {
//optionalLibrary '' //add curseforge-slug here
}
processResources
{
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// replace version and mcversion
expand 'version':project.version, 'mcversion':project.minecraft.version,
'mod_name':project.mod_name, 'mod_description':project.mod_description,
'url':project.url, 'update_url':project.update_json, 'year': Year.now().getValue()
}
// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
//ATs
rename '(.+_at.cfg)', 'META-INF/$1'
}
curseforge {
if (project.hasProperty('curse_key'))
apiKey = project.curse_key
if(project.hasProperty('curse_id')) {
project {
id = project.curse_id
changelogType = 'markdown'
changelog = getChangelogText()
releaseType = project.release_type
//TODO uncomment when adding libraries/optional dependencies
//relations curseRelations
addArtifact coreJar
//addGameVersion '1.12.2' //automatically determined by the CurseGradle plugin
mainArtifact(jar) {
displayName = "${project.mod_name} v${project.mod_version} MC${mc_version}"
}
}
}
}
String getChangelogText() {
def changelogFile = new File(project.projectDir, "changelog.md")
String str = ''
if(!changelogFile.exists()) {
System.out.println("No changelog file found, creating one at \"" + changelogFile.getAbsolutePath() + "\"")
changelogFile.createNewFile()
return str
}
String separator = '---'
int lineCount = 0
boolean done = false
changelogFile.eachLine {
if (done || it == null) {
return
}
if (lineCount < 3) {
lineCount++
if (it.startsWith(separator)) {
return
}
}
if (!it.startsWith(separator)) {
str += "$it" + (lineCount < 3 ? ':\n\n' : '\n')
return
}
done = true // once we go past the first version block, parse no more
}
str += "\n\n see full changelog [here](${project.changelog_url} \"Changelog\")"
return str
}