forked from elytra/GlassHearts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
204 lines (172 loc) · 5.34 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
/*
* The MIT License (MIT)
*
* Copyright (c) 2017 Una Thompson (unascribed)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
buildscript {
repositories {
mavenCentral()
jcenter()
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 'net.sf.proguard:proguard-gradle:5.3.3'
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.4'
classpath 'gradle.plugin.net.minecrell:licenser:0.3'
}
}
apply plugin: 'net.minecraftforge.gradle.forge'
apply from: 'project.gradle'
if (project.ext.useElytraVersionFormat) {
def branch;
if (System.env.BRANCH_NAME) {
// Jenkins support
branch = System.env.BRANCH_NAME;
branch = branch.substring(branch.lastIndexOf('/')+1);
} else {
branch = 'git rev-parse --abbrev-ref HEAD'.execute().in.text.trim();
}
if (branch == "HEAD") {
branch = 'git rev-parse --short HEAD'.execute().in.text.trim();
}
def commits = 'git rev-list --count HEAD'.execute().in.text.trim();
def dirty = !'git diff-index HEAD'.execute().in.text.trim().isEmpty();
version = branch+'-'+project.ext.version+'.'+commits+(dirty ? '-dirty' : '');
} else {
version = project.ext.version;
}
println("Elytra Project Skeleton v1.1.0")
println("https://github.com/elytra/skel")
println()
println("Project Name: "+project.ext.projectName)
println("Version: "+version)
println()
println("Package: "+project.ext.package)
println()
if (!project.ext.concreteModules.isEmpty()) {
println("Concrete Version: "+project.ext.concreteVersion)
}
println("Forge Version: "+project.ext.forge)
println("Mappings: "+project.ext.mappings)
project.ext.priv = parseConfig(file('private.properties'))
group = project.ext.group
archivesBaseName = project.ext.projectName
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
jcenter()
mavenCentral()
maven {
name = 'elytra'
url = 'http://repo.elytradev.com/'
}
}
if (project.ext.enforceLicenseHeaders) {
apply plugin: 'net.minecrell.licenser'
}
if (!project.ext.concreteModules.isEmpty()) {
apply plugin: 'com.github.johnrengelman.shadow'
jar {
classifier = 'slim'
}
shadowJar {
classifier = ''
relocate 'com.elytradev.concrete', project.ext.package+'.repackage.com.elytradev.concrete'
configurations = [project.configurations.shadow]
}
reobf {
shadowJar { mappingType = 'SEARGE' }
}
tasks.reobfJar.doLast {
file('build/libs/'+archivesBaseName+'-'+version+'-slim.jar').delete()
}
tasks.build.dependsOn reobfShadowJar
artifacts {
archives shadowJar
}
dependencies {
for (String module : project.ext.concreteModules) {
shadow 'com.elytradev:concrete:'+project.ext.concreteVersion+':'+module
compile 'com.elytradev:concrete:'+project.ext.concreteVersion+':'+module
}
}
}
if (priv != null) {
apply plugin: 'maven'
configurations {
deploy
}
dependencies {
deploy 'org.apache.maven.wagon:wagon-ssh:2.10'
}
uploadArchives {
repositories.mavenDeployer {
configuration = configurations.deploy
pom.artifactId = project.ext.projectName.toLowerCase()
repository(url: "sftp://"+priv.sftpHost+priv.sftpPath) {
authentication(userName: priv.sftpUser, privateKey: file(priv.sftpKey))
}
}
}
}
minecraft {
version = project.ext.forge
mappings = project.ext.mappings
runDir = "minecraft"
replaceIn 'src/main/java/'+project.ext.package.replace('.', '/')+'/'+project.ext.projectName+'.java'
replace '@VERSION@', project.version
}
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'
exclude '*.xcf'
exclude '*.wav'
}
}
def parseConfig(File config) {
if (!config.exists()) return null
config.withReader {
def prop = new Properties()
prop.load(it)
return (new ConfigSlurper().parse(prop))
}
}