Browse Source

Additional CI fixes (#1696)

* Fix components script compilation

* Add script to run Gradle with Compose properties set up

It's useful for running a single task in
the included Compose build.

* Set default JVM target to 11 if it is lower

* Update Compose submodule
pull/1703/head
Alexey Tsvetkov 3 years ago committed by GitHub
parent
commit
f3a403b321
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      components/build.gradle.kts
  2. 2
      compose/frameworks/support
  3. 8
      compose/scripts/runGradle
  4. 11
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposePlugin.kt
  5. 6
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/ComposeProjectProperties.kt
  6. 24
      gradle-plugins/compose/src/test/test-projects/init.gradle

4
components/build.gradle.kts

@ -1,3 +1,7 @@
plugins {
kotlin("multiplatform") apply false
}
subprojects { subprojects {
version = findProperty("deploy.version") ?: property("compose.version")!! version = findProperty("deploy.version") ?: property("compose.version")!!

2
compose/frameworks/support

@ -1 +1 @@
Subproject commit fe220467abcf2368966a051b732752513ffeceda Subproject commit 3ebf1d446089cc8da34bb1b906982327af7b8249

8
compose/scripts/runGradle

@ -0,0 +1,8 @@
#!/bin/bash
cd "$(dirname "$0")"
. ./prepare
pushd ..
./gradlew $COMPOSE_DEFAULT_GRADLE_ARGS "$@" || exit 1
popd

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

@ -19,6 +19,7 @@ import org.gradle.api.artifacts.repositories.MavenArtifactRepository
import org.gradle.api.plugins.ExtensionAware import org.gradle.api.plugins.ExtensionAware
import org.jetbrains.compose.android.AndroidExtension import org.jetbrains.compose.android.AndroidExtension
import org.jetbrains.compose.desktop.DesktopExtension import org.jetbrains.compose.desktop.DesktopExtension
import org.jetbrains.compose.desktop.application.internal.ComposeProperties
import org.jetbrains.compose.desktop.application.internal.configureApplicationImpl import org.jetbrains.compose.desktop.application.internal.configureApplicationImpl
import org.jetbrains.compose.desktop.application.internal.currentTarget import org.jetbrains.compose.desktop.application.internal.currentTarget
import org.jetbrains.compose.desktop.preview.internal.initializePreview import org.jetbrains.compose.desktop.preview.internal.initializePreview
@ -58,7 +59,7 @@ class ComposePlugin : Plugin<Project> {
project.configureExperimental(composeExtension, experimentalExtension) project.configureExperimental(composeExtension, experimentalExtension)
if (androidExtension.useAndroidX) { if (androidExtension.useAndroidX) {
println("useAndroidX is an experimental feature at the moment!") project.logger.warn("useAndroidX is an experimental feature at the moment!")
RedirectAndroidVariants.androidxVersion = androidExtension.androidxVersion RedirectAndroidVariants.androidxVersion = androidExtension.androidxVersion
listOf( listOf(
RedirectAndroidVariants::class.java, RedirectAndroidVariants::class.java,
@ -125,15 +126,17 @@ class ComposePlugin : Plugin<Project> {
} }
} }
} val overrideDefaultJvmTarget = ComposeProperties.overrideKotlinJvmTarget(project.providers).get()
project.tasks.withType(KotlinCompile::class.java) { project.tasks.withType(KotlinCompile::class.java) {
it.kotlinOptions.apply { it.kotlinOptions.apply {
jvmTarget = "1.8".takeIf { jvmTarget.toDouble() < 1.8 } ?: jvmTarget if (overrideDefaultJvmTarget) {
jvmTarget = "11".takeIf { jvmTarget.toDouble() < 11 } ?: jvmTarget
}
useIR = true useIR = true
} }
} }
} }
}
class RedirectAndroidVariants : ComponentMetadataRule { class RedirectAndroidVariants : ComponentMetadataRule {
override fun execute(context: ComponentMetadataContext) = with(context.details) { override fun execute(context: ComponentMetadataContext) = with(context.details) {

6
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/ComposeProjectProperties.kt

@ -10,6 +10,7 @@ import org.gradle.api.provider.ProviderFactory
internal object ComposeProperties { internal object ComposeProperties {
internal const val VERBOSE = "compose.desktop.verbose" internal const val VERBOSE = "compose.desktop.verbose"
internal const val OVERRIDE_KOTLIN_JVM_TARGET = "compose.desktop.override.default.kotlin.jvm.target"
internal const val PRESERVE_WD = "compose.preserve.working.dir" internal const val PRESERVE_WD = "compose.preserve.working.dir"
internal const val MAC_SIGN = "compose.desktop.mac.sign" internal const val MAC_SIGN = "compose.desktop.mac.sign"
internal const val MAC_SIGN_ID = "compose.desktop.mac.signing.identity" internal const val MAC_SIGN_ID = "compose.desktop.mac.signing.identity"
@ -22,6 +23,11 @@ internal object ComposeProperties {
fun isVerbose(providers: ProviderFactory): Provider<Boolean> = fun isVerbose(providers: ProviderFactory): Provider<Boolean> =
providers.findProperty(VERBOSE).toBoolean() providers.findProperty(VERBOSE).toBoolean()
fun overrideKotlinJvmTarget(providers: ProviderFactory): Provider<Boolean> =
providers.provider {
providers.findProperty(OVERRIDE_KOTLIN_JVM_TARGET)?.toString() != "false"
}
fun preserveWorkingDir(providers: ProviderFactory): Provider<Boolean> = fun preserveWorkingDir(providers: ProviderFactory): Provider<Boolean> =
providers.findProperty(PRESERVE_WD).toBoolean() providers.findProperty(PRESERVE_WD).toBoolean()

24
gradle-plugins/compose/src/test/test-projects/init.gradle

@ -1,12 +1,3 @@
def jvmTargetForKotlinCompile(Project project, String jvmTarget) {
project.tasks.all {
// tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) fails for init scripts
if (it.class.name == "org.jetbrains.kotlin.gradle.tasks.KotlinCompile_Decorated") {
kotlinOptions.jvmTarget = "11"
}
}
}
allprojects { allprojects {
repositories { repositories {
mavenLocal() mavenLocal()
@ -16,19 +7,4 @@ allprojects {
} }
google() google()
} }
plugins.withId("java-base") {
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
}
plugins.withId("org.jetbrains.kotlin.jvm") {
jvmTargetForKotlinCompile(project, "11")
}
plugins.withId("org.jetbrains.kotlin.multiplatform") {
jvmTargetForKotlinCompile(project, "11")
}
} }
Loading…
Cancel
Save