Browse Source

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
pull/2357/head
Alexey Tsvetkov 2 years ago committed by GitHub
parent
commit
e301429247
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 19
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/configureJvmApplication.kt
  2. 28
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/DesktopApplicationTest.kt
  3. 27
      gradle-plugins/compose/src/test/test-projects/application/mpp/build.gradle
  4. 2
      gradle-plugins/compose/src/test/test-projects/application/mpp/settings.gradle
  5. 0
      gradle-plugins/compose/src/test/test-projects/application/mpp/src/desktopMain/kotlin/main.kt

19
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.internal.validation.validatePackageVersions
import org.jetbrains.compose.desktop.application.tasks.* import org.jetbrains.compose.desktop.application.tasks.*
import org.jetbrains.compose.desktop.tasks.AbstractUnpackDefaultComposeApplicationResourcesTask import org.jetbrains.compose.desktop.tasks.AbstractUnpackDefaultComposeApplicationResourcesTask
import org.jetbrains.compose.internal.joinDashLowercaseNonEmpty
import java.io.File import java.io.File
private val defaultJvmArgs = listOf("-D$CONFIGURE_SWING_GLOBALS=true") private val defaultJvmArgs = listOf("-D$CONFIGURE_SWING_GLOBALS=true")
@ -197,12 +196,26 @@ private fun JvmApplicationContext.configurePackagingTasks(
packageFormat packageFormat
} }
val packageAll = tasks.register<DefaultTask>( val packageForCurrentOS = tasks.register<DefaultTask>(
taskNameAction = "package" taskNameAction = "package",
taskNameObject = "distributionForCurrentOS"
) { ) {
dependsOn(packageFormats) 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>( val packageUberJarForCurrentOS = tasks.register<Jar>(
taskNameAction = "package", taskNameAction = "package",
taskNameObject = "uberJarForCurrentOS" taskNameObject = "uberJarForCurrentOS"

28
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.internal.impldep.org.testng.Assert
import org.gradle.testkit.runner.TaskOutcome import org.gradle.testkit.runner.TaskOutcome
import org.jetbrains.compose.desktop.application.internal.* import org.jetbrains.compose.desktop.application.internal.*
import org.jetbrains.compose.internal.uppercaseFirstChar
import org.jetbrains.compose.test.utils.* import org.jetbrains.compose.test.utils.*
import java.io.File import java.io.File
@ -70,7 +71,8 @@ class DesktopApplicationTest : GradlePluginTestBase() {
@Test @Test
fun kotlinDsl(): Unit = with(testProject(TestProjects.jvmKotlinDsl)) { fun kotlinDsl(): Unit = with(testProject(TestProjects.jvmKotlinDsl)) {
gradle(":package", "--dry-run").build() gradle(":packageDistributionForCurrentOS", "--dry-run").build()
gradle(":packageReleaseDistributionForCurrentOS", "--dry-run").build()
} }
@Test @Test
@ -90,16 +92,16 @@ class DesktopApplicationTest : GradlePluginTestBase() {
@Test @Test
fun packageJvm() = with(testProject(TestProjects.jvm)) { fun packageJvm() = with(testProject(TestProjects.jvm)) {
testPackageNativeExecutables() testPackageJvmDistributions()
} }
@Test @Test
fun packageMpp() = with(testProject(TestProjects.mpp)) { fun packageMpp() = with(testProject(TestProjects.mpp)) {
testPackageNativeExecutables() testPackageJvmDistributions()
} }
private fun TestProject.testPackageNativeExecutables() { private fun TestProject.testPackageJvmDistributions() {
val result = gradle(":package").build() val result = gradle(":packageDistributionForCurrentOS").build()
val ext = when (currentOS) { val ext = when (currentOS) {
OS.Linux -> "deb" OS.Linux -> "deb"
OS.Windows -> "msi" OS.Windows -> "msi"
@ -120,8 +122,8 @@ class DesktopApplicationTest : GradlePluginTestBase() {
} else { } else {
Assert.assertEquals(packageFile.name, "TestPackage-1.0.0.$ext", "Unexpected package name") 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${ext.uppercaseFirstChar()}")?.outcome)
assertEquals(TaskOutcome.SUCCESS, result.task(":package")?.outcome) assertEquals(TaskOutcome.SUCCESS, result.task(":packageDistributionForCurrentOS")?.outcome)
} }
@Test @Test
@ -264,8 +266,8 @@ class DesktopApplicationTest : GradlePluginTestBase() {
testRunTask(":runDistributable") testRunTask(":runDistributable")
testRunTask(":run") testRunTask(":run")
gradle(":package").build().checks { check -> gradle(":packageDistributionForCurrentOS").build().checks { check ->
check.taskOutcome(":package", TaskOutcome.SUCCESS) check.taskOutcome(":packageDistributionForCurrentOS", TaskOutcome.SUCCESS)
} }
} }
} }
@ -283,8 +285,8 @@ class DesktopApplicationTest : GradlePluginTestBase() {
testRunTask(":runDistributable") testRunTask(":runDistributable")
testRunTask(":run") testRunTask(":run")
gradle(":package").build().checks { check -> gradle(":packageDistributionForCurrentOS").build().checks { check ->
check.taskOutcome(":package", TaskOutcome.SUCCESS) check.taskOutcome(":packageDistributionForCurrentOS", TaskOutcome.SUCCESS)
} }
} }
} }
@ -302,8 +304,8 @@ class DesktopApplicationTest : GradlePluginTestBase() {
testRunTask(":runDistributable") testRunTask(":runDistributable")
testRunTask(":run") testRunTask(":run")
gradle(":package").build().checks { check -> gradle(":packageDistributionForCurrentOS").build().checks { check ->
check.taskOutcome(":package", TaskOutcome.SUCCESS) check.taskOutcome(":packageDistributionForCurrentOS", TaskOutcome.SUCCESS)
} }
} }
} }

