-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
221 lines (199 loc) · 7.25 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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
buildscript {
repositories {
jcenter()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:3.+'
}
}
plugins {
id 'java'
id 'maven-publish'
id "net.covers1624.signing" version '1.1.3'
}
apply plugin: 'net.minecraftforge.gradle'
group = "codechicken"
archivesBaseName = "Template"
targetCompatibility = "1.8"
sourceCompatibility = "1.8"
//Add generated resources to main resources.
sourceSets.main.resources.srcDirs += "src/generated/resources"
file('build.properties').withReader {
def prop = new Properties()
prop.load(it)
project.ext.config = new ConfigSlurper().parse prop
}
def signProps = [:]
if (System.getenv("KEY_STORE")) {
println "Using Env variables for jar signing."
signProps['keyStore'] = System.getenv("KEY_STORE")
file(System.getenv("KEY_STORE_PROPS")).withReader {
def props = new Properties()
props.load(it)
signProps.putAll(props)
}
} else if (project.hasProperty('keyStore')) {
println "Using Project properties for jar signing."
signProps['keyStore'] = project.getProperty('keyStore')
signProps['storePass'] = project.getProperty('keyStorePass')
signProps['alias'] = project.getProperty('keyStoreAlias')
signProps['keyPass'] = project.getProperty('keyStoreKeyPass')
} else {
println 'No signing secrets found, build will not be signed.'
}
config.mod_version = "${config.mod_version}." + (System.getenv("BUILD_NUMBER") ?: "1")
version = "${config.mc_version}-${config.mod_version}"
println "Starting build of ${archivesBaseName}, Version: ${config.mod_version}"
println "Using Forge: ${config.forge_version}, for Minecraft: ${config.mc_version}, with Mappings: ${config.mappings}"
minecraft {
mappings channel: 'snapshot', version: config.mappings
accessTransformer = file("src/main/resources/META-INF/accesstransformer.cfg")
runs {
client {
workingDirectory file('run')
mods { enderstorage { source sourceSets.main } }
}
server {
workingDirectory file('run')
mods { enderstorage { source sourceSets.main } }
}
data {
workingDirectory file('run')
args '--mod', 'template', '--all', '--output', file("src/generated/resources")
mods { enderstorage { source sourceSets.main } }
}
}
}
repositories {
mavenLocal()
maven { url = "http://chickenbones.net/maven" }
}
dependencies {
minecraft "net.minecraftforge:forge:${config.mc_version}-${config.forge_version}"
compile fg.deobf("codechicken:CodeChickenLib:${config.mc_version}-${config.ccl_version}:universal")
}
signing {
if (!signProps.isEmpty()) {
jars {
sign jar
after reobfJar
keyStore = signProps.keyStore
alias = signProps.alias
storePass = signProps.storePass
keyPass = signProps.keyPass
}
}
}
processResources { task ->
inputs.property 'mod_version', config.mod_version
inputs.property 'mc_version', config.mc_version
from(sourceSets.main.resources.srcDirs) { spec ->
spec.include 'META-INF/mods.toml'
task.doFirst {
spec.expand 'version': config.mod_version,
'mc_version': config.mc_version,
'ccl_version': resolve("CodeChickenLib")
}
}
}
jar {
finalizedBy 'reobfJar'
classifier = 'universal'
manifest {
attributes 'Specification-Title': archivesBaseName
attributes 'Specification-Vendor': 'covers1624'
attributes 'Specification-Version': "1"
attributes 'Implementation-Title': archivesBaseName
attributes 'Implementation-Vendor': 'covers1624'
attributes 'Implementation-Version': version
attributes 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
}
}
task srcJar(type: Jar) {
build.dependsOn it
from sourceSets.main.allSource
classifier = 'sources'
}
publishing {
repositories {
if (System.getenv('MAVEN_PASS')) {
maven {
url "https://maven-upload.covers1624.net/"
credentials {
username 'covers1624'
password System.getenv('MAVEN_PASS')
}
}
}
}
publications {
Template(MavenPublication) {
groupId project.group
artifactId project.archivesBaseName
version project.version
artifact jar
artifact srcJar
pom {
name = archivesBaseName
description = archivesBaseName
//The publish plugin doesnt like GString's here apparently..
url = "https://github.com/TheCBProject/${archivesBaseName}".toString()
scm {
url = "https://github.com/TheCBProject/${archivesBaseName}".toString()
connection = "scm:git:git://github.com/TheCBProject/${archivesBaseName}.git".toString()
connection = "scm:git:[email protected]:TheCBProject/${archivesBaseName}.git".toString()
}
issueManagement {
system = 'github'
url = "https://github.com/TheCBProject/${archivesBaseName}/issues".toString()
}
licenses {
license {
name = "TODO"
url = "TODO"
distribution = 'TODO'
}
}
developers {
developer {
id = 'TODO'
name = 'TODO'
}
}
}
}
}
}
/**
* Polls the 'compile' configuration for a dependency with the given module name
* and resolves, and returns its version. E.g: '1.2.+' will resolve to '1.2.3.4'
*
* @param module The module to search for.
* @param chop If the string should be chopped on the last '-' in its string.
* @param configuration The name of the configuration to search.
* @param errorMissing If an error should be thrown if it can't be found.
* @return The version string, '0' if 'errorMissing' is false and nothing was found.
*/
def resolve(module, chop = true, configuration = 'compile', errorMissing = true) {
//Copy and lenient resolve the configuration, Forge cant be resolved at this time so lenient is required.
def filtered = configurations.getByName(configuration).copy().incoming.artifactView({ it.lenient = true }).artifacts
.findAll { it.id.componentIdentifier.module == module }
.collect { it.id.componentIdentifier.version }
if (filtered.size() > 1) {
println "WARNING: Found ${filtered.size()} Dependencies with ModuleName '${module}' in configuration '${configuration.name}'"
}
if (errorMissing && filtered.isEmpty()) {
throw new RuntimeException("Failed resolve dependency version for '${module}'")
}
if (filtered.isEmpty()) return "0"
def version = filtered.first() as String
if (chop) {
def idx = version.lastIndexOf('-')
return version.substring(idx + 1)
}
return version
}