-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
211 lines (183 loc) · 7.24 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
import groovy.json.JsonSlurper
import groovy.json.JsonOutput
buildscript {
repositories {
maven { url = "https://files.minecraftforge.net/maven" }
jcenter()
mavenCentral()
}
dependencies {
classpath group: "net.minecraftforge.gradle", name: "ForgeGradle", version: "3.+", changing: true
classpath 'gradle.plugin.com.matthewprenger:CurseGradle:1.4.0'
}
}
plugins {
id "java-library"
}
// Normally this would be added to the plugins block above, but since ForgeGradle is constantly changing, and the
// plugin block requires you to specify a version, this allows gradle to get the most up-to-date version.
apply plugin: "net.minecraftforge.gradle"
apply plugin: "com.matthewprenger.cursegradle"
apply plugin: "idea"
// Exclude folders whenever the idea module updates, such as during a gradle re-import.
idea {
module {
for (String excludeDirName in [".gradle", ".idea", "build", "gradle", "media", "run", "out", "logs"]) {
excludeDirs += file(excludeDirName)
}
}
}
// NOTE: build.gradle automatically loads gradle.properties, which holds variables that change between different mods
// Basic mod setup
group = mod_group
archivesBaseName = mod_name
version = minecraft_version + "-" + mod_version
// Uncomment if using Eclipse so eclipse task generates correctly.
//sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
// Load in the repositories for mods useful in the dev process. To add or remove mods, just update the repos.json file.
def repos = new JsonSlurper().parse(file("repos.json"))
repositories {
mavenCentral()
repos.each { n, u ->
maven {
name = n
url = u.url
}
}
}
dependencies {
minecraft "net.minecraftforge:forge:" + minecraft_version + "-" + forge_version
repos.each { n, l ->
compileOnly fg.deobf(l.lib + ":api")
runtimeOnly fg.deobf(l.lib)
}
}
minecraft {
mappings channel: "snapshot", version: mappings_version
accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
runs {
client = {
// Recommended logging data for a userdev environment
//property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
properties 'forge.logging.console.level': 'debug'
properties 'fml.earlyprogresswindow': 'false'
// These variables allow the use of your actual minecraft profile in-game.
// The best place they should be stored is in the gradle.properties file in your gradle user home.
// Due to caching, should you change these variables, you need to rerun the gen(Intellij/Eclipse)Runs task.
if (project.hasProperty('mc_uuid')) {
// Your uuid without any dashes in the middle
args '--uuid', project.getProperty('mc_uuid')
}
if (project.hasProperty('mc_username')) {
// Your username/display name, this is the name that shows up in chat
// Note: This is not your email, even if you have a Mojang account
args '--username', project.getProperty('mc_username')
}
if (project.hasProperty('mc_accessToken')) {
// Your access token, you can find it in your '.minecraft/launcher_profiles.json' file
args '--accessToken', project.getProperty('mc_accessToken')
}
workingDirectory project.file('run').canonicalPath
mods {
armiger {
source sourceSets.main
}
}
}
server = {
// Recommended logging data for a userdev environment
//property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
properties 'forge.logging.console.level': 'debug'
workingDirectory project.file('run').canonicalPath
mods {
armiger {
source sourceSets.main
}
}
}
data {
workingDirectory project.file('run')
//property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
property 'forge.logging.console.level', 'debug'
args '--mod', mod_id, '--all',
'--existing', file('src/main/resources'),
'--existing', file('src/generated/resources'),
'--output', file('src/generated/resources')
mods {
armiger {
source sourceSets.main
}
}
}
}
}
// It' i's necessary to add the generated data directory (like below) if you have the generated data output to a different
// location than your normal resource directory (src/main/resources). As I've done in the 'data' section above.
sourceSets.main.resources {
srcDirs += 'src/generated/resources'
}
processResources {
// Exclude datagenerator .cache directory
exclude '.cache'
from(sourceSets.main.resources.srcDirs) {
include 'META-INF/mods.toml'
expand 'mod_version': getVersion(), 'mod_id': mod_id, 'mod_name': mod_name, 'mod_author': mod_author,
'mod_desc': mod_desc, 'mod_url': mod_url, 'issue_url': issue_url, 'update_url': update_url
}
}
jar {
manifest {
attributes([
"Specification-Title": mod_name,
"Specification-Vendor": mod_author,
"Specification-Version": getArchiveName(),
"Implementation-Title": mod_name,
"Implementation-Version": getArchiveName(),
"Implementation-Vendor" : mod_author,
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}
task srcJar(type: Jar) {
from(sourceSets.main.java)
classifier = 'sources'
}
task apiJar(type: Jar) {
// Remove sources from the api jar when MinecraftForge/ForgeGradle#369 is fixed
from(sourceSets.main.allJava)
from(sourceSets.main.output)
include "aurilux/${mod_id}/api/**"
classifier = 'api'
}
artifacts {
archives srcJar, apiJar
}
task updateJson {
doLast {
def updateJsonFile = file('update.json')
def updateJson = new JsonSlurper().parse(updateJsonFile) as Map
updateJson."${minecraft_version}"."${mod_version}" = "See https://www.curseforge.com/minecraft/mc-mods/${mod_id}/files for detailed information."
// Update promos
updateJson.promos."${minecraft_version}-latest" = "${mod_version}"
updateJson.promos."${minecraft_version}-recommended" = "${mod_version}"
updateJsonFile.write(JsonOutput.prettyPrint(JsonOutput.toJson(updateJson)))
}
}
build.dependsOn updateJson
// ApiKey should be stored in an EXTERNAL file - you don't want other people to know it!
// The suggested location is the 'gradle.properties' file inside your gradle user home.
curseforge {
project {
apiKey = findProperty('curse_key') ?: 0
id = "${curse_id}"
releaseType = "release"
changelogType = 'markdown'
changelog = file('changelog.txt')
addArtifact(srcJar)
addArtifact(apiJar)
addGameVersion "${minecraft_version}"
}
options {
debug = true
}
}