-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
133 lines (108 loc) · 3.15 KB
/
build.gradle
File metadata and controls
133 lines (108 loc) · 3.15 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
// specify repositories and dependencies
buildscript {
repositories {
jcenter()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
}
dependencies {
classpath "net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT"
}
}
// apply plugins
apply plugin: project.mcVersion.equals("1.7.10") ? "forge" : "net.minecraftforge.gradle.forge"
// set java version
sourceCompatibility = project.javaVersion
targetCompatibility = project.javaVersion
version=getVersionFromJava(file("src/main/java/" + project.modClass))
group=project.name.toLowerCase()
archivesBaseName = project.name + "-" + project.mcVersion
// source directories
sourceSets {
main {
java { srcDirs = ["$projectDir/src/main/java"] }
resources { srcDirs = ["$projectDir/src/main/resources"] }
}
}
jar {
manifest {
attributes 'FMLCorePlugin': 'coolsquid.eventtimer.asm.EventTimerPlugin'
attributes 'FMLCorePluginContainsFMLMod': 'true'
}
}
// set forge version and mappings
minecraft {
version = project.mcVersion + "-" + project.forgeVersion
runDir = "run"
mappings = project.mappings
}
repositories {
maven {
url "http://www.ryanliptak.com/maven/"
}
}
// include all files in /libs as dependencies
dependencies {
compile fileTree(dir: "libs", include: "*.jar,*.zip")
deobfCompile "applecore:AppleCore:1.12.2-3.2.0+335.2dbab:api"
}
// update mcmod.info
processResources
{
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "mcversion", project.mcVersion
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources) {
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) {
exclude "mcmod.info"
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
from sourceSets.main.java
}
task devJar(type: Jar) {
from sourceSets.main.output
classifier = "dev"
}
// make the dev and source jars
artifacts {
if (Boolean.parseBoolean(project.makeSourceJar)) {
archives sourcesJar
}
if (Boolean.parseBoolean(project.makeDevJar)) {
archives devJar
}
}
String getVersionFromJava(File file) {
String release = "0";
String update = "0";
String patch = "0";
String build = System.getenv("BUILD_NUMBER") ? System.getenv("BUILD_NUMBER") : "0";
def outfile = "";
def ln = System.getProperty("line.separator")
String prefix = "public static final String VERSION = \"";
file.eachLine {
String s ->
String v = s.trim();
if (v.startsWith(prefix)) {
v = v.substring(prefix.length(), v.length() - 2);
String[] pts = v.split("\\.");
release = pts[0];
update = pts[1];
patch = pts[2];
s = s.replaceAll(".0\";", ".${build}\";");
}
outfile += (s + ln);
}
file.write(outfile);
return "$release.$update.$patch";
}