forked from OpenCubicChunks/CubicChunks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
291 lines (257 loc) · 7.91 KB
/
build.gradle
File metadata and controls
291 lines (257 loc) · 7.91 KB
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
// Gradle repositories and dependencies
buildscript
{
repositories {
mavenCentral()
jcenter()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
maven {
name = 'sponge'
url = 'http://repo.spongepowered.org/maven'
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.2-SNAPSHOT'
classpath 'org.ajoberstar:grgit:1.4.+'
classpath 'org.spongepowered:mixingradle:0.3-SNAPSHOT'
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.3'
}
}
plugins {
id "java"
id "com.github.hierynomus.license" version "0.11.0"
id "eclipse"
id "idea"
id 'com.github.johnrengelman.shadow' version '1.2.3'
}
apply plugin: 'net.minecraftforge.gradle.forge'
apply plugin: 'org.spongepowered.mixin'
idea { module { inheritOutputDirs = true } }
defaultTasks 'licenseFormat', 'build'
// Minimum version of Java required
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
mixin {
add sourceSets.main, "cubicchunks.mixins.refmap.json"
//add sourceSets.main,
}
repositories {
mavenCentral()
maven {
name = 'sponge'
url = 'http://repo.spongepowered.org/maven'
}
}
ext {
//used for license header
projectName = 'Cubic Chunks Mod'
inceptionYear = '2015'
}
group = "cubichunks"
archivesBaseName = "CubicChunks"
version = getModVersionAndWriteToFile()
minecraft {
version = "1.10.2-12.18.1.2092"
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 always work.
// simply re-run your setup task after changing the mappings to update your workspace.
mappings = "snapshot_20160918"
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
replace "@@VERSION@@", project.version
replaceIn "cubicchunks/CubicChunks.java"
}
shadowJar {
//MapDB stuff
relocate 'org.mapdb', 'cubicchunks.org.mappdb'
relocate 'kotlin', 'cubicchunks.org.mappdb.com.google'
relocate 'net.jcip', 'cubicchunks.org.mappdb.net.jcip'
relocate 'org.eclipse.collections', 'cubicchunks.org.mappdb.org.eclipse.collections'
relocate 'net.jpountz', 'cubicchunks.org.mappdb.net.jpountz'
//MapDB natives. Will it work?
relocate 'win32', 'cubicchunks.org.mappdb.win32'
relocate 'linux', 'cubicchunks.org.mappdb.linux'
relocate 'darwin', 'cubicchunks.org.mappdb.darwin'
relocate 'com.flowpowered', 'cubicchunks.com.flowpowered'
/*
Mixin shouldn't be relocated. Mixin dependencies:
org.spongepowered:mixin:0.5.5-SNAPSHOT
+--- org.slf4j:slf4j-api:1.7.7
+--- commons-codec:commons-codec:1.9
+--- org.ow2.asm:asm-commons:5.0.3
| \--- org.ow2.asm:asm-tree:5.0.3
| \--- org.ow2.asm:asm:5.0.3
+--- commons-io:commons-io:2.4
\--- com.googlecode.jarjar:jarjar:1.1
*/
classifier = ''
}
reobf {
shadowJar { mappingType = 'SEARGE' }
}
tasks.build.dependsOn reobfShadowJar
jar {
exclude 'LICENSE.txt'
}
test {
systemProperty "org.spongepowered.test.launch.tweaker", "cubicchunks.tweaker.MixinTweakerServer"
}
// Project repositories
repositories {
mavenCentral()
jcenter()
maven
{
name 'sonatype'
url 'https://oss.sonatype.org/content/groups/public/'
}
}
dependencies {
compile 'com.flowpowered:flow-noise:1.0.1-SNAPSHOT'
compile('org.mapdb:mapdb:3.0.0-RC2'){
exclude module: 'guava'
}
testCompile 'junit:junit:4.11'
testCompile 'org.hamcrest:hamcrest-junit:2.0.0.0'
testCompile 'org.mockito:mockito-core:2.1.0-RC.2'
testCompile 'org.spongepowered:launchwrappertestsuite:1.0-SNAPSHOT'
compile('org.spongepowered:mixin:0.5.11-SNAPSHOT') {
exclude module: 'launchwrapper'
exclude module: 'guava'
exclude module: 'gson'
}
compile group: 'com.carrotsearch', name: 'hppc', version: '0.7.1'
}
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 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'
}
}
// License header formatting
license {
ext.project = projectName
ext.year = inceptionYear
exclude "**/*.info"
exclude "**/package-info.java"
exclude "**/*.json"
exclude "**/*.xml"
exclude "assets/*"
exclude "cubicchunks/server/chunkio/async/forge/*" // Taken from forge
header file('HEADER.txt')
ignoreFailures false
strictCheck true
mapping {
java = 'SLASHSTAR_STYLE'
}
}
jar {
manifest {
attributes 'FMLAT': 'cubicchunks_at.cfg'
attributes 'FMLCorePlugin': 'cubicchunks.asm.CubicChunksCoreMod'
attributes 'TweakClass': 'org.spongepowered.asm.launch.MixinTweaker'
attributes 'TweakOrder': '0'
attributes 'ForceLoadAsMod': 'true'
}
}
idea {
module {
downloadJavadoc = true
downloadSources = true
}
}
//returns version string according to this: http://mcforge.readthedocs.org/en/latest/conventions/versioning/
//format: MCVERSION-MAJORMOD.MAJORAPI.MINOR.PATCH(-final/rcX/betaX)
//rcX and betaX are not implemented yet
private String getModVersion(String describe, String branch) {
String branchSuffix = "";
if(!branch.equalsIgnoreCase("master")) {
//remove invalid filename characters
branchSuffix = "-" + branch.replaceAll("[^a-zA-Z0-9.-]", "_");
}
final String baseVersionRegex = "v[0-9]+\\.[0-9]+";
final String unknownVersion = String.format("%s-UNKNOWN_VERSION%s%s", mcVersion, versionSuffix, branchSuffix);
if (!describe.contains('-')) {
//is it the "vX.Y" format?
if (describe.matches(baseVersionRegex)) {
return String.format("%s-%s.0.0%s%s", mcVersion, describe, versionSuffix, branchSuffix);
}
logger.error("Git describe information: \"" + describe + "\" in unknown/incorrect format");
return unknownVersion;
}
//Describe format: vX.Y-build-hash
String[] parts = describe.split("-");
if (!parts[0].matches(baseVersionRegex)) {
logger.error("Git describe information: \"" + describe + "\" in unknown/incorrect format");
return unknownVersion;
}
if (!parts[1].matches("[0-9]+")) {
logger.error("Git describe information: \"" + describe + "\" in unknown/incorrect format");
return unknownVersion;
}
String mcVersion = mcVersion;
String modAndApiVersion = parts[0].substring(1);
//next we have commit-since-tag
int commitSinceTag;
commitSinceTag = Integer.parseInt(parts[1]);
int minor;
int patch;
int minorFreeze = -1;
if (!(versionMinorFreeze == null || versionMinorFreeze.isEmpty())) {
minorFreeze = Integer.parseInt(versionMinorFreeze);
}
if (minorFreeze < 0) {
minor = commitSinceTag;
patch = 0;
} else {
minor = minorFreeze;
patch = commitSinceTag - minorFreeze;
}
String version = String.format("%s-%s.%d.%d%s%s", mcVersion, modAndApiVersion, minor, patch, versionSuffix, branchSuffix);
return version;
}
private String getModVersionAndWriteToFile() {
def git;
try {
git = org.ajoberstar.grgit.Grgit.open(file('.'))
} catch(org.eclipse.jgit.errors.RepositoryNotFoundException ex) {//TODO: Is there better way to check if the repository can be opened?
logger.error("Git repository not found! Version will be incorrect!");
return getModVersion("", "master");
}
String describe = git.describe();
String branch = git.getBranch().getCurrent().getName();
String version = getModVersion(describe, branch)
//write to file
File file = new File("VERSION");
PrintWriter pw = null;
try {
if(file.exists()) {
file.delete();
}
file.createNewFile();
pw = new PrintWriter(new FileOutputStream(file));
pw.println("VERSION=" + version);
} catch(IOException ex) {
ex.printStackTrace();
} finally {
if(pw != null) {
try{pw.close()}catch(IOException ex){}
}
}
return version;
}