-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle
314 lines (272 loc) · 9.83 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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
buildscript {
ext.kotlin_version = project.kotlin_version
repositories {
mavenCentral()
maven { url = "http://files.minecraftforge.net/maven" }
maven { url = "https://repo.maven.apache.org/maven2" }
maven { url = "https://plugins.gradle.org/m2/" }
maven { url = "https://oss.sonatype.org/content/repositories/snapshots/" }
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${project.kotlin_version}"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:${project.dokka_version}"
}
}
plugins {
id 'com.matthewprenger.cursegradle' version '1.4.0'
}
apply plugin: 'kotlin'
apply plugin: "net.minecraftforge.gradle.forge"
apply plugin: 'com.matthewprenger.cursegradle'
apply plugin: "maven-publish"
apply plugin: "maven"
apply plugin: 'org.jetbrains.dokka'
archivesBaseName = project.mod_name.replace(' ', '-').toLowerCase()
group = "${project.group_name}"
// version = "${project.minecraft_version}-${project.mod_version}"
version = "${project.bc_version}-${project.mod_version}"
if (project.hasProperty('mod_suffix')) {
version += "-${project.mod_suffix}"
}
compileJava { sourceCompatibility = targetCompatibility = "1.8" }
compileKotlin { kotlinOptions { jvmTarget = "1.8" } }
minecraft {
version = "${project.minecraft_version}-${project.forge_version}"
mappings = "${project.mcp_version}"
runDir = "run"
replace '@MOD-ID@', project.mod_id
replace '@MOD-NAME@', project.mod_name
replace '@MOD-VERSION@', project.mod_version
replace '@MOD-MC-VERSION@', project.minecraft_version
replace '@FORGELIN-VERSION@', project.forgelin_version
replace '@FORGE-VERSION@', project.forge_version
replace '@BC-VERSION@', project.bc_version
replace '@JEI-VERSION@', project.jei_version
replace '@FINGERPRINT@', project.findProperty('signSHA1')
replaceIn 'constants.kt'
if (project.hasProperty('mc_username')) {
clientRunArgs += ['--username', "${project.mc_username}"]
if (project.hasProperty('mc_password')) {
clientRunArgs += ['--password=', "${project.mc_password}"]
}
}
if (project.hasProperty('mc_uuid')) {
clientRunArgs += ['--uuid', "${project.mc_uuid}"]
}
// disable server gui
serverRunArgs += "nogui"
// skip the screen to confirm that you want to load a world with missing registry entries
serverJvmArgs += "-Dfml.doNotBackup=true"
clientJvmArgs += "-Dfml.doNotBackup=true"
// skip having to confirm on server
serverJvmArgs += "-Dfml.queryResult=confirm"
// skip jansi warnings in the log
serverJvmArgs += "-Dlog4j.skipJansi=true"
clientJvmArgs += "-Dlog4j.skipJansi=true"
if (project.hasProperty('client_args')) {
clientJvmArgs += "${project.client_args}"
}
if (project.hasProperty('server_args')) {
serverJvmArgs += "${project.server_args}"
}
}
import groovy.json.JsonSlurper
class Secrets {
def data = null
def getProperty(String key) {
return data ? data[key] : ''
}
}
def secretFile
if (System.getenv().SECRET_FILE) {
secretFile = file System.getenv().SECRET_FILE
} else {
secretFile = file 'secret.json'
}
project.ext.secret = new Secrets()
if (secretFile.exists()) {
secretFile.withReader {
project.ext.secret.data = new JsonSlurper().parse it
}
}
// // Mad hacks to make source replacements work for Kotlin
// // "stolen" from: https://github.com/PaleoCrafter/VanillaImmersion/blob/ee82ecafb76659cf7d7822a722c8f63f43f41d01/build.gradle#L119-L136
// import net.minecraftforge.gradle.user.TaskSourceCopy
// for (set in sourceSets) {
// def taskName = "source${set.name.capitalize()}Kotlin"
// def dir = new File(project.getBuildDir(), "sources/${set.name}/kotlin")
// task(taskName, type: TaskSourceCopy) {
// source = set.getKotlin()
// output = dir
// }
// def compileTask = tasks[set.getCompileTaskName("kotlin")]
// compileTask.source = dir
// compileTask.dependsOn taskName
// def dirPath = dir.toPath()
// compileTask.include {
// return it.file.toPath().startsWith(dirPath)
// }
// }
// end of "stolen" part :)
// configurations {
// compile.extendsFrom exportedCompile
// deployerJars
// all { resolutionStrategy.cacheChangingModulesFor 0, 'seconds' }
// }
repositories {
mavenCentral()
mavenLocal()
jcenter()
maven { name='mmd'; url='https://maven.mcmoddev.com' }
maven { name='forgelin'; url='http://maven.shadowfacts.net/' }
maven { name='jei'; url="http://dvs1.progwml6.com/files/maven" }
maven { name='build craft'; url='https://www.mod-buildcraft.com/maven' }
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${project.kotlin_version}"
compile "net.shadowfacts:Forgelin:${project.forgelin_version}+"
deobfProvided "mezz.jei:jei_${project.minecraft_version}:${project.jei_version}+:api"
runtime "mezz.jei:jei_${project.minecraft_version}:${project.jei_version}+"
compileOnly "com.mod-buildcraft:buildcraft-api:${project.bc_version}"
compileOnly "com.mod-buildcraft:buildcraft-lib:${project.bc_version}"
runtime "com.mod-buildcraft:buildcraft-all:${project.bc_version}"
}
processResources {
inputs.property "version", project.version
inputs.property "mcversion", project.minecraft.version
inputs.property "modid", project.mod_id
inputs.property "modname", project.mod_name
from(sourceSets.main.resources.srcDirs) {
include '**/*.info'
include '**/*.properties'
// replace version and mcversion
expand 'version':project.version, 'mcversion':project.minecraft.version, 'modid': project.mod_id, 'modname': project.mod_name
}
from(sourceSets.main.resources.srcDirs) {
exclude '**/*.info'
exclude '**/*.properties'
}
}
jar {
from sourceSets.api.output
from sourceSets.main.output
}
task sourcesJar(type: Jar) {
from sourceSets.api.allSource
from sourceSets.main.allSource
classifier = 'sources'
}
task deobfJar(type: Jar) {
from sourceSets.api.output
from sourceSets.main.output
classifier = 'deobf'
}
task apiJar(type: Jar) {
from sourceSets.api.output
classifier = 'api'
}
task dokkaJavadoc(type: org.jetbrains.dokka.gradle.DokkaTask) {
outputFormat = "javadoc"
kotlinTasks {
[':compileApiKotlin']
}
outputDirectory = "$buildDir/dokkaJavadoc"
}
task signJar(type: SignJar, dependsOn: reobfJar) {
// Skips if the keyStore property is missing.
onlyIf {
project.hasProperty('keyStore')
}
// findProperty allows us to reference the property without it existing.
// Using project.propName would cause the script to fail validation if
// the property did not exist.
keyStore = project.findProperty('keyStore')
alias = project.findProperty('keyStoreAlias')
storePass = project.findProperty('keyStorePass')
keyPass = project.findProperty('keyStoreKeyPass')
inputFile = jar.archivePath
outputFile = jar.archivePath
}
build.dependsOn signJar
tasks.publish.dependsOn build
tasks.curseforge.dependsOn publish
task javadocJar(type: Jar, dependsOn: dokkaJavadoc) {
classifier = 'javadoc'
from dokkaJavadoc.outputDirectory
}
artifacts {
archives apiJar, sourceJar, deobfJar, javadocJar
}
publishing {
publications {
mavenJava(MavenPublication) {
groupId project.group
artifactId project.archivesBaseName
def versionForMaven = "$project.bc_version-$project.mod_version"
if (System.getenv().BUILD_NUMBER) {
versionForMaven += '.' + System.getenv().BUILD_NUMBER
}
version versionForMaven
from components.java
artifact sourceJar {
classifier 'sources'
}
artifact deobfJar {
classifier 'deobf'
}
artifact javadocJar {
classifier 'javadoc'
}
artifact apiJar {
classifier 'api'
}
}
}
repositories {
maven {
credentials {
username secret.username
password secret.password
}
url secret.url
}
}
}
curseforge {
if (project.hasProperty('cf_project_id') && project.hasProperty('cf_release_type') &&
((project.cf_release_type == "alpha") || (project.cf_release_type == "beta") || (project.cf_release_type == "release"))) {
apiKey = secret.curseforgeAPIKey
project {
id = "$project.cf_project_id"
changelog = file('current-changelog.txt')
releaseType = project.cf_release_type
addGameVersion(project.minecraft_version)
def projectName = project.mod_name
def displayVersion = "${project.bc_version} - ${project.mod_version}"
if (System.getenv().BUILD_NUMBER) {
displayVersion += '.' + System.getenv().BUILD_NUMBER
}
relations {
requiredDependency 'shadowfacts-forgelin'
requiredDependency 'buildcraft'
// TODO: add relations ('requiredLibrary' || 'optionalLibrary')
}
mainArtifact(jar) {
displayName = "$projectName : $displayVersion"
}
addArtifact(sourceJar) {
displayName = "$projectName : $displayVersion : Sources"
}
addArtifact(deobfJar) {
displayName = "$projectName : $displayVersion : Development"
}
addArtifact(apiJar) {
displayName = "$projectName : $displayVersion : API"
}
addArtifact(javadocJar) {
displayName = "$projectName : $displayVersion : API Javadoc"
}
}
}
}