-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
144 lines (118 loc) · 3.87 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
buildscript {
repositories {
jcenter()
maven {
name = 'forge'
url = 'http://files.minecraftforge.net/maven'
}
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
}
}
//Returns the current version by reading directly from the ModInfo.java file
project.ext.getVersionFromJava = {
String major = '0';
String revision = '0';
String patch = '0';
String prefix = 'public static final String VERSION = "';
File file = file('src/main/java/thebetweenlandsmusic/ModInfo.java')
file.eachLine { String s ->
s = s.trim();
if (s.startsWith(prefix)) {
s = s.substring(prefix.length(), s.length() - 2);
String[] pts = s.split('\\.');
major = pts[0];
revision = pts[1];
patch = pts[2];
}
}
return "$major.$revision.$patch";
}
//Returns the mod ID by reading directly from the ModInfo.java file
project.ext.getModIdFromJava = {
String id = 'N/A';
String prefix = 'public static final String ID = "';
File file = file('src/main/java/thebetweenlandsmusic/ModInfo.java')
file.eachLine { String s ->
s = s.trim();
if (s.startsWith(prefix)) {
id = s.substring(prefix.length(), s.length() - 2);
}
}
return "$id";
}
//Attempts to get a project variable and if none is found it tries to read from a system environment variable
project.ext.getVariable = { key ->
return project.hasProperty(key) ? project.property(key) : ENV[key];
}
project.ext.ENV = System.getenv()
project.ext.buildnumber = ''
project.ext.modid = project.getModIdFromJava()
allprojects {
version = project.getVersionFromJava()
apply plugin: 'net.minecraftforge.gradle.forge'
minecraft {
version = "1.12.2-14.23.5.2773"
runDir = 'minecraft'
replace '${version}', project.version
replace '${mcversion}', project.minecraft.version
replace '/*!ide*/true/*ide!*/', 'false'
// 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 = "stable_39"
makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
}
apply from: new File(rootProject.projectDir, 'dependencies.gradle')
}
//Don't build jar for root project
tasks.remove(tasks.build)
subprojects {
//Don't set up dev env for subprojects
tasks.remove(tasks.setupCiWorkspace)
tasks.remove(tasks.setupDevWorkspace)
tasks.remove(tasks.setupDecompWorkspace)
tasks.remove(tasks.eclipse)
tasks.remove(tasks.idea)
archivesBaseName = 'TheBetweenlandsMusic'
sourceCompatibility = targetCompatibility = '1.8'
group = 'angrypixel'
//Move build dir into root's build folder
buildDir = new File(rootProject.projectDir, 'build/' + project.name + '/build/')
//Set sourceSets.main to root's sourceSets.main
sourceSets {
main {
java {
srcDir new File(rootProject.projectDir, 'src/main/java')
}
resources {
srcDir new File(rootProject.projectDir, 'src/main/resources')
}
}
}
//Processes the resources of sourceSets.main
processResources {
inputs.property 'version', project.version
inputs.property 'mcversion', project.minecraft.version
from (sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
expand 'version':project.version, 'mcversion':project.minecraft.version
}
from (sourceSets.main.resources.srcDirs) { exclude 'mcmod.info' }
rename '(.+_at.cfg)', 'META-INF/$1'
}
//Set destination dir of all subprojects to build/libs/
jar {
destinationDir = new File(rootProject.projectDir, 'build/libs/')
}
}
apply plugin: 'idea'
idea.project.modules = new ArrayList([rootProject.idea.module])
println('Building version ' + version)
apply from: 'projects.gradle'