forked from SmithsGaming/SmithsCore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
323 lines (272 loc) · 10.2 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
buildscript{
repositories {
jcenter()
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"
}
repositories {
mavenLocal()
maven {
name 'ForgeFS'
url 'http://files.minecraftforge.net/maven'
}
maven {
name 'DVS1 Maven FS'
url 'http://dvs1.progwml6.com/files/maven'
}
}
apply plugin: 'java'
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'maven'
sourceCompatibility = 1.8
targetCompatibility = 1.8
//Buildscript: SmithsCore
// 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.toString() + "-" + config.mod_version.toString() + "-" + System.getenv().TRAVIS_BUILD_NUMBER.toString()
def apiversion = config.minecraft_version.toString() + "-" + config.api_version.toString() + "-" + System.getenv().TRAVIS_BUILD_NUMBER.toString()
if(System.getenv().TRAVIS_BRANCH.toString().contains("Development"))
{
version = version + "-SNAPSHOT"
apiversion = apiversion + "-SNAPSHOT"
}
if(System.getenv().TRAVIS_BRANCH.toString().toLowerCase().contains("master") && config.build_mode.toString().trim().equals("RELEASE"))
{
version = version + "-RC"
apiversion = apiversion + "-RC"
}
group = "com.smithsmodding.smithscore"
archivesBaseName = "smithscore"
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 "mezz.jei:jei_" + config.minecraft_version + ":" + config.jei_version
//Maven uploader
deployerJars 'org.apache.maven.wagon:wagon-ftp:2.8'
}
sourceSets {
main {
java {
srcDir 'src'
}
resources {
srcDir 'resources'
}
}
}
//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': 'SmithsCore_at.cfg'
}
}
task devJar(type: Jar, dependsOn: 'classes') {
from(sourceSets.main.output) {
include '**'
}
extension = 'jar'
classifier "dev"
}
task javadocJar(type: Jar, dependsOn: 'javadoc') {
from "build/docs/javadoc"
classifier "javadoc"
}
artifacts {
archives devJar
archives javadocJar
}
task makeChangelog(type: se.bjurr.gitchangelog.plugin.gradle.GitChangelogTask) {
filePath = "changelog.html"
untaggedName = "Current release ${project.version}"
templateContent = """
Alpha version, still buggy. Do not create a world you care about with this version, it can and will break things severely.<br/>
Please help the project by trying it out and <a href="https://github.com/SmithsModding/SmithsCore/issues">reporting issues here.</a><br/>
{{#tags}}
<h3>{{name}}</h3>
<ul>
{{#commits}}
<li>{{{message}}} - {{authorName}}</li>
{{/commits}}
</ul>
{{/tags}}
"""
}
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 = '246525'
changelog = file('changelog.html')
changelogType = 'html'
if (System.getenv().TRAVIS_BRANCH.toString().contains("Development")) {
releaseType = "alpha"
} else {
releaseType = "beta"
}
addArtifact devJar
addArtifact javadocJar
}
}
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.smithscore.orionminecraft.com") {
authentication(userName: "mavenrepo.smithscore.orionminecraft.com|" + System.getenv().FTPUserName.toString(), password: System.getenv().FTPPassword.toString())
}
} else {
repository(url: "ftp://mavenrepo.smithscore.orionminecraft.com") {
authentication(userName: "mavenrepo.smithscore.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 'smithscore'
url 'https://github.com/smithsmodding/smithscore'
scm {
url 'https://github.com/smithsmodding/smithscore'
connection 'scm:git:git://github.com/smithsmodding/smithscore.git'
developerConnection 'scm:git:[email protected]/smithsmodding/smithscore.git'
}
issueManagement {
system 'github'
url 'https://github.com/smithsmodding/smithscore/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/SmithsCore"
}
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"
}