forked from Railcraft/Railcraft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
359 lines (307 loc) · 10.5 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
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
import groovy.xml.MarkupBuilder
import net.minecraftforge.gradle.tasks.SignJar
buildscript {
repositories {
jcenter()
mavenCentral()
maven {
name = "forge"
url = "http://files.minecraftforge.net/maven"
}
maven {
name = "sonatype"
url = "https://oss.sonatype.org/content/repositories/snapshots/"
}
}
dependencies {
classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
}
}
apply plugin: 'net.minecraftforge.gradle.forge'
apply from: 'api/railcraft/gradle.properties', to: project.ext
sourceCompatibility = targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
group = "com.headlamp-games" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "railcraft"
allprojects {
version = project.version
}
if (file("passwords.properties").exists()) {
apply from: 'passwords.properties', to: project.ext
println "Loading secure configs..."
}
ext {
apiRailcraft = "./api/railcraft/src/main/java"
// apiForestry = "./api/forestry"
// apiThaumcraft = "./api/thaumcraft"
// apiBuildcraft = "./api/buildcraft"
dirLang = "./lang"
dirDest = './build/distributions'
environment = findProject(":private") == null ? "Dev" : "Release"
}
println ''
println '*************************************************************'
println 'Project Version: ' + project.version
println 'Environment: ' + project.environment
println '*************************************************************'
println ''
minecraft {
version = project.version_minecraft + "-" + project.version_forge
runDir = "run"
mappings = project.version_mcp.replace("-", "_")
replace '@VERSION@', project.version
makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
}
def actualRunDir = project.file(minecraft.runDir)
// Change the 4G in -Xmx4G to your desired max RAM and 4G in -Xms4G to your desired initial RAM
def optimizedVmArgs = ['-XX:+UseG1GC', '-Xmx4G', '-Xms4G', '-XX:+UnlockExperimentalVMOptions', '-XX:G1NewSizePercent=20', '-XX:G1ReservePercent=20', '-XX:MaxGCPauseMillis=50', '-XX:G1HeapRegionSize=32M']
def assertionVmArgs = ['-ea:mods.railcraft...', '-ea:net.minecraft...', '-ea:net.minecraftforge...']
def log4jVmArgs = ['-Dlog4j.configurationFile=' + new File(actualRunDir, 'log4j2.xml').toString()]
def combinedVmArgs = [assertionVmArgs, optimizedVmArgs, log4jVmArgs].flatten()
def extraEnvs = new LinkedHashMap() //['LOG4J_CONFIGURATION_FILE': "log4j2.xml"]
minecraft {
clientJvmArgs = combinedVmArgs
serverJvmArgs = combinedVmArgs
}
sourceSets {
main {
resources {
srcDir project.dirLang
exclude '**/Thumbs.db'
}
}
api {
java {
srcDir project.apiRailcraft
}
}
}
repositories {
mavenCentral()
maven {
name = "buildcraft"
url = "https://mod-buildcraft.com/maven/"
}
maven {
name = "ic2"
url = "http://maven.ic2.player.to/"
}
maven {
name = "jei"
url = "http://dvs1.progwml6.com/files/maven/"
}
}
configurations {
api
compile.extendsFrom api
}
dependencies {
// forestry
compileOnly "net.sengir.forestry:forestry_${project.version_minecraft}:${project.version_forestry}:api"
runtime "net.sengir.forestry:forestry_${project.version_minecraft}:${project.version_forestry}"
// IC2
api "net.industrial-craft:industrialcraft-2:${project.version_industrialcraft}:api"
runtime "net.industrial-craft:industrialcraft-2:${project.version_industrialcraft}"
// BuildCraft
compileOnly "com.mod-buildcraft:buildcraft-api:${project.version_buildcraft}"
// JEI
deobfProvided "mezz.jei:jei_${project.version_minecraft}:${project.version_jei}"
// annotations
apiCompileOnly "org.jetbrains:annotations:16.0.2"
compileOnly "org.jetbrains:annotations:16.0.2"
// libs folder in case
compile fileTree(dir: 'lib', include: '*.jar')
// Tests
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.3.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.3.1'
}
processResources {
// this will ensure that this task is redone when the versions change.
inputs.property "version", project.version
inputs.property "version_minecraft", project.minecraft.version
// replace stuff in mcmod.info, nothing else
from(sourceSets.main.resources.srcDirs) {
include 'mcmod.info'
// replace version and version_minecraft
expand 'version': project.version, 'version_minecraft': project.minecraft.version
}
// copy everything else, that is not the mcmod.info
from(sourceSets.main.resources.srcDirs) {
exclude 'mcmod.info'
exclude '**/*.md'
exclude '**/Thumbs.db'
}
}
runClient {
// in git bash, do (replace stuff in the <>) ./gradlew runClient -PmcUsername=<your minecraft login email> -PmcPassword=<your minecraft password>
if (project.hasProperty('mcUsername') && project.hasProperty('mcPassword')) {
args "--username=${project.mcUsername}"
args "--password=${project.mcPassword}"
}
}
runServer {
doFirst {
new File(workingDir, "eula.txt").text = "eula=true"
}
args "nogui" // no server gui, we have console
}
test {
useJUnitPlatform()
// listen to events in the test execution lifecycle
beforeTest { descriptor ->
logger.lifecycle("Running: $descriptor")
}
// Fail the 'test' task on the first test failure
failFast = true
}
task copyLog4jConfig(type: Copy) {
from('extras') {
include 'log4j2.xml'
}
into actualRunDir
}
tasks.withType(JavaExec) {
dependsOn copyLog4jConfig
environment extraEnvs
outputs.upToDateWhen { false }
workingDir actualRunDir
}
genIntellijRuns {
dependsOn copyLog4jConfig
doLast {
def runConfigurationsDir = new File(".idea/runConfigurations")
runConfigurationsDir.mkdirs()
tasks.withType(JavaExec).each { task ->
def taskName = task.name
def mainClass = task.main
def props = combinedVmArgs.join(' ') // task.jvmArgs.join(' ') has too much trash
def args = task.args.join(' ')
def writer = new FileWriter(new File(runConfigurationsDir, "${taskName}.xml"))
def xml = new MarkupBuilder(writer)
xml.component(name: "ProjectRunConfigurationManager") {
configuration(default: 'false', name: taskName, type: "Application", factoryName: "Application", singleton: "true") {
option(name: 'MAIN_CLASS_NAME', value: mainClass)
option(name: 'VM_PARAMETERS', value: props)
option(name: 'PROGRAM_PARAMETERS', value: args)
option(name: 'WORKING_DIRECTORY', value: task.workingDir)
envs() {
extraEnvs.entrySet().each { envVar ->
env(name: envVar.key, value: envVar.value)
}
}
module(name: 'railcraft_main')
// copy log4j config before running
method(v: '2') {
option(name: 'Make', enabled: 'true')
option(name: 'Gradle.BeforeRunTask', enabled: 'true', tasks: 'copyLog4jConfig', externalProjectPath: '$PROJECT_DIR$')
}
}
}
}
}
}
compileJava {
options.compilerArgs += [
'-Xlint:-processing',
'-proc:none'
]
// options.deprecation = true
options.encoding = 'utf8'
}
tasks.withType(Jar) {
from sourceSets.api.output
from {
configurations.api.collect {
it.isDirectory() ? it : zipTree(it).matching {
include '**/ic2/api/energy/**'
include '**/ic2/api/info/**'
include '**/ic2/api/item/**'
include '**/ic2/api/recipe/**'
exclude '**/ic2/**/package-info.java'
exclude '**/ic2/**/package-info.class'
}
}
}
exclude '**/Thumbs.db'
into('mods/railcraft/api') {
from project.apiRailcraft + "/LICENSE.md"
}
// into('forestry/api') {
// from project.apiForestry + "/LICENSE.txt"
// }
// into('thaumcraft/api') {
// from "./src/api/java/thaumcraft/api/LICENSE.txt"
// }
// into('buildcraft/api') {
// from "./src/api/java/buildcraft/api/LICENSE.API"
// }
destinationDir = file(dirDest)
includeEmptyDirs = false
manifest {
attributes(
'FMLAT': 'railcraft_at.cfg'
)
}
}
task devJar(type: Jar, dependsOn: 'classes') {
from sourceSets.main.output
extension = 'jar'
classifier = 'dev'
}
class JarSigner extends SignJar {
JarSigner() {
onlyIf {
project.hasProperty('signingPassword')
}
exclude '**/api/**'
// These properties are intended to be loaded from a "passwords.properties" file
if (project.hasProperty('signingAlias')) {
alias = project.signingAlias
}
if (project.hasProperty('signingPassword')) {
storePass = project.signingPassword
keyPass = project.signingPassword
}
if (project.hasProperty('signingKeystore')) {
keyStore = project.signingKeystore
} else {
keyStore = System.getProperty("user.home") + '/.keystore'
}
}
}
task signMainJar(type: JarSigner, dependsOn: 'jar') {
inputFile = jar.getArchivePath()
outputFile = jar.getArchivePath()
}
task signDevJar(type: JarSigner, dependsOn: 'devJar') {
inputFile = devJar.getArchivePath()
outputFile = devJar.getArchivePath()
}
task apiZip(type: Zip) {
from project.apiRailcraft
destinationDir = file(dirDest)
classifier = 'api'
extension = 'zip'
}
build.dependsOn signMainJar, signDevJar, apiZip
uploadArchives.shouldRunAfter build
if (project.hasProperty("ftpUsername"))
uploadArchives {
repositories {
ivy {
url "sftp://ftp.railcraft.info:22/home2/railcraf/public_html/ivy"
credentials {
username project.ftpUsername
password project.ftpPassword
}
layout 'gradle'
}
}
}
artifacts {
archives apiZip
archives devJar
archives jar
}
task wrapper(type: Wrapper) {
gradleVersion = "4.10.3"
}