-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
268 lines (222 loc) · 7.04 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
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'
}
}
plugins {
id 'com.matthewprenger.cursegradle' version '1.0.9'
}
apply plugin: 'net.minecraftforge.gradle.forge'
//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}"
}
version = "${project.mc_version}-${project.mod_version}"
group = project.maven_group // http://maven.apache.org/guides/mini/guide-naming-conventions.html
//noinspection GroovyUnusedAssignment
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
//Mantle
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 {
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 // 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
replaceIn project.reference_class
//auto-configure the run arguments
clientRunArgs += "--username=${username}"
if(project.hasProperty('dev_password')) {
clientRunArgs += "--password=${dev_password}"
}
serverRunArgs += "nogui" //mc server GUIs suck :P
serverJvmArgs += "-Dfml.doNotBackup=true"
clientJvmArgs += "-Dfml.doNotBackup=true"
serverJvmArgs += "-Dfml.queryResult=confirm"
//skip jansi warnings in the log
serverJvmArgs += "-Dlog4j.skipJansi=true"
clientJvmArgs += "-Dlog4j.skipJansi=true"
}
dependencies {
//JEI (runtime only)
runtime "mezz.jei:jei_${project.mc_version}:${project.jei_version}"
def noJEI = {
exclude group: "mezz.jei", module: "jei_${project.mc_version}"
}
//craftdev-core (from JitPack)
//TODO uncomment when releasing v3.0.0
//deobfProvided "com.github.UpcraftLP:CraftDev-Core:${project.core_version}:api", noJEI
//runtime "com.github.UpcraftLP:CraftDev-Core:${project.core_version}", noJEI
}
compileJava {
options.encoding = 'UTF-8'
}
if (JavaVersion.current().isJava8Compatible()) {
allprojects {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
}
}
jar {
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.mod_name}_at.cfg"
)
}
//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 apiJar
//archives deobfJar
//archives javadocJar
}
sourceSets {
main {
java {
srcDir 'src/main/java'
}
resources {
srcDir 'resources'
}
}
}
def curseRelations = {
requiredLibrary 'craftdev-core'
//optionalLibrary '' //add curseforge-slug here
}
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
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 'version':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'
}
String getChangelogText() {
def changelogFile = new File(project.projectDir, "changelog.md")
String str = ''
if(!changelogFile.exists()) {
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
}