-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathbuild.gradle
executable file
·307 lines (262 loc) · 9.97 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
// DON'T TOUCH THE BUILDSCRIPT[] BLOCK
// its special, and it is only there to make ForgeGradle work correctly.
buildscript {
repositories {
mavenCentral()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT"
classpath "org.ajoberstar:grgit:2.2.1"
}
}
apply plugin: "net.minecraftforge.gradle.forge" // adds the forge dependency
apply plugin: "maven" // for uploading to a maven repo
apply plugin: 'maven-publish' // for uploading to a maven repo
apply plugin: "org.ajoberstar.grgit"
ext.configFile = file "build.properties"
configFile.withReader {
// Load config. It shall from now be referenced as simply config or project.config
def prop = new Properties()
File cfg2 = file "BuildCraft/build.properties"
cfg2.withReader {
prop.load(it)
}
prop.load(it)
project.ext.config = new ConfigSlurper().parse prop
}
version = config.compat_version
group = "com.mod-buildcraft-compat"
archivesBaseName = "buildcraft" // the name that all artifacts will use as a base. artifacts names follow this pattern: [baseName]-[appendix]-[version]-[classifier].[extension]
ext {
compatModInfo = new groovy.json.JsonSlurper().parse(file("resources/mcmod.info"))
mainModInfo = new groovy.json.JsonSlurper().parse(file("BuildCraft/buildcraft_resources/mcmod.info"))
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
maven { name="JEI"; url="http://dvs1.progwml6.com/files/maven" }
maven { name="TOP"; url="http://maven.tterrag.com/" }
maven { name="hwyla"; url="http://tehnut.info/maven" }
// The One probe depends on the RF API -- we don't use it ourselves, nor will we ever add compat for it...
maven { name="cofh"; url="http://maven.covers1624.net" }
maven { name="forestry"; url = "http://maven.ic2.player.to/" }
maven { name "CraftTweaker"; url "http://maven.blamejared.com/" }
}
dependencies {
// JEI Stuff
// Versions from http://minecraft.curseforge.com/projects/just-enough-items-jei/files
compileOnly "mezz.jei:jei_${config.mc_version}:${config.jei_version}:api"
runtime "mezz.jei:jei_${config.mc_version}:${config.jei_version}"
// The One Probe Stuff
compileOnly "mcjty.theoneprobe:TheOneProbe-1.12:${config.top_version}:api"
runtime "mcjty.theoneprobe:TheOneProbe-1.12:${config.top_version}"
// The One Probe depends on the RF api for some odd reason... we never intend to add support for RF ourselves though.
// HWYLA
compileOnly "mcp.mobius.waila:Hwyla:${config.hwyla_version}:api"
runtime "mcp.mobius.waila:Hwyla:${config.hwyla_version}"
// Forestry
deobfCompile "net.sengir.forestry:forestry_${config.mc_version}:${config.forestry_version}"
deobfCompile "net.industrial-craft:industrialcraft-2:${config.ic2_version}"
// CraftTweaker
deobfCompile "CraftTweaker2:CraftTweaker2-API:${config.crafttweaker_version}"
deobfCompile "CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-${config.crafttweaker_version}"
}
minecraft {
version = config.mc_version + "-" + config.forge_version
runDir = "run"
// the mappings can be changed at any time, and must be in the following format.
// snapshot_YYYYMMDD snapshot are built nightly.
// stable_# stables are built at the discretion of the MCP team.
// Use non-default mappings at your own risk. they may not allways work.
// simply re-run your setup task after changing the mappings to update your workspace.
mappings = config.mappings_version
useDepAts = true
def separate = Boolean.getBoolean("build_compat_only")
if (separate) {
project.version = config.compat_version
} else {
project.version = config.mod_version;
}
def addVersionDetails = !Boolean.getBoolean("release")
// Git versioning stuffs
if (grgit != null) {
def repo = grgit.open(dir: project.rootDir)
replace "\${git_commit_hash}", repo.head().id
replace "\${git_commit_msg}", repo.head().fullMessage.replace("\"", "\\\\\\\"").split("\n")[0]
replace "\${git_commit_author}", repo.head().author.name
replace "\${git_branch}", repo.branch.current().getName()
if (addVersionDetails) {
project.version += "-" + repo.head().id.toString().substring(0, 12)
}
} else {
if (addVersionDetails) {
project.version += "-SNAPSHOT"
}
}
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
// replacing stuff in the source
replace "\$version", project.version
replace "\${mcversion}", version
// Replace @Mod.acceptedMinecraftVersions specially as it has to be a valid version in a dev environment :/
replace "(gradle_replace_mcversion,)", "[" + version + "]"
replace "(gradle_replace_forgeversion,)", "[" + config.forge_version + ",)"
replace "\$bc_version", config.mod_version
useDepAts = true
}
compileJava {
options.compilerArgs << "-Xmaxerrs" << "2000"
options.compilerArgs << "-Xmaxwarns" << "2"
options.compilerArgs << "-Xlint:all"
options.compilerArgs << "-Xdiags:verbose"
options.compilerArgs << "-encoding" << "UTF-8"
}
javadoc {
options.setUse(true)
options.addStringsOption("Xmaxerrs").setValue(["2000"])
options.addStringsOption("Xmaxwarns").setValue(["2000"])
options.addStringsOption("Xdoclint:all")
options.setEncoding("UTF-8")
}
task setupSubProjects(dependsOn: "BuildCraft:sub_projects:expression:generateSources") {
// Just an inter-dependency task
}
eclipseClasspath.dependsOn setupSubProjects
ideaModule.dependsOn setupSubProjects
compileApiJava.dependsOn setupSubProjects
// configure the source folders
sourceSets {
api {
java {
srcDir "BuildCraft/BuildCraftAPI/api"
srcDir "BuildCraft/common"
srcDir "BuildCraft/sub_projects/expression/src/main/java"
srcDir "BuildCraft/sub_projects/expression/src/autogen/java"
}
resources {
srcDir "BuildCraft/buildcraft_resources"
srcDir "BuildCraft/BuildCraftGuide/guide_resources"
exclude "pack.png" // exclude from the guide repo
exclude "pack.mcmeta" // exclude from the guide repo
}
}
main {
java {
srcDir "common"
}
resources {
srcDir "resources"
}
}
}
// Obfuscated Jar location
ext.jarFile = zipTree(jar.archivePath)
processResources {
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// replace version and mcversion
// ${version} and ${mcversion} are the exact strings being replaced
expand 'version': project.version, 'mcversion': project.minecraft.version, 'modid': config.modid
}
// copy everything else, that's not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
exclude 'pack.mcmeta'
exclude 'pack.png'
}
}
def createAllModInfo() {
return new File("$projectDir/build/processing/compat-all/mcmod.info")
}
task writeAllModInfo() {
outputs.upToDateWhen { false }
doLast {
File temp = createAllModInfo()
temp.parentFile.mkdirs()
if (temp.exists())
temp.delete()
temp.createNewFile()
def elements = [];
for (int i = 0; i < mainModInfo.size(); i++) {
elements += mainModInfo[i];
}
elements += compatModInfo[0];
String prettyPrinted = groovy.json.JsonOutput.prettyPrint(groovy.json.JsonOutput.toJson(elements))
prettyPrinted = prettyPrinted.replace("\$version", project.version)
prettyPrinted = prettyPrinted.replace("\${mcversion}", project.minecraft.version)
temp.write(prettyPrinted)
return temp
}
}
def unzippedSourceJar = new File("$projectDir/build/processing/tasks/unzipped_src_jar/unzip")
def libsDir = new File(System.getenv("LIBS_DIR") ?: "build/libs/", project.version)
def modulesDir = new File(libsDir, "modules")
// forge (or gradle?) creates a special sourceJar which has been processed
// This task unzips that created jar, so that partial source jars can be created.
task unzipSourceJar(type: Copy, dependsOn: sourceJar) {
from (zipTree(sourceJar.archivePath)) {
include "**"
}
into unzippedSourceJar
}
task compatJar(type: Jar, dependsOn:reobfJar) {
destinationDir = modulesDir
appendix = "compat"
version = project.version
from(project.ext.jarFile) {
includes.addAll("**")
}
}
task allJar(type: Jar, dependsOn: [reobfJar, writeAllModInfo]) {
destinationDir = libsDir
appendix = "all"
version = project.version
from(createAllModInfo().parentFile)
from(project.ext.jarFile) {
includes.addAll("**")
exclude("mcmod.info")
}
}
task allSrcJar(type: Jar, dependsOn:[reobfJar, writeAllModInfo, unzipSourceJar]) {
destinationDir = libsDir
appendix = "all"
classifier = "sources"
from(createAllModInfo().parentFile)
from(unzippedSourceJar) {
includes.add("**")
exclude("mcmod.info")
}
}
build.dependsOn compatJar, allJar, allSrcJar
publishing {
repositories {
maven {
url System.getenv("MAVEN_DIR") ?: "$projectDir/build/maven"
}
}
publications {
pub_allJar(MavenPublication) {
groupId "com.mod-buildcraft"
artifactId "buildcraft-all"
version project.version
artifact allJar
}
pub_apiSrcJar(MavenPublication) {
groupId "com.mod-buildcraft"
artifactId "buildcraft-all"
version project.version
artifact allSrcJar
}
}
}