diff --git a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/configureJvmApplication.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/configureJvmApplication.kt index 32f3d33509..577da2bb8a 100644 --- a/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/configureJvmApplication.kt +++ b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/configureJvmApplication.kt @@ -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( - taskNameAction = "package" + val packageForCurrentOS = tasks.register( + taskNameAction = "package", + taskNameObject = "distributionForCurrentOS" ) { dependsOn(packageFormats) } + if (buildType === app.buildTypes.default) { + // todo: remove + tasks.register("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( taskNameAction = "package", taskNameObject = "uberJarForCurrentOS" diff --git a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/DesktopApplicationTest.kt b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/DesktopApplicationTest.kt index ef992a6fc0..920425e3cc 100644 --- a/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/DesktopApplicationTest.kt +++ b/gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/DesktopApplicationTest.kt @@ -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) } } } diff --git a/gradle-plugins/compose/src/test/test-projects/application/mpp/build.gradle b/gradle-plugins/compose/src/test/test-projects/application/mpp/build.gradle index 3b13d85550..611ddc78df 100644 --- a/gradle-plugins/compose/src/test/test-projects/application/mpp/build.gradle +++ b/gradle-plugins/compose/src/test/test-projects/application/mpp/build.gradle @@ -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" diff --git a/gradle-plugins/compose/src/test/test-projects/application/mpp/settings.gradle b/gradle-plugins/compose/src/test/test-projects/application/mpp/settings.gradle index 633aadd815..9eed2dbfce 100644 --- a/gradle-plugins/compose/src/test/test-projects/application/mpp/settings.gradle +++ b/gradle-plugins/compose/src/test/test-projects/application/mpp/settings.gradle @@ -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" \ No newline at end of file diff --git a/gradle-plugins/compose/src/test/test-projects/application/mpp/src/jvmMain/kotlin/main.kt b/gradle-plugins/compose/src/test/test-projects/application/mpp/src/desktopMain/kotlin/main.kt similarity index 100% rename from gradle-plugins/compose/src/test/test-projects/application/mpp/src/jvmMain/kotlin/main.kt rename to gradle-plugins/compose/src/test/test-projects/application/mpp/src/desktopMain/kotlin/main.kt