Files
xpipe/dist/base.gradle
crschnick 9a01303008 Fixes
2025-05-29 14:46:54 +00:00

144 lines
4.9 KiB
Groovy

import java.util.stream.Collectors
def distDir = "${project.layout.buildDirectory.get()}/dist"
task licenses(type: DefaultTask) {
doLast {
copy {
from "$projectDir/licenses/"
into "$distDir/licenses/"
include '*.license'
rename { String name ->
name.replace("license", "txt")
}
}
}
}
def debugArguments = file("$projectDir/debug/debug_arguments.txt").text.lines().map(s -> '"' + s + '"').collect(Collectors.joining(' '))
if (org.gradle.internal.os.OperatingSystem.current().isWindows()) {
task baseDist(type: DefaultTask) {
doLast {
copy {
from "$distDir/jpackage/xpiped"
into "$distDir/base"
}
copy {
from "$projectDir/logo/logo.ico"
into "$distDir/base"
}
copy {
from "$projectDir/fonts"
into "$distDir/base/fonts"
}
copy {
from "$rootDir/lang"
into "$distDir/base/lang"
}
file("$distDir/base/app/.jpackage.xml").delete()
def batLauncherFile = file("$distDir/base/runtime/bin/xpiped.bat")
def batLauncherContent = batLauncherFile.text
batLauncherContent = batLauncherContent.replace(" -p \"%~dp0/../app\"", "")
batLauncherFile.text = batLauncherContent
file("$distDir/base/runtime/bin/xpiped").delete()
file("$distDir/base/scripts").mkdirs()
def debug = file("$distDir/base/scripts/xpiped_debug.bat")
debug.text = file("$projectDir/debug/windows/xpiped_debug.bat").text.replace(
'JVM-ARGS',
debugArguments)
debug.setExecutable(true)
copy {
from "$distDir/licenses"
into "$distDir/base/licenses"
}
}
}
} else if (org.gradle.internal.os.OperatingSystem.current().isLinux()) {
task baseDist(type: DefaultTask) {
doLast {
copy {
from "$distDir/jpackage/xpiped"
into "$distDir/base/"
}
copy {
from "$projectDir/logo/logo.png"
into "$distDir/base/"
}
copy {
from "$projectDir/fonts"
into "$distDir/base/fonts"
}
copy {
from "$rootDir/lang"
into "$distDir/base/lang"
}
def shLauncherFile = file("$distDir/base/lib/runtime/bin/xpiped")
def shLauncherContent = shLauncherFile.text
shLauncherContent = shLauncherContent.replace(" -p \"\$DIR/../app\"", "")
shLauncherFile.text = shLauncherContent
file("$distDir/base/lib/runtime/bin/xpiped.bat").delete()
file("$distDir/base/scripts").mkdirs()
def debug = file("$distDir/base/scripts/xpiped_debug.sh")
debug.text = file("$projectDir/debug/linux/xpiped_debug.sh").text.replace(
'JVM-ARGS',
debugArguments)
debug.setExecutable(true, false)
copy {
from "$distDir/licenses"
into "$distDir/base/licenses"
}
}
}
} else {
task baseDist(type: DefaultTask) {
doLast {
def app = "${productName}.app"
copy {
from "$distDir/jpackage/xpiped.app/Contents"
into "$distDir/$app/Contents/"
}
copy {
from "$projectDir/logo/logo.icns"
into "$distDir/$app/Contents/Resources/"
}
copy {
from "$distDir/licenses"
into "$distDir/$app/Contents/Resources/licenses"
}
copy {
from "$projectDir/fonts"
into "$distDir/$app/Contents/Resources/fonts"
}
copy {
from "$rootDir/lang"
into "$distDir/$app/Contents/Resources/lang"
}
def shLauncherFile = file("$distDir/$app/Contents/runtime/Contents/Home/bin/xpiped")
def shLauncherContent = shLauncherFile.text
shLauncherContent = shLauncherContent.replace(" -p \"\$DIR/../app\"", "")
shLauncherFile.text = shLauncherContent
file("$distDir/$app/Contents/runtime/Contents/Home/bin/xpiped.bat").delete()
file("$distDir/$app/Contents/Resources/scripts").mkdirs()
def debug = file("$distDir/$app/Contents/Resources/scripts/xpiped_debug.sh")
debug.text = file("$projectDir/debug/mac/xpiped_debug.sh").text.replace(
'JVM-ARGS',
debugArguments)
debug.setExecutable(true, false)
}
}
}
baseDist.dependsOn(licenses)
baseDist.dependsOn(jpackage)
dist.dependsOn(baseDist)