-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
339 lines (285 loc) · 10.6 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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
// For those who want the bleeding edge
buildscript {
repositories {
jcenter()
mavenLocal()
mavenCentral()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
maven {
name = "m2"
url = "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
classpath "gradle.plugin.com.selesse:gradle-git-changelog:0.4.0-SNAPSHOT"
}
}
plugins {
id "com.matthewprenger.cursegradle" version "1.0.7"
}
repositories {
mavenLocal()
maven {
name 'ForgeFS'
url 'http://files.minecraftforge.net/maven'
}
maven {
name 'DVS1 Maven FS'
url 'http://dvs1.progwml6.com/files/maven'
}
maven {
name = "SmithsCore"
url = "http://mavenrepo.smithscore.orionminecraft.com/"
}
}
apply plugin: 'java'
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'maven'
apply plugin: 'com.selesse.git.changelog'
sourceCompatibility = 1.8
targetCompatibility = 1.8
//Buildscript: armory
// Load the properties of this project.
ext.configFile = file "build.properties"
//Reference the properties inside the project:
configFile.withReader {
def prop = new Properties()
prop.load(it)
project.ext.config = new ConfigSlurper().parse prop
}
//Date formatting helper function
def getDate() {
def date = new Date()
def formattedDate = date.format('dd-MM-yyyy : hh:mm:ss')
return formattedDate
}
def build_mode = config.build_mode
//These configurations are needed for uploading to a MavenRepo:
configurations {
deployerJars
}
//Initializing the mod environment
version = config.minecraft_version + "-" + config.mod_version.toString() + "-" + System.getenv().TRAVIS_BUILD_NUMBER.toString()
def apiversion = config.api_version.toString() + "-" + System.getenv().TRAVIS_BUILD_NUMBER.toString()
if(System.getenv().TRAVIS_BRANCH.toString().contains("Development"))
{
version = version + "-SNAPSHOT"
apiversion = apiversion + "-SNAPSHOT"
}
group = "com.smithsmodding.armory"
archivesBaseName = "armory"
minecraft {
version = config.minecraft_version + "-" + config.forge_version
runDir = "run"
mappings = "snapshot_20161220"
useDepAts = true
//Replacing stuff inside the code:
replace "@VERSION@", project.version
replace "@MCVERSION@", config.minecraft_version
replace "@APIVERSION@", apiversion
}
dependencies {
//Mod dependencies
deobfCompile group: 'com.smithsmodding.smithscore', name: 'smithscore', version: config.minecraft_version + "-" + config.smithscore_version
deobfCompile "mezz.jei:jei_" + config.minecraft_version + ":" + config.jei_version
//Maven uploader
deployerJars 'org.apache.maven.wagon:wagon-ftp:2.8'
compile 'org.jetbrains:annotations:15.0'
}
sourceSets {
main {
java {
srcDir 'src/main'
}
resources {
srcDir 'src/resources'
}
}
api {
java {
srcDir 'src/api'
}
}
}
// Add API dir to the IDEA module
idea.module.sourceDirs += sourceSets.api.java.srcDirs
//This will process all the resources used during build, and needed for running the project
processResources
{
//Replaces 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'
}
exclude '**/Thumbs.db'
}
jar {
manifest {
attributes 'FMLAT': 'Armory_at.cfg'
}
from sourceSets.main.output
from sourceSets.api.output
}
javadoc {
source += sourceSets.api.allSource
}
// add a javadoc jar
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from 'build/docs/javadoc'
}
task apiJar(type: Jar) {
from sourceSets.api.output
classifier = 'api'
}
artifacts {
archives javadocJar
archives apiJar
}
changelog {
title = "${project.name} - Changelog"
outputDirectory = file("$projectDir")
fileName = "changelog.html"
since = 'last_tag'
formats = ['html', 'markdown']
commitFormat = '%s (%an)'
includeLines {
!it.contains("Merge ") && !it.contains("Sync")
}
markdown {
commitFormat = '* %s (%an)'
}
html {
template = file("$projectDir/sample-html.tpl").text
}
}
curseforge {
if (System.getenv().CURSEAPIKEY != null) {
if (!build_mode.toString().trim().equals("SYNC")) {
if ((build_mode.toString().trim().equals("DEBUG") && System.getenv().TRAVIS_BRANCH.toString().contains("Development")) || ((build_mode.toString().trim().equals("RELEASE") && !System.getenv().TRAVIS_BRANCH.toString().contains("Development")))) {
apiKey = System.getenv().CURSEAPIKEY
project {
id = '231229'
changelog = file('changelog.html')
changelogType = 'html'
if (System.getenv().TRAVIS_BRANCH.toString().contains("Development")) {
releaseType = "alpha"
} else {
releaseType = "beta"
}
relations {
requiredLibrary 'smithscore' // SmithScore is required
}
//TOTO: When API ready add here, as well as DevJar and JavaDocJar.
}
} else {
logger.lifecycle("Cannot run the CurseUpload sequence. Curse upload is only done on the Development-Branch when in Debug mode, or on any other branch in Release mode. Current Branch: " + System.getenv().TRAVIS_BRANCH.toString() + " - Current build mode: " + build_mode.toString())
}
} else {
logger.lifecycle("Cannot run CurseUpload sequence. We are currently synchronising to Computers.")
}
} else {
logger.lifecycle("Cannot run the CurseUpload sequence. No API-Key was available.")
}
}
//Function to upload completed project to the maven repo.
uploadArchives {
repositories.mavenDeployer {
configuration = configurations.deployerJars
if (System.getenv().TRAVIS_BRANCH.toString().contains("Development")) {
snapshotRepository(url: "ftp://mavenrepo.armory.orionminecraft.com") {
authentication(userName: "mavenrepo.armory.orionminecraft.com|" + System.getenv().FTPUserName.toString(), password: System.getenv().FTPPassword.toString())
}
} else {
repository(url: "ftp://mavenrepo.armory.orionminecraft.com") {
authentication(userName: "mavenrepo.armory.orionminecraft.com|" + System.getenv().FTPUserName.toString(), password: System.getenv().FTPPassword.toString())
}
}
pom {
groupId = project.group
version = project.version
artifactId = project.archivesBaseName
}
pom.project {
name project.archivesBaseName
packaging 'jar'
description 'Armory'
url 'https://github.com/smithsmodding/armory'
scm {
url 'https://github.com/smithsmodding/smithscore'
connection 'scm:git:git://github.com/smithsmodding/armory.git'
developerConnection 'scm:git:[email protected]/smithsmodding/armory.git'
}
issueManagement {
system 'github'
url 'https://github.com/smithsmodding/armory/issues'
}
developers {
developer {
id 'OrionDevelopment'
name 'Orion'
roles {
role 'developer'
}
}
}
}
}
}
task checkOutLocalMinecraftBranch(type: Exec) {
commandLine "git", "checkout", "-b", "Minecraft-" + config.minecraft_version.toString()
}
task gitSetEmail(type: Exec) {
commandLine "git", "config", "user.email", "[email protected]"
}
task gitSetName(type: Exec) {
commandLine "git", "config", "user.name", "Travic CI For Smithsmodding"
}
task configRemoteGit(type: Exec) {
commandLine "git", "config", "remote.origin.url", "https://" + System.getenv().GitUsername.toString() + ":" + System.getenv().GitPassword.toString() + "@github.com/SmithsGaming/Armory"
}
task createVersionTag(type: Exec) {
commandLine "git", "tag", "-a", version, "-m", "'Autobuild by Travis CI. Build on: " + getDate() + ".'"
}
task pushGitChanges(type: Exec) {
commandLine "git", "push", "origin", "-f", "Minecraft-" + config.minecraft_version.toString(), "--quiet"
}
task pushGitTags(type: Exec) {
commandLine "git", "push", "--tags", "--quiet"
}
gitSetEmail.mustRunAfter checkOutLocalMinecraftBranch
gitSetName.mustRunAfter gitSetEmail
configRemoteGit.mustRunAfter gitSetName
createVersionTag.mustRunAfter configRemoteGit
pushGitChanges.mustRunAfter createVersionTag
pushGitTags.mustRunAfter pushGitChanges
task createGithubBranches() {
if ((System.getenv().TRAVIS_BRANCH.toString().contains("Development")) && (build_mode.toString().trim().equals("RELEASE"))) {
logger.lifecycle("Configuring upload to git.")
dependsOn checkOutLocalMinecraftBranch, gitSetName, gitSetEmail, configRemoteGit, pushGitChanges
logger.lifecycle("Configuration complete. Current MC Version: " + config.minecraft_version.toString() + ". Branch name: Minecraft-" + config.minecraft_version.toString() + ".")
} else if ((System.getenv().TRAVIS_BRANCH.toString().contains("Minecraft")) && (build_mode.toString().trim().equals("RELEASE"))) {
logger.lifecycle("Configuring version marking on git.")
dependsOn gitSetName, gitSetEmail, configRemoteGit, createVersionTag, pushGitTags
logger.lifecycle("Configuration complete. Current MC Version: " + config.minecraft_version.toString() + ". Branch name: Minecraft-" + config.minecraft_version.toString() + ".")
} else {
logger.lifecycle("The sync of the branches is not being executed, because we are not releasing a new version.")
}
}
//The external task that executes the uploadAtchives function.
task('uploadJars', dependsOn: uploadArchives) {
description = "uploads JARs"
}