Browse Source

Merge remote-tracking branch 'origin/master' into release/1.2

# Conflicts:
#	gradle-plugins/gradle.properties
pull/2359/head
Igor Demin 2 years ago
parent
commit
ab5702a582
  1. 5
      README.md
  2. 9
      gradle-plugins/buildSrc/src/main/kotlin/BuildProperties.kt
  3. 14
      gradle-plugins/compose/build.gradle.kts
  4. 23
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeCompilerKotlinSupportPlugin.kt
  5. 11
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeExtension.kt
  6. 19
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/configureJvmApplication.kt
  7. 66
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/ComposeCompilerArtifactProvider.kt
  8. 11
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/TestKotlinVersion.kt
  9. 20
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/TestProperties.kt
  10. 52
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/DesktopApplicationTest.kt
  11. 14
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/GradlePluginTest.kt
  12. 107
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/unit/ComposeCompilerArtifactProviderTest.kt
  13. 9
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/unit/FileHashTest.kt
  14. 10
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/GradlePluginTestBase.kt
  15. 2
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/GradleTestNameGenerator.kt
  16. 12
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestKotlinVersion.kt
  17. 14
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProject.kt
  18. 5
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProjects.kt
  19. 29
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProperties.kt
  20. 6
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/assertUtils.kt
  21. 2
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/fileUtils.kt
  22. 2
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/processUtils.kt
  23. 2
      gradle-plugins/compose/src/test/resources/junit-platform.properties
  24. 31
      gradle-plugins/compose/src/test/test-projects/application/androidx-compiler/build.gradle
  25. BIN
      gradle-plugins/compose/src/test/test-projects/application/androidx-compiler/main-image.expected.png
  26. 11
      gradle-plugins/compose/src/test/test-projects/application/androidx-compiler/settings.gradle
  27. 76
      gradle-plugins/compose/src/test/test-projects/application/androidx-compiler/src/main/kotlin/Main.kt
  28. 2
      gradle-plugins/compose/src/test/test-projects/application/defaultArgs/settings.gradle
  29. 2
      gradle-plugins/compose/src/test/test-projects/application/defaultArgsOverride/settings.gradle
  30. 2
      gradle-plugins/compose/src/test/test-projects/application/javaLogger/settings.gradle
  31. 2
      gradle-plugins/compose/src/test/test-projects/application/jvm/settings.gradle
  32. 2
      gradle-plugins/compose/src/test/test-projects/application/jvmKotlinDsl/settings.gradle
  33. 2
      gradle-plugins/compose/src/test/test-projects/application/macOptions/settings.gradle
  34. 2
      gradle-plugins/compose/src/test/test-projects/application/macSign/settings.gradle
  35. 2
      gradle-plugins/compose/src/test/test-projects/application/moduleClashCli/settings.gradle
  36. 27
      gradle-plugins/compose/src/test/test-projects/application/mpp/build.gradle
  37. 4
      gradle-plugins/compose/src/test/test-projects/application/mpp/settings.gradle
  38. 0
      gradle-plugins/compose/src/test/test-projects/application/mpp/src/desktopMain/kotlin/main.kt
  39. 2
      gradle-plugins/compose/src/test/test-projects/application/optionsWithSpaces/settings.gradle
  40. 2
      gradle-plugins/compose/src/test/test-projects/application/proguard/settings.gradle
  41. 2
      gradle-plugins/compose/src/test/test-projects/application/resources/settings.gradle
  42. 2
      gradle-plugins/compose/src/test/test-projects/application/unpackSkiko/settings.gradle
  43. 2
      gradle-plugins/compose/src/test/test-projects/misc/jsMpp/settings.gradle
  44. 2
      gradle-plugins/compose/src/test/test-projects/misc/jvmPreview/settings.gradle
  45. 21
      gradle-plugins/gradle.properties

5
README.md

@ -47,11 +47,10 @@ Note that when you use Compose Multiplatform, you setup your project differently
* [codeviewer](examples/codeviewer) - File Browser and Code Viewer application for Android and Desktop * [codeviewer](examples/codeviewer) - File Browser and Code Viewer application for Android and Desktop
* [imageviewer](examples/imageviewer) - Image Viewer application for Android and Desktop * [imageviewer](examples/imageviewer) - Image Viewer application for Android and Desktop
* [issues](examples/issues) - GitHub issue tracker with an adaptive UI and ktor-client * [issues](examples/issues) - GitHub issue tracker with an adaptive UI and ktor-client
* [game](examples/falling-balls) - Simple game * [Falling Balls](examples/falling-balls) - Simple game
* [game](experimental/examples/falling-balls-mpp) - Simple game for web target
* [compose-bird](examples/web-compose-bird) - A flappy bird clone using Compose for Web * [compose-bird](examples/web-compose-bird) - A flappy bird clone using Compose for Web
* [notepad](examples/notepad) - Notepad, using the new experimental Composable Window API * [notepad](examples/notepad) - Notepad, using the new experimental Composable Window API
* [todoapp](examples/todoapp) - TODO items tracker with persistence and multiple screens * [todoapp](examples/todoapp) - TODO items tracker with persistence and multiple screens, written with external navigation library
* [todoapp-lite](examples/todoapp-lite) - A simplified version of [todoapp](examples/todoapp), fully based on Compose * [todoapp-lite](examples/todoapp-lite) - A simplified version of [todoapp](examples/todoapp), fully based on Compose
* [widgets gallery](examples/widgets-gallery) - Gallery of standard widgets * [widgets gallery](examples/widgets-gallery) - Gallery of standard widgets
* [IDEA plugin](examples/intellij-plugin) - Plugin for IDEA using Compose for Desktop * [IDEA plugin](examples/intellij-plugin) - Plugin for IDEA using Compose for Desktop

