mirror of
https://github.com/jlengrand/compose-multiplatform.git
synced 2026-03-10 15:48:51 +00:00
Replace 'package<BUILD_TYPE>' with 'package<BUILD_TYPE>DistribuionForCurrentOS' (#2353)
ProGuard support has introduced `Release` build type in addition to the default one. Prior to that there was the `package` task, which did not do anything by itself. The `package` task existed purely for convenience: instead of running the `packageMsi` on Windows and the `packageDmg` on macOS, a user could run the `package` task to package an application into a format suitable for a host OS. A similar task for the release build type should be called `packageRelease`. However, this name conflicts with a task created by the `com.android.application` plugin. This change deprecates the `package` task and removes the `packageRelease` task. `packageDistributionForCurrentOS` and `packageReleaseDistributionForCurrentOS` should be used instead. Resolves #2345
This commit is contained in:
@@ -17,7 +17,6 @@ import org.jetbrains.compose.desktop.application.dsl.TargetFormat
|
||||
import org.jetbrains.compose.desktop.application.internal.validation.validatePackageVersions
|
||||
import org.jetbrains.compose.desktop.application.tasks.*
|
||||
import org.jetbrains.compose.desktop.tasks.AbstractUnpackDefaultComposeApplicationResourcesTask
|
||||
import org.jetbrains.compose.internal.joinDashLowercaseNonEmpty
|
||||
import java.io.File
|
||||
|
||||
private val defaultJvmArgs = listOf("-D$CONFIGURE_SWING_GLOBALS=true")
|
||||
@@ -197,12 +196,26 @@ private fun JvmApplicationContext.configurePackagingTasks(
|
||||
packageFormat
|
||||
}
|
||||
|
||||
val packageAll = tasks.register<DefaultTask>(
|
||||
taskNameAction = "package"
|
||||
val packageForCurrentOS = tasks.register<DefaultTask>(
|
||||
taskNameAction = "package",
|
||||
taskNameObject = "distributionForCurrentOS"
|
||||
) {
|
||||
dependsOn(packageFormats)
|
||||
}
|
||||
|
||||
if (buildType === app.buildTypes.default) {
|
||||
// todo: remove
|
||||
tasks.register<DefaultTask>("package") {
|
||||
dependsOn(packageForCurrentOS)
|
||||
|
||||
doLast {
|
||||
it.logger.error(
|
||||
"'${it.name}' task is deprecated and will be removed in next releases. " +
|
||||
"Use '${packageForCurrentOS.get().name}' task instead")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val packageUberJarForCurrentOS = tasks.register<Jar>(
|
||||
taskNameAction = "package",
|
||||
taskNameObject = "uberJarForCurrentOS"
|
||||
|
||||
@@ -8,6 +8,7 @@ package org.jetbrains.compose.test.tests.integration
|
||||
import org.gradle.internal.impldep.org.testng.Assert
|
||||
import org.gradle.testkit.runner.TaskOutcome
|
||||
import org.jetbrains.compose.desktop.application.internal.*
|
||||
import org.jetbrains.compose.internal.uppercaseFirstChar
|
||||
import org.jetbrains.compose.test.utils.*
|
||||
|
||||
import java.io.File
|
||||
@@ -70,7 +71,8 @@ class DesktopApplicationTest : GradlePluginTestBase() {
|
||||
|
||||
@Test
|
||||
fun kotlinDsl(): Unit = with(testProject(TestProjects.jvmKotlinDsl)) {
|
||||
gradle(":package", "--dry-run").build()
|
||||
gradle(":packageDistributionForCurrentOS", "--dry-run").build()
|
||||
gradle(":packageReleaseDistributionForCurrentOS", "--dry-run").build()
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -90,16 +92,16 @@ class DesktopApplicationTest : GradlePluginTestBase() {
|
||||
|
||||
@Test
|
||||
fun packageJvm() = with(testProject(TestProjects.jvm)) {
|
||||
testPackageNativeExecutables()
|
||||
testPackageJvmDistributions()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun packageMpp() = with(testProject(TestProjects.mpp)) {
|
||||
testPackageNativeExecutables()
|
||||
testPackageJvmDistributions()
|
||||
}
|
||||
|
||||
private fun TestProject.testPackageNativeExecutables() {
|
||||
val result = gradle(":package").build()
|
||||
private fun TestProject.testPackageJvmDistributions() {
|
||||
val result = gradle(":packageDistributionForCurrentOS").build()
|
||||
val ext = when (currentOS) {
|
||||
OS.Linux -> "deb"
|
||||
OS.Windows -> "msi"
|
||||
@@ -120,8 +122,8 @@ class DesktopApplicationTest : GradlePluginTestBase() {
|
||||
} else {
|
||||
Assert.assertEquals(packageFile.name, "TestPackage-1.0.0.$ext", "Unexpected package name")
|
||||
}
|
||||
assertEquals(TaskOutcome.SUCCESS, result.task(":package${ext.capitalize()}")?.outcome)
|
||||
assertEquals(TaskOutcome.SUCCESS, result.task(":package")?.outcome)
|
||||
assertEquals(TaskOutcome.SUCCESS, result.task(":package${ext.uppercaseFirstChar()}")?.outcome)
|
||||
assertEquals(TaskOutcome.SUCCESS, result.task(":packageDistributionForCurrentOS")?.outcome)
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -264,8 +266,8 @@ class DesktopApplicationTest : GradlePluginTestBase() {
|
||||
testRunTask(":runDistributable")
|
||||
testRunTask(":run")
|
||||
|
||||
gradle(":package").build().checks { check ->
|
||||
check.taskOutcome(":package", TaskOutcome.SUCCESS)
|
||||
gradle(":packageDistributionForCurrentOS").build().checks { check ->
|
||||
check.taskOutcome(":packageDistributionForCurrentOS", TaskOutcome.SUCCESS)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -283,8 +285,8 @@ class DesktopApplicationTest : GradlePluginTestBase() {
|
||||
testRunTask(":runDistributable")
|
||||
testRunTask(":run")
|
||||
|
||||
gradle(":package").build().checks { check ->
|
||||
check.taskOutcome(":package", TaskOutcome.SUCCESS)
|
||||
gradle(":packageDistributionForCurrentOS").build().checks { check ->
|
||||
check.taskOutcome(":packageDistributionForCurrentOS", TaskOutcome.SUCCESS)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -302,8 +304,8 @@ class DesktopApplicationTest : GradlePluginTestBase() {
|
||||
testRunTask(":runDistributable")
|
||||
testRunTask(":run")
|
||||
|
||||
gradle(":package").build().checks { check ->
|
||||
check.taskOutcome(":package", TaskOutcome.SUCCESS)
|
||||
gradle(":packageDistributionForCurrentOS").build().checks { check ->
|
||||
check.taskOutcome(":packageDistributionForCurrentOS", TaskOutcome.SUCCESS)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,42 @@
|
||||
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
|
||||
|
||||
plugins {
|
||||
id "com.android.application"
|
||||
id "org.jetbrains.kotlin.multiplatform"
|
||||
id "org.jetbrains.compose"
|
||||
}
|
||||
|
||||
repositories {
|
||||
jetbrainsCompose()
|
||||
google()
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvm {
|
||||
}
|
||||
// empty stub (no actual android app) to detect configuration conflicts
|
||||
// like https://github.com/JetBrains/compose-jb/issues/2345
|
||||
android()
|
||||
|
||||
jvm("desktop")
|
||||
sourceSets {
|
||||
named("jvmMain") {
|
||||
desktopMain {
|
||||
dependsOn(commonMain)
|
||||
|
||||
dependencies {
|
||||
implementation("org.jetbrains.kotlin:kotlin-stdlib")
|
||||
implementation(compose.desktop.currentOs)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdk = 31
|
||||
|
||||
defaultConfig {
|
||||
minSdk = 21
|
||||
targetSdk = 31
|
||||
}
|
||||
}
|
||||
|
||||
compose.desktop {
|
||||
application {
|
||||
mainClass = "MainKt"
|
||||
|
||||
@@ -2,10 +2,12 @@ pluginManagement {
|
||||
plugins {
|
||||
id 'org.jetbrains.kotlin.multiplatform' version 'KOTLIN_VERSION_PLACEHOLDER'
|
||||
id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER'
|
||||
id 'com.android.application' version '7.0.4'
|
||||
}
|
||||
repositories {
|
||||
mavenLocal()
|
||||
gradlePluginPortal()
|
||||
google()
|
||||
}
|
||||
}
|
||||
rootProject.name = "simple"
|
||||
Reference in New Issue
Block a user