mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Merge pull request #1054 from Stefterv/include-jdk
Change for `includeJDK` to grab the running JDK
This commit is contained in:
+57
-94
@@ -1,9 +1,9 @@
|
||||
import org.gradle.kotlin.dsl.support.zipTo
|
||||
import org.gradle.internal.jvm.Jvm
|
||||
import org.gradle.internal.os.OperatingSystem
|
||||
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
|
||||
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
|
||||
import org.jetbrains.compose.desktop.application.tasks.AbstractJPackageTask
|
||||
import org.jetbrains.compose.internal.de.undercouch.gradle.tasks.download.Download
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.overrides
|
||||
import java.io.FileOutputStream
|
||||
import java.util.zip.ZipEntry
|
||||
import java.util.zip.ZipOutputStream
|
||||
@@ -139,11 +139,11 @@ tasks.compileJava{
|
||||
val version = if(project.version == "unspecified") "1.0.0" else project.version
|
||||
|
||||
tasks.register<Exec>("installCreateDmg") {
|
||||
onlyIf { org.gradle.internal.os.OperatingSystem.current().isMacOsX }
|
||||
onlyIf { OperatingSystem.current().isMacOsX }
|
||||
commandLine("arch", "-arm64", "brew", "install", "--quiet", "create-dmg")
|
||||
}
|
||||
tasks.register<Exec>("packageCustomDmg"){
|
||||
onlyIf { org.gradle.internal.os.OperatingSystem.current().isMacOsX }
|
||||
onlyIf { OperatingSystem.current().isMacOsX }
|
||||
group = "compose desktop"
|
||||
|
||||
val distributable = tasks.named<AbstractJPackageTask>("createDistributable").get()
|
||||
@@ -173,8 +173,6 @@ tasks.register<Exec>("packageCustomDmg"){
|
||||
extra.add("25")
|
||||
}
|
||||
|
||||
commandLine("brew", "install", "--quiet", "create-dmg")
|
||||
|
||||
commandLine("create-dmg",
|
||||
"--volname", packageName,
|
||||
"--volicon", file("macos/volume.icns"),
|
||||
@@ -191,7 +189,7 @@ tasks.register<Exec>("packageCustomDmg"){
|
||||
}
|
||||
|
||||
tasks.register<Exec>("packageCustomMsi"){
|
||||
onlyIf { org.gradle.internal.os.OperatingSystem.current().isWindows }
|
||||
onlyIf { OperatingSystem.current().isWindows }
|
||||
dependsOn("createDistributable")
|
||||
workingDir = file("windows")
|
||||
group = "compose desktop"
|
||||
@@ -207,20 +205,22 @@ tasks.register<Exec>("packageCustomMsi"){
|
||||
)
|
||||
}
|
||||
|
||||
val snapname = findProperty("snapname") ?: rootProject.name
|
||||
val snaparch = when (System.getProperty("os.arch")) {
|
||||
"amd64", "x86_64" -> "amd64"
|
||||
"aarch64" -> "arm64"
|
||||
else -> System.getProperty("os.arch")
|
||||
}
|
||||
|
||||
tasks.register("generateSnapConfiguration"){
|
||||
onlyIf { org.gradle.internal.os.OperatingSystem.current().isLinux }
|
||||
val name = findProperty("snapname") ?: rootProject.name
|
||||
val arch = when (System.getProperty("os.arch")) {
|
||||
"amd64", "x86_64" -> "amd64"
|
||||
"aarch64" -> "arm64"
|
||||
else -> System.getProperty("os.arch")
|
||||
}
|
||||
|
||||
onlyIf { OperatingSystem.current().isLinux }
|
||||
val distributable = tasks.named<AbstractJPackageTask>("createDistributable").get()
|
||||
dependsOn(distributable)
|
||||
|
||||
val dir = distributable.destinationDir.get()
|
||||
val content = """
|
||||
name: $snapname
|
||||
name: $name
|
||||
version: $version
|
||||
base: core22
|
||||
summary: A creative coding editor
|
||||
@@ -248,20 +248,19 @@ tasks.register("generateSnapConfiguration"){
|
||||
parts:
|
||||
processing:
|
||||
plugin: dump
|
||||
source: deb/processing_$version-1_$snaparch.deb
|
||||
source: deb/processing_$version-1_$arch.deb
|
||||
source-type: deb
|
||||
stage-packages:
|
||||
- openjdk-17-jre
|
||||
override-prime: |
|
||||
snapcraftctl prime
|
||||
chmod -R +x opt/processing/lib/app/resources/jdk-*
|
||||
rm -vf usr/lib/jvm/java-17-openjdk-*/lib/security/cacerts
|
||||
""".trimIndent()
|
||||
dir.file("../snapcraft.yaml").asFile.writeText(content)
|
||||
}
|
||||
|
||||
tasks.register<Exec>("packageSnap"){
|
||||
onlyIf { org.gradle.internal.os.OperatingSystem.current().isLinux }
|
||||
onlyIf { OperatingSystem.current().isLinux }
|
||||
dependsOn("packageDeb", "generateSnapConfiguration")
|
||||
group = "compose desktop"
|
||||
|
||||
@@ -283,19 +282,20 @@ tasks.register<Zip>("zipDistributable"){
|
||||
}
|
||||
|
||||
afterEvaluate{
|
||||
// Override the default DMG task to use our custom one
|
||||
tasks.named("packageDmg").configure{
|
||||
dependsOn("packageCustomDmg")
|
||||
group = "compose desktop"
|
||||
actions = emptyList()
|
||||
}
|
||||
|
||||
// Override the default MSI task to use our custom one
|
||||
tasks.named("packageMsi").configure{
|
||||
dependsOn("packageCustomMsi")
|
||||
group = "compose desktop"
|
||||
actions = emptyList()
|
||||
}
|
||||
tasks.named("packageDistributionForCurrentOS").configure {
|
||||
if(org.gradle.internal.os.OperatingSystem.current().isMacOsX
|
||||
if(OperatingSystem.current().isMacOsX
|
||||
&& compose.desktop.application.nativeDistributions.macOS.notarization.appleID.isPresent
|
||||
){
|
||||
dependsOn("notarizeDmg")
|
||||
@@ -326,40 +326,9 @@ tasks.register<Copy>("includeJavaMode") {
|
||||
into(composeResources("modes/java/mode"))
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
}
|
||||
tasks.register<Download>("includeJdk") {
|
||||
val os = DefaultNativePlatform.getCurrentOperatingSystem()
|
||||
val arch = when (System.getProperty("os.arch")) {
|
||||
"amd64", "x86_64" -> "x64"
|
||||
else -> System.getProperty("os.arch")
|
||||
}
|
||||
val platform = when {
|
||||
os.isWindows -> "windows"
|
||||
os.isMacOsX -> "mac"
|
||||
else -> "linux"
|
||||
}
|
||||
|
||||
val javaVersion = System.getProperty("java.version").split(".")[0]
|
||||
val imageType = "jdk"
|
||||
|
||||
src("https://api.adoptium.net/v3/binary/latest/" +
|
||||
"$javaVersion/ga/" +
|
||||
"$platform/" +
|
||||
"$arch/" +
|
||||
"$imageType/" +
|
||||
"hotspot/normal/eclipse?project=jdk")
|
||||
|
||||
val extension = if (os.isWindows) "zip" else "tar.gz"
|
||||
val jdk = layout.buildDirectory.file("tmp/jdk-$platform-$arch.$extension")
|
||||
dest(jdk)
|
||||
overwrite(false)
|
||||
doLast {
|
||||
copy {
|
||||
val archive = if (os.isWindows) { zipTree(jdk) } else { tarTree(jdk) }
|
||||
from(archive){ eachFile{ permissions{ unix("755") } } }
|
||||
into(composeResources(""))
|
||||
}
|
||||
}
|
||||
finalizedBy("prepareAppResources")
|
||||
tasks.register<Copy>("includeJdk") {
|
||||
from(Jvm.current().javaHome.absolutePath)
|
||||
destinationDir = composeResources("jdk").get().asFile
|
||||
}
|
||||
tasks.register<Copy>("includeSharedAssets"){
|
||||
from("../build/shared/")
|
||||
@@ -405,6 +374,7 @@ tasks.register<Copy>("includeJavaModeResources") {
|
||||
from(java.layout.buildDirectory.dir("resources-bundled"))
|
||||
into(composeResources("../"))
|
||||
}
|
||||
// TODO: Move to java mode
|
||||
tasks.register<Copy>("renameWindres") {
|
||||
dependsOn("includeSharedAssets","includeJavaModeResources")
|
||||
val dir = composeResources("modes/java/application/launch4j/bin/")
|
||||
@@ -421,29 +391,29 @@ tasks.register<Copy>("renameWindres") {
|
||||
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
||||
into(dir)
|
||||
}
|
||||
tasks.register("signResources"){
|
||||
onlyIf {
|
||||
org.gradle.internal.os.OperatingSystem.current().isMacOsX
|
||||
&&
|
||||
compose.desktop.application.nativeDistributions.macOS.signing.sign.get()
|
||||
}
|
||||
group = "compose desktop"
|
||||
tasks.register("includeProcessingResources"){
|
||||
dependsOn(
|
||||
"includeJdk",
|
||||
"includeCore",
|
||||
"includeJavaMode",
|
||||
"includeJdk",
|
||||
"includeSharedAssets",
|
||||
"includeProcessingExamples",
|
||||
"includeProcessingWebsiteExamples",
|
||||
"includeJavaModeResources",
|
||||
"renameWindres"
|
||||
)
|
||||
finalizedBy("prepareAppResources")
|
||||
finalizedBy("signResources")
|
||||
}
|
||||
|
||||
tasks.register("signResources"){
|
||||
onlyIf {
|
||||
OperatingSystem.current().isMacOsX
|
||||
&&
|
||||
compose.desktop.application.nativeDistributions.macOS.signing.sign.get()
|
||||
}
|
||||
group = "compose desktop"
|
||||
val resourcesPath = composeResources("")
|
||||
|
||||
|
||||
|
||||
// find jars in the resources directory
|
||||
val jars = mutableListOf<File>()
|
||||
doFirst{
|
||||
@@ -476,7 +446,7 @@ tasks.register("signResources"){
|
||||
include("**/*x86_64*")
|
||||
include("**/*ffmpeg*")
|
||||
include("**/ffmpeg*/**")
|
||||
exclude("jdk-*/**")
|
||||
exclude("jdk/**")
|
||||
exclude("*.jar")
|
||||
exclude("*.so")
|
||||
exclude("*.dll")
|
||||
@@ -512,39 +482,32 @@ tasks.register("signResources"){
|
||||
|
||||
|
||||
}
|
||||
afterEvaluate {
|
||||
tasks.named("prepareAppResources").configure {
|
||||
dependsOn(
|
||||
"includeCore",
|
||||
"includeJavaMode",
|
||||
"includeSharedAssets",
|
||||
"includeProcessingExamples",
|
||||
"includeProcessingWebsiteExamples",
|
||||
"includeJavaModeResources",
|
||||
"renameWindres"
|
||||
)
|
||||
}
|
||||
tasks.register("setExecutablePermissions") {
|
||||
description = "Sets executable permissions on binaries in Processing.app resources"
|
||||
group = "compose desktop"
|
||||
tasks.register("setExecutablePermissions") {
|
||||
description = "Sets executable permissions on binaries in Processing.app resources"
|
||||
group = "compose desktop"
|
||||
|
||||
doLast {
|
||||
val resourcesPath = layout.buildDirectory.dir("compose/binaries")
|
||||
fileTree(resourcesPath) {
|
||||
include("**/resources/**/bin/**")
|
||||
include("**/resources/**/*.sh")
|
||||
include("**/resources/**/*.dylib")
|
||||
include("**/resources/**/*.so")
|
||||
include("**/resources/**/*.exe")
|
||||
}.forEach { file ->
|
||||
if (file.isFile) {
|
||||
file.setExecutable(true, false)
|
||||
}
|
||||
doLast {
|
||||
val resourcesPath = layout.buildDirectory.dir("compose/binaries")
|
||||
fileTree(resourcesPath) {
|
||||
include("**/resources/**/bin/**")
|
||||
include("**/resources/**/lib/**")
|
||||
include("**/resources/**/*.sh")
|
||||
include("**/resources/**/*.dylib")
|
||||
include("**/resources/**/*.so")
|
||||
include("**/resources/**/*.exe")
|
||||
}.forEach { file ->
|
||||
if (file.isFile) {
|
||||
file.setExecutable(true, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
tasks.named("prepareAppResources").configure {
|
||||
dependsOn("includeProcessingResources")
|
||||
}
|
||||
tasks.named("createDistributable").configure {
|
||||
dependsOn("signResources", "includeJdk")
|
||||
finalizedBy("setExecutablePermissions")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -391,17 +391,14 @@ public class Platform {
|
||||
static public File getJavaHome() {
|
||||
var resourcesDir = System.getProperty("compose.application.resources.dir");
|
||||
if(resourcesDir != null) {
|
||||
var jdkFolder = Arrays.stream(new File(resourcesDir).listFiles((dir, name) -> dir.isDirectory() && name.startsWith("jdk-")))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if(Platform.isMacOS()){
|
||||
return new File(jdkFolder, "Contents/Home");
|
||||
}
|
||||
var jdkFolder = new File(resourcesDir,"jdk");
|
||||
if(jdkFolder.exists()){
|
||||
return jdkFolder;
|
||||
}
|
||||
}
|
||||
|
||||
var home = System.getProperty("java.home");
|
||||
if(home != null && new File(home, "bin/java").exists()){
|
||||
if(home != null){
|
||||
return new File(home);
|
||||
}
|
||||
if (Platform.isMacOS()) {
|
||||
|
||||
Reference in New Issue
Block a user