-
Notifications
You must be signed in to change notification settings - Fork 78
/
build.gradle
176 lines (145 loc) · 5.51 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
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 whether the private keystore for signing is available and if the jar should be signed
project.ext.canJarBeSigned = {
return getVariable('blKeyStore') != null && (!isDeploymentEnv || isDeploymentRelease)
}
//Returns the public fingerprint, may be empty ("")
project.ext.getProjectFingerprint = {
if(canJarBeSigned()) {
return getVariable('blKeyStoreFingerprint').replaceAll(':', '').toLowerCase()
}
return ''
}
//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/thebetweenlands/common/lib/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/thebetweenlands/common/lib/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.isDeploymentEnv = ENV['DEPLOY_ENV'] != null && 'true'.equals(ENV['DEPLOY_ENV'])
project.ext.isDeploymentRelease = project.isDeploymentEnv && ENV['DEPLOY_BUILD_TYPE'] != null && 'release'.equals(ENV['DEPLOY_BUILD_TYPE'])
project.ext.buildnumber = project.isDeploymentEnv ? ENV['DEPLOY_BUILD_NUMBER'] : ''
project.ext.modid = project.getModIdFromJava()
allprojects {
version = project.getVersionFromJava()
if(!isDeploymentRelease) version = version + (!project.isDeploymentRelease ? ((project.isDeploymentEnv ? ('-' + project.buildnumber) : '') + '-SNAPSHOT') : '')
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'
replace '${fingerprint}', getProjectFingerprint()
clientJvmArgs = ['-Dfml.coreMods.load=thebetweenlands.core.TheBetweenlandsLoadingPlugin']
serverJvmArgs = ['-Dfml.coreMods.load=thebetweenlands.core.TheBetweenlandsLoadingPlugin']
// 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 = 'TheBetweenlands'
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/')
}
//Adds the maven artifact attribute to the specified Manifest
project.ext.addMavenArtifactAttribute = { m, classifier ->
m.attributes ([
'Maven-Artifact': group + ':' + archivesBaseName + ':' + project.version + ':' + classifier,
'Timestamp': new java.util.Date().getTime()
])
}
}
apply plugin: 'idea'
idea.project.modules = new ArrayList([rootProject.idea.module])
if(isDeploymentEnv) println('Deployment environment found')
if(isDeploymentRelease) println('Deploying a release build')
println(canJarBeSigned() ? 'Keystore properties found, jar files will be signed' : 'No keystore properties found, jar files will not be signed')
println('Building version ' + version)
apply from: 'projects.gradle'