9
gradle-plugins/buildSrc/src/main/kotlin/BuildProperties.kt

@ -15,7 +15,14 @@ object BuildProperties {
fun composeVersion(project: Project): String = fun composeVersion(project: Project): String =
System.getenv("COMPOSE_GRADLE_PLUGIN_COMPOSE_VERSION") System.getenv("COMPOSE_GRADLE_PLUGIN_COMPOSE_VERSION")
?: project.findProperty("compose.version") as String ?: project.findProperty("compose.version") as String
fun composeCompilerVersion(project: Project): String = project.findProperty("compose.compiler.version") as String fun composeCompilerVersion(project: Project): String =
project.findProperty("compose.compiler.version") as String
fun composeCompilerCompatibleKotlinVersion(project: Project): String =
project.findProperty("compose.compiler.compatible.kotlin.version") as String
fun testsAndroidxCompilerVersion(project: Project): String =
project.findProperty("compose.tests.androidx.compiler.version") as String
fun testsAndroidxCompilerCompatibleVersion(project: Project): String =
project.findProperty("compose.tests.androidx.compatible.kotlin.version") as String
fun deployVersion(project: Project): String = fun deployVersion(project: Project): String =
System.getenv("COMPOSE_GRADLE_PLUGIN_VERSION") System.getenv("COMPOSE_GRADLE_PLUGIN_VERSION")
?: project.findProperty("deploy.version") as String ?: project.findProperty("deploy.version") as String

14
gradle-plugins/compose/build.gradle.kts

@ -66,6 +66,7 @@ dependencies {
testImplementation(gradleTestKit()) testImplementation(gradleTestKit())
testImplementation(platform("org.junit:junit-bom:5.7.0")) testImplementation(platform("org.junit:junit-bom:5.7.0"))
testImplementation("org.junit.jupiter:junit-jupiter") testImplementation("org.junit.jupiter:junit-jupiter")
testImplementation(kotlin("gradle-plugin-api"))
// include relocated download task to avoid potential runtime conflicts // include relocated download task to avoid potential runtime conflicts
embedded("de.undercouch:gradle-download-task:4.1.1") embedded("de.undercouch:gradle-download-task:4.1.1")
@ -105,7 +106,7 @@ val javaHomeForTests: String? = when {
} }
val isWindows = getCurrentOperatingSystem().isWindows val isWindows = getCurrentOperatingSystem().isWindows
val gradleTestsPattern = "org.jetbrains.compose.gradle.*" val gradleTestsPattern = "org.jetbrains.compose.test.tests.integration.*"
// check we don't accidentally including unexpected classes (e.g. from embedded dependencies) // check we don't accidentally including unexpected classes (e.g. from embedded dependencies)
val checkJar by tasks.registering { val checkJar by tasks.registering {
@ -161,7 +162,7 @@ fun testGradleVersion(gradleVersion: String) {
tasks.test.get().let { defaultTest -> tasks.test.get().let { defaultTest ->
classpath = defaultTest.classpath classpath = defaultTest.classpath
} }
systemProperty("gradle.version.for.tests", gradleVersion) systemProperty("compose.tests.gradle.version", gradleVersion)
filter { filter {
includeTestsMatching(gradleTestsPattern) includeTestsMatching(gradleTestsPattern)
} }
@ -177,8 +178,13 @@ tasks.withType<Test>().configureEach {
configureJavaForComposeTest() configureJavaForComposeTest()
dependsOn(":publishToMavenLocal") dependsOn(":publishToMavenLocal")
systemProperty("compose.plugin.version", BuildProperties.deployVersion(project))
systemProperty("kotlin.version", project.property("kotlin.version").toString()) systemProperty("compose.tests.compose.gradle.plugin.version", BuildProperties.deployVersion(project))
for ((k, v) in project.properties) {
if (k.startsWith("compose.")) {
systemProperty(k, v.toString())
}
}
} }
task("printAllAndroidxReplacements") { task("printAllAndroidxReplacements") {

23
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeCompilerKotlinSupportPlugin.kt

@ -5,25 +5,32 @@
package org.jetbrains.compose package org.jetbrains.compose
import org.gradle.api.Project
import org.gradle.api.provider.Provider import org.gradle.api.provider.Provider
import org.jetbrains.compose.internal.ComposeCompilerArtifactProvider
import org.jetbrains.compose.internal.webExt import org.jetbrains.compose.internal.webExt
import org.jetbrains.kotlin.gradle.plugin.* import org.jetbrains.kotlin.gradle.plugin.*
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTarget import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTarget
class ComposeCompilerKotlinSupportPlugin : KotlinCompilerPluginSupportPlugin { class ComposeCompilerKotlinSupportPlugin : KotlinCompilerPluginSupportPlugin {
private var composeCompilerArtifactProvider = ComposeCompilerArtifactProvider { null }
override fun apply(target: Project) {
super.apply(target)
target.plugins.withType(ComposePlugin::class.java) {
val composeExt = target.extensions.getByType(ComposeExtension::class.java)
composeCompilerArtifactProvider = ComposeCompilerArtifactProvider { composeExt.kotlinCompilerPlugin.orNull }
}
}
override fun getCompilerPluginId(): String = override fun getCompilerPluginId(): String =
"androidx.compose.compiler.plugins.kotlin" "androidx.compose.compiler.plugins.kotlin"
override fun getPluginArtifactForNative(): SubpluginArtifact =
composeCompilerArtifact("compiler-hosted")
override fun getPluginArtifact(): SubpluginArtifact = override fun getPluginArtifact(): SubpluginArtifact =
composeCompilerArtifact("compiler") composeCompilerArtifactProvider.compilerArtifact
private fun composeCompilerArtifact(artifactId: String) = override fun getPluginArtifactForNative(): SubpluginArtifact =
SubpluginArtifact( composeCompilerArtifactProvider.compilerHostedArtifact
groupId = "org.jetbrains.compose.compiler", artifactId = artifactId, version = ComposeBuildConfig.composeCompilerVersion
)
override fun isApplicable(kotlinCompilation: KotlinCompilation<*>): Boolean = override fun isApplicable(kotlinCompilation: KotlinCompilation<*>): Boolean =
when (kotlinCompilation.target.platformType) { when (kotlinCompilation.target.platformType) {

11
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposeExtension.kt

@ -5,6 +5,15 @@
package org.jetbrains.compose package org.jetbrains.compose
import org.gradle.api.model.ObjectFactory
import org.gradle.api.plugins.ExtensionAware import org.gradle.api.plugins.ExtensionAware
import org.gradle.api.provider.Property
import org.jetbrains.compose.desktop.application.internal.nullableProperty
import javax.inject.Inject
abstract class ComposeExtension @Inject constructor(
objects: ObjectFactory
) : ExtensionAware {
val kotlinCompilerPlugin: Property<String?> = objects.nullableProperty()
}
abstract class ComposeExtension : ExtensionAware

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"

66
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/ComposeCompilerArtifactProvider.kt

@ -0,0 +1,66 @@
/*
* Copyright 2020-2022 JetBrains s.r.o. and respective authors and developers.
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
*/
package org.jetbrains.compose.internal
import org.jetbrains.compose.ComposeBuildConfig
import org.jetbrains.kotlin.gradle.plugin.SubpluginArtifact
internal class ComposeCompilerArtifactProvider(private val customPluginString: () -> String?) {
val compilerArtifact: SubpluginArtifact
get() {
val customPlugin = customPluginString()
val customCoordinates = customPlugin?.split(":")
return when (customCoordinates?.size) {
null -> DefaultCompiler.pluginArtifact
1 -> {
val customVersion = customCoordinates[0]
check(customVersion.isNotBlank()) { "'compose.kotlinCompilerPlugin' cannot be blank!" }
DefaultCompiler.pluginArtifact.copy(version = customVersion)
}
3 -> DefaultCompiler.pluginArtifact.copy(
groupId = customCoordinates[0],
artifactId = customCoordinates[1],
version = customCoordinates[2]
)
else -> error("""
Illegal format of 'compose.kotlinCompilerPlugin' property.
Expected format: either '<VERSION>' or '<GROUP_ID>:<ARTIFACT_ID>:<VERSION>'
Actual value: '$customPlugin'
""".trimIndent())
}
}
val compilerHostedArtifact: SubpluginArtifact
get() = compilerArtifact.run {
val newArtifactId =
if (groupId == DefaultCompiler.GROUP_ID && artifactId == DefaultCompiler.ARTIFACT_ID) {
DefaultCompiler.HOSTED_ARTIFACT_ID
} else artifactId
copy(artifactId = newArtifactId)
}
internal object DefaultCompiler {
const val GROUP_ID = "org.jetbrains.compose.compiler"
const val ARTIFACT_ID = "compiler"
const val HOSTED_ARTIFACT_ID = "compiler-hosted"
const val VERSION = ComposeBuildConfig.composeCompilerVersion
val pluginArtifact: SubpluginArtifact
get() = SubpluginArtifact(groupId = GROUP_ID, artifactId = ARTIFACT_ID, version = VERSION)
}
}
internal fun SubpluginArtifact.copy(
groupId: String? = null,
artifactId: String? = null,
version: String? = null
): SubpluginArtifact =
SubpluginArtifact(
groupId = groupId ?: this.groupId,
artifactId = artifactId ?: this.artifactId,
version = version ?: this.version
)

11
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/TestKotlinVersion.kt

@ -1,11 +0,0 @@
/*
* Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers.
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
*/
package org.jetbrains.compose.test
@Suppress("EnumEntryName")
enum class TestKotlinVersion(val versionString: String) {
Default(TestProperties.defaultKotlinVersion)
}

20
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/TestProperties.kt

@ -1,20 +0,0 @@
/*
* Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers.
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
*/
package org.jetbrains.compose.test
object TestProperties {
val defaultKotlinVersion: String
get() = notNullSystemProperty("kotlin.version")
val composeVersion: String
get() = notNullSystemProperty("compose.plugin.version")
val gradleVersionForTests: String?
get() = System.getProperty("gradle.version.for.tests")
private fun notNullSystemProperty(property: String): String =
System.getProperty(property) ?: error("The '$property' system property is not set")
}

52
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/gradle/DesktopApplicationTest.kt → gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/DesktopApplicationTest.kt

@ -1,21 +1,23 @@
/* /*
* Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. * Copyright 2020-2022 JetBrains s.r.o. and respective authors and developers.
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
*/ */
package org.jetbrains.compose.gradle 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.test.* import org.jetbrains.compose.internal.uppercaseFirstChar
import org.junit.jupiter.api.Assertions.assertEquals import org.jetbrains.compose.test.utils.*
import org.junit.jupiter.api.Assumptions
import org.junit.jupiter.api.Test
import java.io.File import java.io.File
import java.util.* import java.util.*
import java.util.jar.JarFile import java.util.jar.JarFile
import kotlin.collections.HashSet import kotlin.collections.HashSet
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assumptions
import org.junit.jupiter.api.Test
class DesktopApplicationTest : GradlePluginTestBase() { class DesktopApplicationTest : GradlePluginTestBase() {
@Test @Test
@ -56,9 +58,21 @@ class DesktopApplicationTest : GradlePluginTestBase() {
} }
} }
@Test
fun testAndroidxCompiler() = with(testProject(TestProjects.androidxCompiler, defaultAndroidxCompilerEnvironment)) {
gradle(":runDistributable").build().checks { check ->
val actualMainImage = file("main-image.actual.png")
val expectedMainImage = file("main-image.expected.png")
assert(actualMainImage.readBytes().contentEquals(expectedMainImage.readBytes())) {
"The actual image '$actualMainImage' does not match the expected image '$expectedMainImage'"
}
}
}
@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
@ -78,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"
@ -108,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
@ -252,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)
} }
} }
} }
@ -271,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)
} }
} }
} }
@ -290,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)
} }
} }
} }

