Files
IdleRSC/build.gradle
Kaila_Btw 67783a5bdb Add sleep assets to jar and extract when missing
This will solve missing assets on release tasks or when running the jar solo without any other resources in the dir. Ideally Idle jar is self sufficient and can extract any assets it needs on the fly without worrying about missing dependencies if the jar is moved or something is deleted.
2024-01-29 22:53:48 -05:00

97 lines
2.6 KiB
Groovy

plugins {
// Use metadata from git
id 'git-metadata'
// Ensure archives are reproducible
id 'reproducible-archives'
}
ext.releaseName = { ->
return "${rootProject.getName()}-${gitCommitDate()}-${gitCommitCount()}-${gitCommitHash()}"
}
tasks.register('run', JavaExec) {
group 'build'
description 'Run IdleRSC.'
dependsOn ':app:build'
File appJar = new File(project(':app').getBuildDir(), "libs/${project(':app').getName()}.jar")
classpath = files(appJar)
}
tasks.register('buildPatchedClient', JavaExec) {
group 'build'
description 'Create patched client jar archive.'
dependsOn ':client:build', ':patcher:build', ':patcher:spotlessApply'
File patcherJar = new File(project(':patcher').getBuildDir(), "libs/${project(':patcher').getName()}.jar")
File clientJar = new File(project(':client').getBuildDir(), "libs/${project(':client').getName()}.jar")
File patchedClientJar = new File(project(':patcher').getBuildDir(), 'libs/patched_client.jar')
classpath = files(patcherJar)
args clientJar, patchedClientJar
outputs.upToDateWhen {
patchedClientJar.exists()
}
}
tasks.register('createClientCache', Zip) {
group 'build'
description 'Create client cache for inclusion in the jar archive.'
archiveFileName = 'ZipCache.zip'
destinationDirectory = project(':app').file('src/main/resources/cache/')
from('assets/cache/')
include '**/*'
}
tasks.register('copyMapData', Copy) {
group 'build'
description 'Copy map data for inclusion in the jar archive.'
from 'assets/map'
into project(':app').file('src/main/resources/map')
}
tasks.register('copyAssetData', Copy) {
group 'build'
description 'Copy asset data for inclusion in the jar archive.'
from 'assets/sleep'
into project(':app').file('src/main/resources/assets/sleep')
}
tasks.register('prepareRelease', Copy) {
group 'Distribution'
description 'Prepare files for release zip.'
dependsOn ':app:build'
// Final JAR
from("${project(':app').getBuildDir()}/libs") {
rename 'app.jar', "${rootProject.name}.jar"
}
// documentation and cache
from ("${rootProject.projectDir}") {
include 'scripts/'
include 'doc/'
include 'README.md', 'LICENSE'
}
into "build/${releaseName()}"
}
tasks.register('release', Zip) {
group 'Distribution'
description 'Create release zip for end-users.'
dependsOn prepareRelease
archiveFileName = "${releaseName()}.zip"
destinationDirectory = rootProject.getProjectDir()
// Configure zip task to place contents in IdleRSC folder
into('IdleRSC') {
from("build/${releaseName()}") {
into('.')
}
}
}