-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbuild.gradle
162 lines (133 loc) · 3.58 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
buildscript {
apply from: 'versions.gradle'
println "Building for MC ${mc_ver}, version data: ${version_config}"
repositories {
jcenter()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
}
dependencies {
classpath forgegradle_ver
}
}
repositories {
mavenCentral()
maven {
name 'Forge'
url 'http://files.minecraftforge.net/maven'
}
maven {
name 'MinecraftS3'
url 'http://s3.amazonaws.com/Minecraft.Download/libraries'
}
maven {
url 'http://repo.openmods.info/artifactory/openmods'
}
maven {
url 'http://repo.openmods.info/artifactory/thirdparty'
}
}
apply plugin: 'java'
apply plugin: 'net.minecraftforge.gradle.forge'
apply from: 'versions.gradle'
sourceSets {
main {
resources {
srcDirs = ["src/main/resources-${settings_ver}"]
}
}
}
configurations {
shade
compile.extendsFrom shade
}
dependencies {
shade "com.badlogicgames.jlayer:jlayer:1.0.2-gdx"
shade "org.jflac:jflac-codec:1.5.2"
}
// Grab system env
def env = System.getenv()
version = mod_version
def 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
}
// 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 = mappings_ver
replaceIn "NotEnoughCodecs.java"
replace '@VERSION@', mod_version
replace 'ModSettings.Default', "ModSettings.${settings_ver}"
}
processResources
{
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// replace version
expand 'version':project.mod_version
}
// copy everything else, thats not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
}
}
// Merge Jenkins and Git manifests to form final manifest in final release jar
jar {
manifest {
from jenkinsManifest, gitManifest
}
configurations.shade.each { dep ->
from(project.zipTree(dep)){
exclude 'META-INF', 'META-INF/**'
}
}
}
task deobfJar(type: Jar) {
from sourceSets.main.output
classifier = 'deobf'
manifest {
from jenkinsManifest, gitManifest
}
}