|
| 1 | +import org.gradle.internal.jvm.Jvm |
1 | 2 | import org.gradle.kotlin.dsl.support.zipTo |
2 | 3 | import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform |
3 | 4 | import org.jetbrains.compose.desktop.application.dsl.TargetFormat |
@@ -250,7 +251,6 @@ tasks.register("generateSnapConfiguration"){ |
250 | 251 | - openjdk-17-jre |
251 | 252 | override-prime: | |
252 | 253 | snapcraftctl prime |
253 | | - chmod -R +x opt/processing/lib/app/resources/jdk-* |
254 | 254 | rm -vf usr/lib/jvm/java-17-openjdk-*/lib/security/cacerts |
255 | 255 | """.trimIndent() |
256 | 256 | dir.file("../snapcraft.yaml").asFile.writeText(content) |
@@ -322,40 +322,26 @@ tasks.register<Copy>("includeJavaMode") { |
322 | 322 | into(composeResources("modes/java/mode")) |
323 | 323 | duplicatesStrategy = DuplicatesStrategy.EXCLUDE |
324 | 324 | } |
325 | | -tasks.register<Download>("includeJdk") { |
326 | | - val os = DefaultNativePlatform.getCurrentOperatingSystem() |
327 | | - val arch = when (System.getProperty("os.arch")) { |
328 | | - "amd64", "x86_64" -> "x64" |
329 | | - else -> System.getProperty("os.arch") |
330 | | - } |
331 | | - val platform = when { |
332 | | - os.isWindows -> "windows" |
333 | | - os.isMacOsX -> "mac" |
334 | | - else -> "linux" |
335 | | - } |
336 | | - |
337 | | - val javaVersion = System.getProperty("java.version").split(".")[0] |
338 | | - val imageType = "jdk" |
339 | | - |
340 | | - src("https://api.adoptium.net/v3/binary/latest/" + |
341 | | - "$javaVersion/ga/" + |
342 | | - "$platform/" + |
343 | | - "$arch/" + |
344 | | - "$imageType/" + |
345 | | - "hotspot/normal/eclipse?project=jdk") |
346 | | - |
347 | | - val extension = if (os.isWindows) "zip" else "tar.gz" |
348 | | - val jdk = layout.buildDirectory.file("tmp/jdk-$platform-$arch.$extension") |
349 | | - dest(jdk) |
350 | | - overwrite(false) |
351 | | - doLast { |
352 | | - copy { |
353 | | - val archive = if (os.isWindows) { zipTree(jdk) } else { tarTree(jdk) } |
354 | | - from(archive){ eachFile{ permissions{ unix("755") } } } |
355 | | - into(composeResources("")) |
| 325 | +tasks.register("includeJdk") { |
| 326 | + dependsOn("createDistributable") |
| 327 | + doFirst { |
| 328 | + val jdk = Jvm.current().javaHome.absolutePath |
| 329 | + val target = layout.buildDirectory.dir("compose/binaries").get().asFileTree.matching { include("**/include.jdk") } |
| 330 | + .files |
| 331 | + .firstOrNull() |
| 332 | + ?.parentFile |
| 333 | + ?.resolve("jdk") |
| 334 | + ?.absolutePath |
| 335 | + ?: error("Could not find include.jdk") |
| 336 | + |
| 337 | + val isWindows = System.getProperty("os.name").lowercase().contains("win") |
| 338 | + val command = if (isWindows) { |
| 339 | + listOf("xcopy", "/E", "/I", "/Q", jdk, target) |
| 340 | + } else { |
| 341 | + listOf("cp", "-a", jdk, target) |
356 | 342 | } |
| 343 | + ProcessBuilder(command).inheritIO().start().waitFor() |
357 | 344 | } |
358 | | - finalizedBy("prepareAppResources") |
359 | 345 | } |
360 | 346 | tasks.register<Copy>("includeSharedAssets"){ |
361 | 347 | from("../build/shared/") |
@@ -427,7 +413,6 @@ tasks.register("signResources"){ |
427 | 413 | dependsOn( |
428 | 414 | "includeCore", |
429 | 415 | "includeJavaMode", |
430 | | - "includeJdk", |
431 | 416 | "includeSharedAssets", |
432 | 417 | "includeProcessingExamples", |
433 | 418 | "includeProcessingWebsiteExamples", |
@@ -540,7 +525,7 @@ afterEvaluate { |
540 | 525 | } |
541 | 526 | } |
542 | 527 | tasks.named("createDistributable").configure { |
543 | | - dependsOn("signResources", "includeJdk") |
544 | | - finalizedBy("setExecutablePermissions") |
| 528 | + dependsOn("signResources") |
| 529 | + finalizedBy( "includeJdk","setExecutablePermissions") |
545 | 530 | } |
546 | 531 | } |
0 commit comments