|
| 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
|
@@ -322,40 +323,26 @@ tasks.register<Copy>("includeJavaMode") {
|
322 | 323 | into(composeResources("modes/java/mode"))
|
323 | 324 | duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
324 | 325 | }
|
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("")) |
| 326 | +tasks.register("includeJdk") { |
| 327 | + dependsOn("createDistributable") |
| 328 | + doFirst { |
| 329 | + val jdk = Jvm.current().javaHome.absolutePath |
| 330 | + val target = layout.buildDirectory.dir("compose/binaries").get().asFileTree.matching { include("**/include.jdk") } |
| 331 | + .files |
| 332 | + .firstOrNull() |
| 333 | + ?.parentFile |
| 334 | + ?.resolve("jdk") |
| 335 | + ?.absolutePath |
| 336 | + ?: error("Could not find include.jdk") |
| 337 | + |
| 338 | + val isWindows = System.getProperty("os.name").lowercase().contains("win") |
| 339 | + val command = if (isWindows) { |
| 340 | + listOf("xcopy", "/E", "/I", "/Q", jdk, target) |
| 341 | + } else { |
| 342 | + listOf("cp", "-a", jdk, target) |
356 | 343 | }
|
| 344 | + ProcessBuilder(command).inheritIO().start().waitFor() |
357 | 345 | }
|
358 |
| - finalizedBy("prepareAppResources") |
359 | 346 | }
|
360 | 347 | tasks.register<Copy>("includeSharedAssets"){
|
361 | 348 | from("../build/shared/")
|
@@ -427,7 +414,6 @@ tasks.register("signResources"){
|
427 | 414 | dependsOn(
|
428 | 415 | "includeCore",
|
429 | 416 | "includeJavaMode",
|
430 |
| - "includeJdk", |
431 | 417 | "includeSharedAssets",
|
432 | 418 | "includeProcessingExamples",
|
433 | 419 | "includeProcessingWebsiteExamples",
|
@@ -540,7 +526,7 @@ afterEvaluate {
|
540 | 526 | }
|
541 | 527 | }
|
542 | 528 | tasks.named("createDistributable").configure {
|
543 |
| - dependsOn("signResources", "includeJdk") |
544 |
| - finalizedBy("setExecutablePermissions") |
| 529 | + dependsOn("signResources") |
| 530 | + finalizedBy( "includeJdk","setExecutablePermissions") |
545 | 531 | }
|
546 | 532 | }
|
0 commit comments