-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
113 lines (92 loc) · 2.68 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
buildscript {
repositories {
jcenter()
mavenCentral()
// Minecraft Forge
maven {
name = 'Forge'
url = 'http://files.minecraftforge.net/maven'
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
}
}
apply plugin: 'net.minecraftforge.gradle.forge'
//================================================
// Jar data
// Grab system env
ext.env = System.getenv()
version = mc_ver + "-" + mod_version
ext.in_jenkins = false
// Get Jenkins metadata
ext.jenkinsManifest = manifest {
if (env.BUILD_TAG != null) { // If this works, we'll assume we're in Jenkins atleast.
attributes("Jenkins-Build": "true", "Jenkins-Tag": env.BUILD_TAG, "Jenkins-ID": env.BUILD_ID)
in_jenkins = true
} else {
attributes("Jenkins-Build": "false")
}
}
def branch = null
def hash = null
def proc1 = "git rev-parse --short HEAD".execute()
proc1.in.eachLine { line -> hash = line }
proc1.err.eachLine { line -> println line }
proc1.waitFor()
if (!in_jenkins) {
def proc2 = "git rev-parse --abbrev-ref HEAD".execute()
proc2.in.eachLine { line -> branch = line }
proc2.err.eachLine { line -> println line }
proc2.waitFor()
} else { // In Jenkins
branch = env.GIT_BRANCH.minus("origin/")
}
// If not on master, add branch to jar name
if (branch != null && !branch.equals("master")) {
version += "-" + branch
} else {
//version += "-" + hash
}
// Version tag for jar file name
if (env.BUILD_NUMBER != null) {
version += "-snapshot-" + env.BUILD_NUMBER
}
// Get Git metadata (if in Jenkins)
ext.gitManifest = manifest {
if (branch != null) {
attributes("Git-Branch": branch, "Git-Hash": hash)
}
}
// Setup Forge plugin
minecraft {
version = mc_ver + "-" + forge_ver
runDir = 'run'
mappings = mcp_mappings
replaceIn "openmods/clicky/ClicketyClack.java"
replace '$ACCEPTED_MC_VERSIONS$', mc_version_range
replace '$VERSION$', mod_version
}
processResources {
inputs.property "version", rootProject.mod_version
inputs.property "mc_version", rootProject.mc_ver
// Process mcmod.info
from(sourceSets.main.resources.srcDirs) {
include '**/*.info'
expand 'version':mod_version, 'mc_version':mc_ver
}
// Copy anything else directly
from(sourceSets.main.resources.srcDirs) {
exclude '**/*.info'
}
}
//================================================
// Jar tasks
// Generate FML Coremod manifest
ext.fmlManifest = manifest {}
// Merge Jenkins and Git manifests to form final manifest in final release jar
jar {
manifest {
from jenkinsManifest, gitManifest, fmlManifest
}
}