14
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/gradle/GradlePluginTest.kt → gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/GradlePluginTest.kt

@ -1,25 +1,23 @@
/* /*
* Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. * Copyright 2020-2022 JetBrains s.r.o. and respective authors and developers.
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
*/ */
package org.jetbrains.compose.gradle package org.jetbrains.compose.test.tests.integration
import org.gradle.testkit.runner.TaskOutcome
import org.jetbrains.compose.desktop.ui.tooling.preview.rpc.PreviewLogger import org.jetbrains.compose.desktop.ui.tooling.preview.rpc.PreviewLogger
import org.jetbrains.compose.desktop.ui.tooling.preview.rpc.RemoteConnection import org.jetbrains.compose.desktop.ui.tooling.preview.rpc.RemoteConnection
import org.jetbrains.compose.desktop.ui.tooling.preview.rpc.receiveConfigFromGradle import org.jetbrains.compose.desktop.ui.tooling.preview.rpc.receiveConfigFromGradle
import org.jetbrains.compose.test.GradlePluginTestBase import org.jetbrains.compose.test.utils.*
import org.jetbrains.compose.test.TestKotlinVersion
import org.jetbrains.compose.test.TestProjects
import org.jetbrains.compose.test.checks
import org.junit.jupiter.api.Test
import java.net.ServerSocket import java.net.ServerSocket
import java.net.Socket import java.net.Socket
import java.net.SocketTimeoutException import java.net.SocketTimeoutException
import java.util.concurrent.atomic.AtomicBoolean import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.atomic.AtomicInteger import java.util.concurrent.atomic.AtomicInteger
import kotlin.concurrent.thread import kotlin.concurrent.thread
import org.gradle.testkit.runner.TaskOutcome
import org.junit.jupiter.api.Test
class GradlePluginTest : GradlePluginTestBase() { class GradlePluginTest : GradlePluginTestBase() {
@Test @Test

107
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/unit/ComposeCompilerArtifactProviderTest.kt

@ -0,0 +1,107 @@
/*
* Copyright 2020-2022 JetBrains s.r.o. and respective authors and developers.
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
*/
package org.jetbrains.compose.test.tests.unit
import org.jetbrains.compose.internal.ComposeCompilerArtifactProvider
import org.jetbrains.compose.internal.copy
import org.jetbrains.compose.test.utils.TestProperties
import org.jetbrains.kotlin.gradle.plugin.SubpluginArtifact
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.Assertions.*
internal class ComposeCompilerArtifactProviderTest {
@Test
fun defaultCompilerArtifact() {
assertArtifactEquals(
Expected.jbCompiler,
Actual.compiler(null)
)
}
@Test
fun defaultCompilerHostedArtifact() {
assertArtifactEquals(
Expected.jbCompilerHosted,
Actual.compilerHosted(null)
)
}
@Test
fun customVersion() {
assertArtifactEquals(
Expected.jbCompiler.copy(version = "10.20.30"),
Actual.compiler("10.20.30")
)
}
@Test
fun customCompiler() {
assertArtifactEquals(
Expected.googleCompiler.copy(version = "1.3.1"),
Actual.compiler("androidx.compose.compiler:compiler:1.3.1")
)
}
@Test
fun customCompilerHosted() {
// check that we don't replace artifactId for non-jb compiler
assertArtifactEquals(
Expected.googleCompiler.copy(version = "1.3.1"),
Actual.compilerHosted("androidx.compose.compiler:compiler:1.3.1")
)
}
@Test
fun illegalCompiler() {
testIllegalCompiler("androidx.compose.compiler:compiler")
testIllegalCompiler("a:b:c:d")
testIllegalCompiler("")
}
private fun testIllegalCompiler(pluginString: String?) {
try {
Actual.compiler(pluginString)
} catch (e: Exception) {
return
}
error("Expected error, but illegal value was accepted: '$pluginString'")
}
object Actual {
fun compiler(pluginString: String?) =
ComposeCompilerArtifactProvider { pluginString }.compilerArtifact
fun compilerHosted(pluginString: String?) =
ComposeCompilerArtifactProvider { pluginString }.compilerHostedArtifact
}
object Expected {
val jbCompiler: SubpluginArtifact
get() = SubpluginArtifact(
groupId = "org.jetbrains.compose.compiler",
artifactId = "compiler",
version = TestProperties.composeCompilerVersion
)
val jbCompilerHosted: SubpluginArtifact
get() = jbCompiler.copy(artifactId = "compiler-hosted")
val googleCompiler: SubpluginArtifact
get() = jbCompiler.copy(groupId = "androidx.compose.compiler")
}
private fun assertArtifactEquals(
expected: SubpluginArtifact,
actual: SubpluginArtifact
) {
assertEquals(expected.asString(), actual.asString())
}
private fun SubpluginArtifact.asString(): String =
"SubpluginArtifact(groupId = '$groupId', artifactId = '$artifactId', version = '$version')"
}

9
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/FileHashTest.kt → gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/unit/FileHashTest.kt

@ -1,14 +1,15 @@
/* /*
* Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. * Copyright 2020-2022 JetBrains s.r.o. and respective authors and developers.
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
*/ */
package org.jetbrains.compose package org.jetbrains.compose.test.tests.unit
import org.gradle.internal.impldep.org.testng.Assert
import org.jetbrains.compose.desktop.application.internal.OS import org.jetbrains.compose.desktop.application.internal.OS
import org.jetbrains.compose.desktop.application.internal.currentOS import org.jetbrains.compose.desktop.application.internal.currentOS
import org.jetbrains.compose.desktop.application.internal.files.contentHash import org.jetbrains.compose.desktop.application.internal.files.contentHash
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import org.junit.jupiter.api.io.TempDir import org.junit.jupiter.api.io.TempDir
import java.io.File import java.io.File
@ -40,7 +41,7 @@ class FileHashTest {
val initHash = initJar.contentHash() val initHash = initJar.contentHash()
val modifiedHash = modifiedJar.contentHash() val modifiedHash = modifiedJar.contentHash()
Assert.assertNotEquals(modifiedHash, initHash) assertNotEquals(modifiedHash, initHash)
} }
private fun createJar(outputFileName: String, vararg files: File): File { private fun createJar(outputFileName: String, vararg files: File): File {

10
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/GradlePluginTestBase.kt → gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/GradlePluginTestBase.kt

@ -1,9 +1,9 @@
/* /*
* Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. * Copyright 2020-2022 JetBrains s.r.o. and respective authors and developers.
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
*/ */
package org.jetbrains.compose.test package org.jetbrains.compose.test.utils
import org.junit.jupiter.api.io.TempDir import org.junit.jupiter.api.io.TempDir
import java.io.File import java.io.File
@ -15,6 +15,12 @@ abstract class GradlePluginTestBase {
val defaultTestEnvironment: TestEnvironment val defaultTestEnvironment: TestEnvironment
get() = TestEnvironment(workingDir = testWorkDir) get() = TestEnvironment(workingDir = testWorkDir)
val defaultAndroidxCompilerEnvironment: TestEnvironment
get() = defaultTestEnvironment.copy(
kotlinVersion = TestKotlinVersion.AndroidxCompatible,
composeCompilerArtifact = "androidx.compose.compiler:compiler:${TestProperties.androidxCompilerVersion}"
)
fun testProject( fun testProject(
name: String, name: String,
testEnvironment: TestEnvironment = defaultTestEnvironment testEnvironment: TestEnvironment = defaultTestEnvironment

2
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/GradleTestNameGenerator.kt → gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/GradleTestNameGenerator.kt

@ -3,7 +3,7 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
*/ */
package org.jetbrains.compose.test package org.jetbrains.compose.test.utils
import org.junit.jupiter.api.DisplayNameGenerator import org.junit.jupiter.api.DisplayNameGenerator

12
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestKotlinVersion.kt

@ -0,0 +1,12 @@
/*
* Copyright 2020-2022 JetBrains s.r.o. and respective authors and developers.
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
*/
package org.jetbrains.compose.test.utils
@Suppress("EnumEntryName")
enum class TestKotlinVersion(val versionString: String) {
Default(TestProperties.composeCompilerCompatibleKotlinVersion),
AndroidxCompatible(TestProperties.androidxCompilerCompatibleKotlinVersion)
}

14
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/TestProject.kt → gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProject.kt

@ -1,9 +1,9 @@
/* /*
* Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. * Copyright 2020-2022 JetBrains s.r.o. and respective authors and developers.
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
*/ */
package org.jetbrains.compose.test package org.jetbrains.compose.test.utils
import org.gradle.testkit.runner.GradleRunner import org.gradle.testkit.runner.GradleRunner
import org.jetbrains.compose.desktop.application.internal.ComposeProperties import org.jetbrains.compose.desktop.application.internal.ComposeProperties
@ -12,7 +12,8 @@ import java.io.File
data class TestEnvironment( data class TestEnvironment(
val workingDir: File, val workingDir: File,
val kotlinVersion: TestKotlinVersion = TestKotlinVersion.Default, val kotlinVersion: TestKotlinVersion = TestKotlinVersion.Default,
val composeVersion: String = TestProperties.composeVersion val composeGradlePluginVersion: String = TestProperties.composeGradlePluginVersion,
val composeCompilerArtifact: String? = null
) )
class TestProject( class TestProject(
@ -38,9 +39,12 @@ class TestProject(
if (orig.name.endsWith(".gradle") || orig.name.endsWith(".gradle.kts")) { if (orig.name.endsWith(".gradle") || orig.name.endsWith(".gradle.kts")) {
val origContent = orig.readText() val origContent = orig.readText()
val newContent = origContent var newContent = origContent
.replace("COMPOSE_VERSION_PLACEHOLDER", testEnvironment.composeVersion) .replace("COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER", testEnvironment.composeGradlePluginVersion)
.replace("KOTLIN_VERSION_PLACEHOLDER", testEnvironment.kotlinVersion.versionString) .replace("KOTLIN_VERSION_PLACEHOLDER", testEnvironment.kotlinVersion.versionString)
if (testEnvironment.composeCompilerArtifact != null) {
newContent = newContent.replace("COMPOSE_COMPILER_ARTIFACT_PLACEHOLDER", testEnvironment.composeCompilerArtifact)
}
target.writeText(newContent) target.writeText(newContent)
} else { } else {
orig.copyTo(target) orig.copyTo(target)

5
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/TestProjects.kt → gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProjects.kt

@ -1,14 +1,15 @@
/* /*
* Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. * Copyright 2020-2022 JetBrains s.r.o. and respective authors and developers.
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
*/ */
package org.jetbrains.compose.test package org.jetbrains.compose.test.utils
object TestProjects { object TestProjects {
const val jvm = "application/jvm" const val jvm = "application/jvm"
const val mpp = "application/mpp" const val mpp = "application/mpp"
const val proguard = "application/proguard" const val proguard = "application/proguard"
const val androidxCompiler = "application/androidx-compiler"
const val jvmKotlinDsl = "application/jvmKotlinDsl" const val jvmKotlinDsl = "application/jvmKotlinDsl"
const val moduleClashCli = "application/moduleClashCli" const val moduleClashCli = "application/moduleClashCli"
const val javaLogger = "application/javaLogger" const val javaLogger = "application/javaLogger"

29
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/TestProperties.kt

@ -0,0 +1,29 @@
/*
* Copyright 2020-2022 JetBrains s.r.o. and respective authors and developers.
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
*/
package org.jetbrains.compose.test.utils
object TestProperties {
val composeCompilerVersion: String
get() = notNullSystemProperty("compose.compiler.version")
val composeCompilerCompatibleKotlinVersion: String
get() = notNullSystemProperty("compose.compiler.compatible.kotlin.version")
val androidxCompilerVersion: String
get() = notNullSystemProperty("compose.tests.androidx.compiler.version")
val androidxCompilerCompatibleKotlinVersion: String
get() = notNullSystemProperty("compose.tests.androidx.compiler.compatible.kotlin.version")
val composeGradlePluginVersion: String
get() = notNullSystemProperty("compose.tests.compose.gradle.plugin.version")
val gradleVersionForTests: String?
get() = System.getProperty("compose.tests.gradle.version")
private fun notNullSystemProperty(property: String): String =
System.getProperty(property) ?: error("The '$property' system property is not set")
}

6
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/assertUtils.kt → gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/assertUtils.kt

@ -1,16 +1,14 @@
/* /*
* Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. * Copyright 2020-2022 JetBrains s.r.o. and respective authors and developers.
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
*/ */
package org.jetbrains.compose.test package org.jetbrains.compose.test.utils
import org.gradle.internal.impldep.junit.framework.Assert
import org.gradle.testkit.runner.BuildResult import org.gradle.testkit.runner.BuildResult
import org.gradle.testkit.runner.TaskOutcome import org.gradle.testkit.runner.TaskOutcome
import org.junit.jupiter.api.Assertions import org.junit.jupiter.api.Assertions
import java.io.File import java.io.File
import kotlin.math.exp
internal fun <T> Collection<T>.checkContains(vararg elements: T) { internal fun <T> Collection<T>.checkContains(vararg elements: T) {
val expectedElements = elements.toMutableSet() val expectedElements = elements.toMutableSet()

2
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/fileUtils.kt → gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/fileUtils.kt

@ -3,7 +3,7 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
*/ */
package org.jetbrains.compose.test package org.jetbrains.compose.test.utils
import java.io.File import java.io.File

2
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/processUtils.kt → gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/utils/processUtils.kt

@ -3,7 +3,7 @@
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. * Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
*/ */
package org.jetbrains.compose.test package org.jetbrains.compose.test.utils
import java.io.File import java.io.File

2
gradle-plugins/compose/src/test/resources/junit-platform.properties

@ -1 +1 @@
junit.jupiter.displayname.generator.default=org.jetbrains.compose.test.GradleTestNameGenerator junit.jupiter.displayname.generator.default=org.jetbrains.compose.test.utils.GradleTestNameGenerator

31
gradle-plugins/compose/src/test/test-projects/application/androidx-compiler/build.gradle

@ -0,0 +1,31 @@
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
plugins {
id "org.jetbrains.kotlin.jvm"
id "org.jetbrains.compose"
}
repositories {
google()
jetbrainsCompose()
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib"
implementation compose.desktop.currentOs
}
compose {
kotlinCompilerPlugin.set("COMPOSE_COMPILER_ARTIFACT_PLACEHOLDER")
desktop {
application {
mainClass = "Main"
args(project.projectDir.absolutePath)
nativeDistributions {
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
}
args(project.projectDir.absolutePath)
}
}
}

BIN
gradle-plugins/compose/src/test/test-projects/application/androidx-compiler/main-image.expected.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 B

11
gradle-plugins/compose/src/test/test-projects/application/androidx-compiler/settings.gradle

@ -0,0 +1,11 @@
pluginManagement {
plugins {
id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER'
id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER'
}
repositories {
mavenLocal()
gradlePluginPortal()
}
}
rootProject.name = "simple"

76
gradle-plugins/compose/src/test/test-projects/application/androidx-compiler/src/main/kotlin/Main.kt

@ -0,0 +1,76 @@
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.GenericShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.ExperimentalComposeUiApi
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.renderComposeScene
import org.jetbrains.skia.EncodedImageFormat
import java.io.File
import java.util.*
object Main {
@JvmStatic
@OptIn(ExperimentalComposeUiApi::class)
fun main(args: Array<String>) {
val workingDir = args.getOrNull(0)?.let { File(it) }
workingDir?.mkdirs()
if (workingDir == null || !workingDir.isDirectory) {
error("Working directory must be passes as the first argument. '$workingDir' is not a directory")
}
val image = renderComposeScene(height = 10, width = 10) {
mainShape()
}
val encodedImage = image.encodeToData(EncodedImageFormat.PNG) ?: error("Could not encode image as png")
workingDir.resolve("main-image.actual.png").writeBytes(encodedImage.bytes)
val mainMethods = this.javaClass.declaredMethods
.mapTo(TreeSet()) { it.name }
.joinToString("\n")
workingDir.resolve("main-methods.actual.txt").writeText(mainMethods)
}
@Composable
fun mainShape() {
triangle(Color.Magenta)
}
@Composable
fun unused() {
transitivelyUnused()
}
@Composable
fun transitivelyUnused() {
triangle(Color.Gray)
}
@Composable
fun keptByKeepRule() {
fillShape(Color.Blue, CircleShape)
}
}
@Composable
fun triangle(color: Color) {
fillShape(color, GenericShape { size, _ ->
moveTo(size.width / 2f, 0f)
lineTo(size.width, size.height)
lineTo(0f, size.height)
})
}
@Composable
fun fillShape(color: Color, shape: Shape){
Column(modifier = Modifier.fillMaxWidth().wrapContentSize(Alignment.Center)) {
Box(
modifier = Modifier.clip(shape).fillMaxSize().background(color)
)
}
}

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

@ -1,7 +1,7 @@
pluginManagement { pluginManagement {
plugins { plugins {
id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER' id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER'
id 'org.jetbrains.compose' version 'COMPOSE_VERSION_PLACEHOLDER' id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER'
} }
repositories { repositories {
mavenLocal() mavenLocal()

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

@ -1,7 +1,7 @@
pluginManagement { pluginManagement {
plugins { plugins {
id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER' id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER'
id 'org.jetbrains.compose' version 'COMPOSE_VERSION_PLACEHOLDER' id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER'
} }
repositories { repositories {
mavenLocal() mavenLocal()

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

@ -1,7 +1,7 @@
pluginManagement { pluginManagement {
plugins { plugins {
id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER' id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER'
id 'org.jetbrains.compose' version 'COMPOSE_VERSION_PLACEHOLDER' id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER'
} }
repositories { repositories {
mavenLocal() mavenLocal()

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

@ -1,7 +1,7 @@
pluginManagement { pluginManagement {
plugins { plugins {
id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER' id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER'
id 'org.jetbrains.compose' version 'COMPOSE_VERSION_PLACEHOLDER' id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER'
} }
repositories { repositories {
mavenLocal() mavenLocal()

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

@ -1,7 +1,7 @@
pluginManagement { pluginManagement {
plugins { plugins {
id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER' id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER'
id 'org.jetbrains.compose' version 'COMPOSE_VERSION_PLACEHOLDER' id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER'
} }
repositories { repositories {
mavenLocal() mavenLocal()

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

@ -1,7 +1,7 @@
pluginManagement { pluginManagement {
plugins { plugins {
id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER' id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER'
id 'org.jetbrains.compose' version 'COMPOSE_VERSION_PLACEHOLDER' id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER'
} }
repositories { repositories {
mavenLocal() mavenLocal()

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

@ -1,7 +1,7 @@
pluginManagement { pluginManagement {
plugins { plugins {
id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER' id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER'
id 'org.jetbrains.compose' version 'COMPOSE_VERSION_PLACEHOLDER' id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER'
} }
repositories { repositories {
mavenLocal() mavenLocal()

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

@ -1,7 +1,7 @@
pluginManagement { pluginManagement {
plugins { plugins {
id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER' id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER'
id 'org.jetbrains.compose' version 'COMPOSE_VERSION_PLACEHOLDER' id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER'
} }
repositories { repositories {
mavenLocal() mavenLocal()

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"

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

@ -1,11 +1,13 @@
pluginManagement { 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_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

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

@ -1,7 +1,7 @@
pluginManagement { pluginManagement {
plugins { plugins {
id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER' id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER'
id 'org.jetbrains.compose' version 'COMPOSE_VERSION_PLACEHOLDER' id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER'
} }
repositories { repositories {
mavenLocal() mavenLocal()

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

@ -1,7 +1,7 @@
pluginManagement { pluginManagement {
plugins { plugins {
id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER' id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER'
id 'org.jetbrains.compose' version 'COMPOSE_VERSION_PLACEHOLDER' id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER'
} }
repositories { repositories {
mavenLocal() mavenLocal()

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

@ -1,7 +1,7 @@
pluginManagement { pluginManagement {
plugins { plugins {
id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER' id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER'
id 'org.jetbrains.compose' version 'COMPOSE_VERSION_PLACEHOLDER' id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER'
} }
repositories { repositories {
mavenLocal() mavenLocal()

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

@ -1,7 +1,7 @@
pluginManagement { pluginManagement {
plugins { plugins {
id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER' id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER'
id 'org.jetbrains.compose' version 'COMPOSE_VERSION_PLACEHOLDER' id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER'
} }
repositories { repositories {
mavenLocal() mavenLocal()

2
gradle-plugins/compose/src/test/test-projects/misc/jsMpp/settings.gradle

@ -1,7 +1,7 @@
pluginManagement { 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_VERSION_PLACEHOLDER' id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER'
} }
repositories { repositories {
mavenLocal() mavenLocal()

2
gradle-plugins/compose/src/test/test-projects/misc/jvmPreview/settings.gradle

@ -2,7 +2,7 @@ pluginManagement {
plugins { plugins {
id 'org.jetbrains.kotlin.multiplatform' version 'KOTLIN_VERSION_PLACEHOLDER' id 'org.jetbrains.kotlin.multiplatform' version 'KOTLIN_VERSION_PLACEHOLDER'
id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER' id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER'
id 'org.jetbrains.compose' version 'COMPOSE_VERSION_PLACEHOLDER' id 'org.jetbrains.compose' version 'COMPOSE_GRADLE_PLUGIN_VERSION_PLACEHOLDER'
} }
repositories { repositories {
mavenLocal() mavenLocal()

21
gradle-plugins/gradle.properties

@ -1,25 +1,16 @@
org.gradle.parallel=true org.gradle.parallel=true
kotlin.code.style=official kotlin.code.style=official
# A version of Compose libraries,
# that will be used by published Gradle plugin,
# unless overridden by COMPOSE_GRADLE_PLUGIN_COMPOSE_VERSION env var.
#
# __LATEST_COMPOSE_RELEASE_VERSION__ # __LATEST_COMPOSE_RELEASE_VERSION__
# Default version of Compose Libraries used by Gradle plugin
compose.version=1.2.0-beta02 compose.version=1.2.0-beta02
# Default version of Compose Compiler used by Gradle plugin
compose.compiler.version=1.3.0-alpha01 compose.compiler.version=1.3.0-alpha01
# Default version of Kotlin compatible with compose.compiler.version
# See the corresponding version here: https://developer.android.com/jetpack/androidx/releases/compose-kotlin
# (note, that for the 'org.jetbrains.compose` build we usualy keep only Major and Minor versions the same)
# This is only used on CI for now.
compose.compiler.compatible.kotlin.version=1.7.10 compose.compiler.compatible.kotlin.version=1.7.10
# https://developer.android.com/jetpack/androidx/releases/compose-kotlin
# A version of Kotlin expected by __LATEST_COMPOSE_RELEASE_VERSION__ compose.tests.androidx.compiler.version=1.3.1
# This Kotlin version should be used in test or for checking plugin's compatibility, compose.tests.androidx.compiler.compatible.kotlin.version=1.7.10
# not for building the Gradle plugin itself!
# __KOTLIN_COMPOSE_VERSION__
kotlin.version=1.7.10
# A version of Gradle plugin, that will be published, # A version of Gradle plugin, that will be published,
# unless overridden by COMPOSE_GRADLE_PLUGIN_VERSION env var. # unless overridden by COMPOSE_GRADLE_PLUGIN_VERSION env var.

Loading…
Cancel
Save