-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
248 lines (212 loc) · 7.76 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
buildscript {
ext.kotlin_version = project.kotlin_version
repositories {
mavenCentral()
maven { url = "http://files.minecraftforge.net/maven" }
maven { url = "http://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 "gradle.plugin.com.matthewprenger:CurseGradle:${project.cursegradle_version}"
classpath "org.jetbrains.dokka:dokka-gradle-plugin:${project.dokka_version}"
}
}
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}"
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
}
}
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}+"
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}"
compile "com.mod-buildcraft:buildcraft:${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.main.output
}
task sourcesJar(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}
task deobfJar(type: Jar) {
from sourceSets.main.output
classifier = 'deobf'
}
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
artifacts {
archives sourceJar, deobfJar
}
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'
}
}
}
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
}
mainArtifact(jar) {
displayName = "$project.mod_name : $displayVersion"
relations {
requiredLibrary 'shadowfacts-forgelin'
requiredLibrary 'buildcraft'
// TODO: add relations ('requiredLibrary' || 'optionalLibrary')
}
}
addArtifact(sourceJar) {
displayName = "$project.mod_name : $displayVersion : Sources"
}
addArtifact(deobfJar) {
displayName = "$project.mod_name : $displayVersion : Development"
}
}
}
}