-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
296 lines (249 loc) · 8.86 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
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 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
classpath 'com.matthewprenger:CurseGradle:1.0-SNAPSHOT'
}
}
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'com.matthewprenger.cursegradle'
apply from: 'https://gist.githubusercontent.com/UpcraftLP/0a98a7dfe913bd3e99073efa7ad0353b/raw/mod_script.gradle'
//Only edit below this line, the above code adds and enables the nessasary things for Forge to be setup.
import java.time.Year
def username = "${modid}"
if (project.hasProperty('dev_mail')) {
username = "${dev_mail}"
}
else if(project.hasProperty('dev_username')) {
username = "${dev_username}"
}
def buildVersion = project.mod_version + ext.buildName
version = "${project.mc_version}-" + buildVersion
group = project.maven_group // http://maven.apache.org/guides/mini/guide-naming-conventions.html
//noinspection GroovyUnusedAssignment
archivesBaseName = project.modid
tasks.build.doFirst { println("Current version is ${modid}-${version}") }
sourceCompatibility = targetCompatibility = project.jvm_version // Need this here so eclipse task generates correctly.
compileJava {
sourceCompatibility = targetCompatibility = project.jvm_version
}
repositories {
maven {
//JEI files
name = "DVS1 Maven FS"
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 {
//hwyla
name = "TehNut"
url = "https://tehnut.info/maven"
}
//local maven, if present
mavenLocal()
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
if("${mappings}" != "${project.ext.mappings}" && "${mappings}".startsWith("snapshot_")) {
println(String.format("You are on old mappings, latest mappings are %s (you are on %s)", project.ext.mappings, mappings))
}
makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
replace "@VERSION@", project.mod_version
def fingerPrintKey = project.hasProperty('public_key') ? findProperty('public_key').replace(":", "").toLowerCase(Locale.ROOT) : "undefined"
replace "@FINGERPRINTKEY@", fingerPrintKey
replace "@UPDATE_JSON@", project.update_json
replace "required-after:forge", "required-after:forge@[" + project.forge_version + ",)"
replace "required-after:glasspane", "required-after:glasspane@[" + project.gp_version + ",)"
replaceIn "${project.reference_class}".replace(".", "/")
//auto-configure the run arguments
if(project.hasProperty('dev_uuid')) {
clientRunArgs += "--uuid=${dev_uuid}"
}
else {
clientRunArgs += "--username=${username}"
if(project.hasProperty('dev_password')) clientRunArgs += "--password=${dev_password}"
}
//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'
}
// API jar
task apiJar(type: Jar) {
onlyIf{
project.hasProperty("api_package")
}
from sourceSets.api.allJava
include new String(findProperty("api_package") + "/**").replace(".", "/")
from ("LICENSE") {
include "*"
}
manifest.mainAttributes(
"Built-On-Java": "${System.getProperty('java.vm.version')} + (${System.getProperty('java.vm.vendor')})",
"Implementation-Title": project.name + '-api',
"Implementation-Version": project.version,
"Maven-Artifact":"${project.group}:${project.archivesBaseName}:${project.version}:api",
"Built-On": "${mc_version}-${forge_version}"
)
classifier = 'api'
}
// Javadoc jar
task javadocJar(type: Jar, dependsOn: javadoc) {
from javadoc.destinationDir
from ("LICENSE") {
include "*"
}
manifest.mainAttributes(
"Built-On-Java": "${System.getProperty('java.vm.version')} + (${System.getProperty('java.vm.vendor')})",
"Implementation-Title": project.name + '-javadoc',
"Implementation-Version": project.version,
"Maven-Artifact":"${project.group}:${project.archivesBaseName}:${project.version}:javadoc",
"Built-On": "${mc_version}-${forge_version}"
)
classifier = 'javadoc'
}
jar {
from sourceSets.api.output
from "LICENSE"
manifest.mainAttributes(
"Implementation-Title": project.name,
"Implementation-Version": "${project.mod_version}",
"Built-On": "${project.mc_version}-${project.forge_version}"
//"FMLAT": "${project.modid}_at.cfg"
)
}
task signApiJar(type: SignJar, dependsOn: apiJar) {
onlyIf {
project.hasProperty('sign_keyStore')
}
keyPass = findProperty('sign_keyPass')
keyStore = findProperty('sign_keyStore')
storePass = findProperty('sign_storePass')
alias = findProperty('sign_alias')
inputFile = apiJar.archivePath
outputFile = apiJar.archivePath
}
task signJavadocJar(type: SignJar, dependsOn: javadocJar) {
onlyIf {
project.hasProperty('sign_keyStore')
}
keyPass = findProperty('sign_keyPass')
keyStore = findProperty('sign_keyStore')
storePass = findProperty('sign_storePass')
alias = findProperty('sign_alias')
inputFile = javadocJar.archivePath
outputFile = javadocJar.archivePath
}
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
}
if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
dependencies {
compile "com.github.GlassPane:GlassPane:1.0.0"
}
if(project.hasProperty("api_package")) tasks.build.dependsOn signApiJar
tasks.build.dependsOn signJar, signJavadocJar
tasks.curseforge.dependsOn build
artifacts {
//archives apiJar
archives javadocJar
}
def curseRelations = {
//requiredLibrary '' //add curseforge-slug here
requiredLibrary 'glasspane'
}
curseforge {
if (project.hasProperty('curse_key'))
apiKey = project.curse_key
if(project.hasProperty('curse_id')) {
project {
id = project.curse_id
changelogType = 'markdown'
changelog = "${project.ext.changeLog}"
releaseType = project.release_type
relations curseRelations
addArtifact javadocJar
//addArtifact sourceJar
//addArtifact apiJar
//addGameVersion '1.12'
//addGameVersion '1.12.1'
//addGameVersion '1.12.2'
mainArtifact(jar) {
displayName = "${project.mod_name} v${project.mod_version} MC${project.mc_version}"
}
}
}
}
processResources
{
// this will ensure that this task is redone when the versions change.
inputs.property "version", 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 'modid':project.modid, 'name':project.mod_name, 'description':project.mod_description, 'version':project.mod_version, 'mcversion':project.minecraft.version, 'url':project.url, 'updateUrl':project.update_json, 'year':String.valueOf(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'
}