This repository has been archived by the owner on Apr 22, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 347
/
Copy pathbuild.gradle
294 lines (252 loc) · 9.46 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
import groovy.json.JsonException
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
// For those who want the bleeding edge
buildscript {
repositories {
mavenCentral()
jcenter()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
maven {
// Required for the curseforge task
name = "gradle"
url "https://plugins.gradle.org/m2/"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
classpath "gradle.plugin.com.matthewprenger:CurseGradle:1.0.7" // Required for the curseforge task
classpath "se.bjurr.gitchangelog:git-changelog-gradle-plugin:1.32"
}
}
repositories {
maven {
// Required for JEI
name 'progwml6'
url 'http://dvs1.progwml6.com/files/maven'
}
maven {
// Required for WAILA
name 'ProfMobius'
url 'http://mobiusstrip.eu/maven'
}
}
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'com.matthewprenger.cursegradle' // Required for the curseforge task
apply plugin: 'se.bjurr.gitchangelog.git-changelog-gradle-plugin'
sourceCompatibility = 1.8
targetCompatibility = 1.8
version = "${minecraft_version}-${mod_version}.${System.getenv("BUILD_NUMBER") ?: 0}"
group = mod_group
archivesBaseName = mod_artifact_basename
minecraft {
version = minecraft_version + "-" + forge_version
runDir = "run"
useDepAts = true // Required for JEI
// Set mod version in code prior to compilation
replaceIn "EquivalentExchange.java"
replace "@MOD_VERSION@", "${mod_version}.${System.getenv("BUILD_NUMBER") ?: 0}"
// Set the jar signature in code prior to compilation, if it exists as a build property
if (project.hasProperty("ee3_sha1_signature")) {
replace "@FINGERPRINT@", project.ee3_sha1_signature
}
// Specify the mcp mappings to use
mappings = mcp_mappings_version
}
dependencies {
deobfCompile "mezz.jei:jei_${minecraft_version}:${dep_jei_version}"
}
processResources {
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
// exclude xcf files, as they are for development only
exclude '**/*.xcf'
// 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
}
// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
task devJar(type: Jar, dependsOn: 'classes') {
from(sourceSets.main.output) {
include '**'
}
extension = 'jar'
classifier = 'dev'
}
artifacts {
archives devJar
}
task signJar(type: SignJar, dependsOn: ["jar", "devJar"]) {
onlyIf {
project.hasProperty('keystore_location')
}
keyStore = project.hasProperty('keystore_location') ? project.getProperty('keystore_location') : "";
storePass = project.hasProperty('keystore_password') ? project.getProperty('keystore_password') : "";
alias = project.hasProperty('ee3_keystore_alias') ? project.getProperty('ee3_keystore_alias') : "";
keyPass = project.hasProperty('keystore_password') ? project.getProperty('keystore_password') : "";
inputFile = jar.archivePath
outputFile = jar.archivePath
}
curseforge {
apiKey = project.hasProperty('ee3_curseforge_apikey') ? project.ee3_curseforge_apikey : ''
project {
id = project.hasProperty('ee3_curseforge_projectid') ? project.ee3_curseforge_projectid : '0'
releaseType = mod_release_type
changelogType = 'text'
changelog = file("build/libs/${project.archivesBaseName}-${project.version}-changelog.txt")
addArtifact devJar
relations {
optionalLibrary 'jei'
}
}
}
/**
* Build the json file that MinecraftForge's Update Checker will use to check for new versions
*
* MinecraftForge Update Checker documentation - http://mcforge.readthedocs.io/en/latest/gettingstarted/autoupdate/
*/
task buildVersionFile {
def minecraftVersion = "${minecraft_version}"
def modVersion = "${mod_version}.${System.getenv("BUILD_NUMBER") ?: 0}"
def isReleaseVersion = project.hasProperty("mod_release_type") && project.property("mod_release_type") == "release"
def fileName = "versions.json"
def remoteUrl = "http://ee.pahimar.com/"
def changelogStatement = "Changelog available at " + remoteUrl + minecraftVersion + "/${project.archivesBaseName}-${project.version}-changelog.txt"
def localUpdateJson = new HashMap()
// Grab the remote file so that we can append new entries to it
try {
def remoteUpdateJson = new JsonSlurper().parse(new URL(remoteUrl + 'update/' + fileName))
if (remoteUpdateJson instanceof Map) {
localUpdateJson.putAll(remoteUpdateJson)
}
}
catch (JsonException e) {}
// Set homepage
localUpdateJson.put("homepage", remoteUrl)
// Add new mod version to the list of mod versions for this version of Minecraft
if (localUpdateJson.get(minecraftVersion) instanceof Map) {
((Map) localUpdateJson.get(minecraftVersion)).put(modVersion, changelogStatement)
}
else {
def modVersionsMap = new HashMap()
modVersionsMap.put(modVersion, changelogStatement)
localUpdateJson.put(minecraftVersion, modVersionsMap)
}
// Add new versions to the promos list
if (localUpdateJson.get("promos") instanceof Map) {
((Map) localUpdateJson.get("promos")).put("latest", modVersion)
((Map) localUpdateJson.get("promos")).put(minecraftVersion + "-latest", modVersion)
if (isReleaseVersion) {
((Map) localUpdateJson.get("promos")).put("recommended", modVersion)
((Map) localUpdateJson.get("promos")).put(minecraftVersion + "-recommended", modVersion)
}
}
else {
def promosMap = new HashMap<String, String>()
promosMap.put("latest", modVersion)
promosMap.put(minecraftVersion + "-latest", modVersion)
if (isReleaseVersion) {
promosMap.put("recommended", modVersion)
promosMap.put(minecraftVersion + "-recommended", modVersion)
}
localUpdateJson.put("promos", promosMap)
}
// Output new versions file
def localUpdateFile = new File(fileName)
if (!localUpdateFile.exists()) {
localUpdateFile.createNewFile()
}
localUpdateFile.setText(JsonOutput.prettyPrint(JsonOutput.toJson(localUpdateJson)))
}
/**
* Generate a changelog file from GitHub commits
*
* See: https://github.com/tomasbjerre/git-changelog-gradle-plugin
*/
task makeChangelog(type: se.bjurr.gitchangelog.plugin.gradle.GitChangelogTask) {
filePath = "changelog.html"
untaggedName = "Current release ${mod_version}"
templateContent = """
<h1>Changelog for Equivalent Exchange 3</h1>
<h2>Version ${mod_version} for Minecraft ${project.minecraft.version}</h2>
<ul>
{{#tags}}
<li><h3>{{name}}</h3>
<hr/>
<ul>
{{#commits}}
<li>{{{message}}}</li>
{{/commits}}
</ul>
{{/tags}}
</ul>
"""
}
uploadArchives {
repositories {
mavenDeployer {
if (project.hasProperty("forgemaven_url")) {
logger.info('Publishing to files server')
repository(url: project.getProperty("forgemaven_url")) {
authentication(userName: project.properties.forgemaven_username ?: "", password: project.properties.forgemaven_password ?: "")
}
}
else {
// local repo folder. Might wanna just use gradle install if you wanna send it to maven-local
repository(url: 'file://localhost/' + project.file('repo').getAbsolutePath())
}
pom {
groupId = project.group
version = project.version
artifactId = project.archivesBaseName
}
pom.project {
name project.archivesBaseName
packaging 'jar'
description 'Equivalent Exchange 3'
url 'https://github.com/pahimar/Equivalent-Exchange-3/'
scm {
url 'https://github.com/pahimar/Equivalent-Exchange-3/'
connection 'scm:git:git://github.com/pahimar/Equivalent-Exchange-3.git'
developerConnection 'scm:git:[email protected]/pahimar/Equivalent-Exchange-3.git'
}
issueManagement {
system 'github'
url 'https://github.com/pahimar/Equivalent-Exchange-3/issues'
}
licenses {
license {
name 'GNU Lesser General Public License 3.0'
url 'https://www.gnu.org/licenses/lgpl-3.0.txt'
distribution 'repo'
}
}
developers {
developer {
id 'Pahimar'
name 'Pahimar'
roles {
role 'developer'
}
}
}
}
}
}
}