-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
250 lines (211 loc) · 8.19 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
//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:2.2-SNAPSHOT'
}
}
plugins {
id "com.matthewprenger.cursegradle" version "1.0.7"
id "se.bjurr.gitchangelog.git-changelog-gradle-plugin" version "1.34"
}
//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/'
}
maven { //My own repo (used for uploading and dependency)
name 'SmithsMavenRepo'
url 'http://mavenrepo.smithscore.orionminecraft.com/'
}
}
//Apply the gradle plugins.
apply plugin: 'java'
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'maven'
//Buildscript: weaponry
// 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
sourceCompatibility = 1.8
targetCompatibility = 1.8
//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.smithsmodding.armory.weaponry"
archivesBaseName = "Armory-Weaponry"
//IDea fix for
idea {
module {
inheritOutputDirs = true
}
}
//Sets up the currect versions for minecraft and Forge
minecraft {
version = config.minecraft_version + "-" + config.forge_version
runDir = "run"
mappings = "snapshot_20160518"
useDepAts = true
//Replacing stuff inside the code:
replace "@VERSION@", project.version
replaceIn "weaponry.java"
}
//Tells gradle which dependencies are needed for gradle and project
dependencies {
//Mod dependencies
deobfCompile group: 'com.smithsmodding.smithscore', name: 'smithscore', version: config.minecraft_version + "-" + config.smithscore_version, classifier: 'dev'
deobfCompile "mezz.jei:jei_" + config.minecraft_version + ":" + config.jei_version
compile "com.SmithsModding.Armory:Armory:" + config.minecraft_version + "-" + config.armory_version + ":api"
deobfCompile "slimeknights.mantle:Mantle:${config.minecraft_version}-${config.mantle_version}"
deobfCompile "slimeknights:TConstruct:${config.minecraft_version}-${config.tconstruct_version}"
runtime "com.SmithsModding.Armory:Armory:" + config.minecraft_version + "-" + config.armory_version
//Maven uploader
deployerJars 'org.apache.maven.wagon:wagon-ftp:2.2'
}
sourceSets {
main {
java {
srcDir 'src/main'
}
resources {
srcDir 'src/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'
}
}
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 = '231236'
changelog = ''
changelogType = 'text'
if (System.getenv().TRAVIS_BRANCH.toString().contains("Development")) {
releaseType = "alpha"
} else {
releaseType = "beta"
}
relations {
requiredLibrary 'smithscore' // SmithScore is required
requiredLibrary 'armory-armoring-the-world'
requiredLibrary 'tinkers-construct'
}
}
} 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.")
}
}
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/Weaponry"
}
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, createVersionTag, pushGitChanges, 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"
}