-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
285 lines (247 loc) · 9.47 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
//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_file = new File("build_mode.properties")
def build_mode = build_file.text
//ForgeGradle BuildScript.
buildscript {
repositories {
mavenCentral()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT'
}
}
//The repositories in which the dependencies are stored:
repositories {
mavenCentral()
maven { // The repo from which to get waila
name "Mobius Repo"
url "http://mobiusstrip.eu/maven"
}
maven { //The repo to get NEI etc
name 'CB FS'
url 'http://chickenbones.net/maven'
}
maven { //The repo to get TiC
name 'DVS1 Maven FS'
url 'http://dvs1.progwml6.com/files/maven'
}
maven { //Forges own repo
name 'ForgeFS'
url 'http://files.minecraftforge.net/maven'
}
maven { //My own repo (used for uploading and dependency)
name 'OrionMavenRepo'
url 'http://mavenrepo.armory.orionminecraft.com/'
}
}
//Apply the gradle plugins.
apply plugin: 'forge'
apply plugin: 'maven'
apply plugin: 'curseforge'
//These configurations are needed for uploading to a MavenRepo:
configurations {
deployerJars
}
//Initializing the mod environment
version = config.mod_version.toString() + "-" + System.getenv().TRAVIS_BUILD_NUMBER.toString()
if(System.getenv().TRAVIS_BRANCH.toString().contains("Development"))
{
version = version + "-SNAPSHOT"
}
group= "com.Orion.Armory.World"
archivesBaseName = "Armory-World"
//IDea fix for
idea {
module {
inheritOutputDirs = true
}
}
//Sets up the currect versions for minecraft and Forge
minecraft {
version = config.forge_version.toString() + "-" + config.minecraft_version
runDir = "run/assets"
//Replacing stuff inside the code:
replace "@VERSION@", project.version
replaceIn "World.java"
}
//Tells gradle which dependencies are needed for gradle and project
dependencies {
//Mod dependencies
compile "com.SmithsModding.Armory:Armory:"+ config.armory_version
compile "mantle:Mantle:${config.minecraft_version}-${config.mantle_version}:deobf"
compile "tconstruct:TConstruct:${config.minecraft_version}-${config.tconstruct_version}:deobf"
//Maven uploader
deployerJars 'org.apache.maven.wagon:wagon-ftp:2.2'
}
sourceSets {
main {
java {
srcDir 'src/Armory/World'
}
resources {
srcDir 'resources'
}
}
}
//This will process all the resources used during build, and needed for running the project
processResources
{
//This will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
//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'
}
}
//The following function comes with thanks to AbrarSyed:
//Copying the coremod dependencies from the classpath to the mods directory so the system can load them in a Dev Env.
//This is not executed during build!
task copyChicken(type: Copy){
from configurations.compile
include "**/*Chicken*.jar", "**/*NotEnoughItems*.jar"
exclude "**/CodeChickenLib*" // because CCC downloads it anyways.. -_-
into file(minecraft.runDir + "/mods") // parallel to the assets dir
}
curse {
dependsOn 'reobf'
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"))))
{
projectId = System.getenv().CURSEPROJECTID
apiKey = System.getenv().CURSEAPIKEY
changelog = "Check out: " + "https://github.com/" + System.getenv().TRAVIS_REPO_SLUG.toString() + "/commits/" + System.getenv().TRAVIS_BRANCH.toString() + " for all Changes."
if (System.getenv().TRAVIS_BRANCH.toString().contains("Development"))
{
releaseType = "Alpha"
}
else
{
releaseType = "Beta"
}
relatedProject 'armory-armoring-the-world'
}
else
{
logger.lifecycle("Cannor 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.orionminecraft.com"){
authentication(userName: "mavenrepo.orionminecraft.com|" + System.getenv().FTPUserName.toString(), password: System.getenv().FTPPassword.toString())
}
}
else {
repository(url: "ftp://mavenrepo.orionminecraft.com") {
authentication(userName: "mavenrepo.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/World'
scm {
url 'https://github.com/SmithsModding/World'
connection 'scm:git:git://github.com/SmithsModding/World.git'
developerConnection 'scm:git:git@github.com/SmithsModding/World.git'
}
issueManagement {
system 'github'
url 'https://github.com/SmithsModding/World/issues'
}
developers {
developer {
id 'OrionDevelopment'
name 'Orion'
roles {
role 'developer'
}
}
}
}
}
}
task('createGithubBranches') << {
if ((System.getenv().TRAVIS_BRANCH.toString().contains("Development")) && (build_mode.toString().trim().equals("RELEASE")))
{
logger.lifecycle("Uploading code to the corresponding Minecraft version branch. Creating branch if needed.")
logger.lifecycle("Creating local branch.")
//Creates/Or checks out the new local branch.
def createLocalBranchCMD = "git checkout -b Minecraft-" + config.minecraft_version.toString()
def createLocalProg = createLocalBranchCMD.execute();
createLocalProg.waitFor()
//Adds a tag to the minecraft version specific branch for the version number.
logger.lifecycle("Adding version tag.")
def addTagCMD = "git -a Version[" + version + "] -m 'Autobuild by Travis CI. Build on: " + getDate() + ".'"
def addTagProg = addTagCMD.execute()
addTagProg.waitFor()
logger.lifecycle("Uploading force push to repo.")
def setUrlCMD = "git config remote.origin.url https://" + System.getenv().GitUsername.toString() + ":" + System.getenv().GitPassword.toString() + "@github.com/SmithsModding/World"
def setURLProg = setUrlCMD.execute()
setURLProg.waitFor()
def cmd = "git push origin -f Minecraft-" + config.minecraft_version.toString()
def prog = cmd.execute()
prog.waitFor()
logger.lifecycle("Mirrored the code the corresponding minecraft version branch. 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"
}