2023-01-27 02:34:46 +00:00
|
|
|
import java.util.stream.Collectors
|
|
|
|
|
|
|
|
def distDir = "$buildDir/dist"
|
|
|
|
|
|
|
|
def distJvmArgs = new ArrayList<String>(project(':app').application.applicationDefaultJvmArgs)
|
|
|
|
|
|
|
|
def releaseArguments = distJvmArgs + [
|
2023-06-12 01:08:43 +00:00
|
|
|
"-Dio.xpipe.app.version=$rootProject.versionString",
|
|
|
|
"-Dio.xpipe.app.build=$rootProject.versionString-${new Date().format('yyyyMMddHHmm')}",
|
2023-02-10 13:46:54 +00:00
|
|
|
"-Dio.xpipe.app.buildId=$rootProject.buildId",
|
2023-02-19 17:44:47 +00:00
|
|
|
"-Dio.xpipe.app.fullVersion=$rootProject.fullVersion",
|
2023-04-26 14:34:59 +00:00
|
|
|
"-Dio.xpipe.app.staging=$rootProject.isStage",
|
2023-01-27 02:34:46 +00:00
|
|
|
'-Dio.xpipe.app.sentryUrl=https://fd5f67ff10764b7e8a704bec9558c8fe@o1084459.ingest.sentry.io/6094279'
|
|
|
|
]
|
|
|
|
|
|
|
|
if (org.gradle.internal.os.OperatingSystem.current().isMacOsX()) {
|
2023-05-20 14:23:36 +00:00
|
|
|
releaseArguments += '-Xdock:name=XPipe'
|
2023-01-27 02:34:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// To remove warnings, the plugin probably does not expect the JPackage tasks to be in a separate project
|
|
|
|
application {
|
|
|
|
mainModule = 'io.xpipe.app'
|
|
|
|
mainClass = 'io.xpipe.app.Main'
|
|
|
|
}
|
|
|
|
|
|
|
|
def appDependencies = project(':app').configurations.findByName('runtimeClasspath').getFiles().stream()
|
|
|
|
.collect(Collectors.toMap(f -> f.toPath().getFileName().toString(), f -> f, (f1, f2) -> f1))
|
|
|
|
.values()
|
|
|
|
def appModuleNames = ['app']
|
|
|
|
appDependencies.removeIf(f -> appModuleNames.stream()
|
|
|
|
.anyMatch(m -> f.toPath().getFileName().toString().contains("${m}.jar")))
|
|
|
|
def appModuleOutputFiles = ["${project(':app').buildDir}/libs/app.jar"]
|
|
|
|
dependencies {
|
|
|
|
implementation files(appDependencies.toArray())
|
|
|
|
implementation files(appModuleOutputFiles.toArray())
|
|
|
|
}
|
|
|
|
|
2023-08-20 09:42:34 +00:00
|
|
|
// Mac does not like a zero major version
|
|
|
|
def macVersion = rootProject.canonicalVersionString
|
|
|
|
if (Integer.parseInt(macVersion.substring(0, 1)) == 0) {
|
|
|
|
macVersion = "1" + macVersion.substring(1)
|
|
|
|
}
|
|
|
|
|
2023-01-27 02:34:46 +00:00
|
|
|
jlink {
|
|
|
|
imageDir = file("$buildDir/image")
|
|
|
|
options = [
|
|
|
|
// Disable this as this removes line numbers from stack traces!
|
|
|
|
// '--strip-debug',
|
|
|
|
'--compress', '2',
|
|
|
|
'--no-header-files',
|
|
|
|
'--no-man-pages',
|
|
|
|
// '--strip-native-commands'
|
|
|
|
]
|
|
|
|
|
|
|
|
launcher {
|
|
|
|
moduleName = 'io.xpipe.app'
|
|
|
|
mainClassName = 'io.xpipe.app.Main'
|
|
|
|
name = 'xpiped'
|
|
|
|
jvmArgs = releaseArguments
|
|
|
|
}
|
|
|
|
|
|
|
|
jpackage {
|
|
|
|
imageOutputDir = file("$distDir/jpackage")
|
|
|
|
imageName = 'xpiped'
|
|
|
|
if (org.gradle.internal.os.OperatingSystem.current().isWindows()) {
|
|
|
|
icon = "logo/logo.ico"
|
2023-02-02 13:58:50 +00:00
|
|
|
appVersion = rootProject.canonicalVersionString
|
2023-01-27 02:34:46 +00:00
|
|
|
} else if (org.gradle.internal.os.OperatingSystem.current().isLinux()) {
|
|
|
|
icon = "logo/logo.png"
|
2023-02-02 13:58:50 +00:00
|
|
|
appVersion = rootProject.canonicalVersionString
|
2023-01-27 02:34:46 +00:00
|
|
|
} else {
|
|
|
|
icon = "logo/logo.icns"
|
|
|
|
|
|
|
|
def cert = System.getenv('MACOS_DEVELOPER_ID_APPLICATION_CERTIFICATE_USER_NAME')
|
|
|
|
if (cert != null) {
|
|
|
|
imageOptions += [
|
|
|
|
'--mac-signing-key-user-name', cert
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
imageOptions += [
|
|
|
|
'--mac-sign',
|
|
|
|
'--mac-package-signing-prefix', 'io.xpipe.app',
|
2023-05-20 14:23:36 +00:00
|
|
|
'--mac-package-name', "XPipe Desktop",
|
2023-01-27 02:34:46 +00:00
|
|
|
'--mac-app-category', 'productivity',
|
|
|
|
// '--mac-entitlements', "$projectDir/misc/mac/Entitlements.plist"
|
|
|
|
]
|
|
|
|
|
2023-08-20 06:51:17 +00:00
|
|
|
resourceDir = file("$buildDir/macos_resources")
|
2023-08-20 09:42:34 +00:00
|
|
|
appVersion = macVersion
|
2023-01-27 02:34:46 +00:00
|
|
|
}
|
|
|
|
skipInstaller = true
|
2023-05-20 14:23:36 +00:00
|
|
|
applicationName = 'XPipe'
|
2023-01-27 02:34:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.named('jlink').get().dependsOn(rootProject.getTasksByName("jar", true))
|
|
|
|
|
|
|
|
def outputName = org.gradle.internal.os.OperatingSystem.current().isMacOsX() ? 'xpiped.app/Contents/Resources' : 'xpiped'
|
2023-04-04 16:11:31 +00:00
|
|
|
def extModules = project.allExtensions.toList()
|
2023-02-10 13:46:54 +00:00
|
|
|
task copyBundledExtensions(type: DefaultTask,
|
|
|
|
dependsOn: extModules.stream().map { it.getTasksByName('createExtOutput', true)[0] }.toList()) {
|
2023-01-27 02:34:46 +00:00
|
|
|
doLast {
|
2023-02-10 13:46:54 +00:00
|
|
|
for (def extProject : extModules) {
|
|
|
|
def dir = "${extProject.buildDir}/libs_ext"
|
2023-01-27 02:34:46 +00:00
|
|
|
if (file(dir).exists()) {
|
|
|
|
copy {
|
|
|
|
from(dir)
|
|
|
|
into "$distDir/jpackage/$outputName/extensions/${extProject.name}"
|
|
|
|
include '*.jar'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-08-20 06:51:17 +00:00
|
|
|
|
|
|
|
task prepareMacOSInfo(type: DefaultTask) {
|
|
|
|
doLast {
|
|
|
|
file("$buildDir/macos_resources").mkdirs()
|
|
|
|
copy {
|
2023-08-20 09:42:34 +00:00
|
|
|
from file("$projectDir/misc/mac/Info.plist")
|
2023-08-20 06:51:17 +00:00
|
|
|
into file("$buildDir/macos_resources")
|
|
|
|
}
|
|
|
|
exec {
|
2023-08-20 09:42:34 +00:00
|
|
|
commandLine "$projectDir/misc/mac/modify_version.sh", macVersion, "$buildDir/macos_resources/Info.plist"
|
2023-08-20 06:51:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (org.gradle.internal.os.OperatingSystem.current().isMacOsX()) {
|
2023-08-20 09:42:34 +00:00
|
|
|
jpackageImage.dependsOn(prepareMacOSInfo)
|
2023-08-20 06:51:17 +00:00
|
|
|
}
|
|
|
|
|
2023-01-27 02:34:46 +00:00
|
|
|
jpackage.finalizedBy(copyBundledExtensions)
|