27
gradle-plugins/compose/src/test/test-projects/application/mpp/build.gradle

@ -1,23 +1,42 @@
import org.jetbrains.compose.desktop.application.dsl.TargetFormat import org.jetbrains.compose.desktop.application.dsl.TargetFormat
plugins { plugins {
id "com.android.application"
id "org.jetbrains.kotlin.multiplatform" id "org.jetbrains.kotlin.multiplatform"
id "org.jetbrains.compose" id "org.jetbrains.compose"
} }
repositories {
jetbrainsCompose()
google()
}
kotlin { 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 { sourceSets {
named("jvmMain") { desktopMain {
dependsOn(commonMain)
dependencies { dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib")
implementation(compose.desktop.currentOs) implementation(compose.desktop.currentOs)
} }
} }
} }
} }
android {
compileSdk = 31
defaultConfig {
minSdk = 21
targetSdk = 31
}
}
compose.desktop { compose.desktop {
application { application {
mainClass = "MainKt" mainClass = "MainKt"

2
gradle-plugins/compose/src/test/test-projects/application/mpp/settings.gradle

@ -2,10 +2,12 @@ pluginManagement {
plugins { plugins {
id 'org.jetbrains.kotlin.multiplatform' version 'KOTLIN_VERSION_PLACEHOLDER' id 'org.jetbrains.kotlin.multiplatform' version 'KOTLIN_VERSION_PLACEHOLDER'
id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER' id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER'
id 'com.android.application' version '7.0.4'
} }
repositories { repositories {
mavenLocal() mavenLocal()
gradlePluginPortal() gradlePluginPortal()
google()
} }
} }
rootProject.name = "simple" rootProject.name = "simple"

0
gradle-plugins/compose/src/test/test-projects/application/mpp/src/jvmMain/kotlin/main.kt → gradle-plugins/compose/src/test/test-projects/application/mpp/src/desktopMain/kotlin/main.kt

Loading…
Cancel
Save