mirror of
https://github.com/jlengrand/compose-multiplatform.git
synced 2026-03-10 08:11:20 +00:00
Use Gradle 7.1 for building Gradle and Intellij plugin (#836)
* Replace usage of 'de.fuerstenau.buildconfig' with a custom replacement, because the plugin does not support Gradle 7.0+ and there has not been any commit activity in 5 years (https://github.com/mfuerstenau/gradle-buildconfig-plugin); * Update 'com.github.johnrengelman.shadow' to 7.0.0
This commit is contained in:
@@ -3,8 +3,7 @@ import com.gradle.publish.PluginBundleExtension
|
||||
plugins {
|
||||
// __KOTLIN_COMPOSE_VERSION__
|
||||
kotlin("jvm") version "1.5.10" apply false
|
||||
id("com.gradle.plugin-publish") version "0.10.1" apply false
|
||||
id("de.fuerstenau.buildconfig") version "1.1.8" apply false
|
||||
id("com.gradle.plugin-publish") version "0.15.0" apply false
|
||||
}
|
||||
|
||||
subprojects {
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.file.DirectoryProperty
|
||||
import org.gradle.api.provider.MapProperty
|
||||
import org.gradle.api.provider.Property
|
||||
import org.gradle.api.tasks.Input
|
||||
import org.gradle.api.tasks.OutputDirectory
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.gradle.kotlin.dsl.mapProperty
|
||||
import org.gradle.kotlin.dsl.property
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
open class GenerateBuildConfig : DefaultTask() {
|
||||
@get:Input
|
||||
val fieldsToGenerate: MapProperty<String, Any> = project.objects.mapProperty()
|
||||
|
||||
@get:Input
|
||||
val classFqName: Property<String> = project.objects.property()
|
||||
|
||||
@get:OutputDirectory
|
||||
val generatedOutputDir: DirectoryProperty = project.objects.directoryProperty()
|
||||
|
||||
@TaskAction
|
||||
fun execute() {
|
||||
val dir = generatedOutputDir.get().asFile
|
||||
dir.deleteRecursively()
|
||||
dir.mkdirs()
|
||||
|
||||
val fqName = classFqName.get()
|
||||
val parts = fqName.split(".")
|
||||
val className = parts.last()
|
||||
val file = dir.resolve("$className.kt")
|
||||
val content = buildString {
|
||||
if (parts.size > 1) {
|
||||
appendLine("package ${parts.dropLast(1).joinToString(".")}")
|
||||
}
|
||||
|
||||
appendLine()
|
||||
appendLine("/* GENERATED, DO NOT EDIT MANUALLY! */")
|
||||
appendLine("object $className {")
|
||||
for ((k, v) in fieldsToGenerate.get().entries.sortedBy { it.key }) {
|
||||
appendLine("const val $k = ${if (v is String) "\"$v\"" else v.toString()}")
|
||||
}
|
||||
appendLine("}")
|
||||
}
|
||||
file.writeText(content)
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,10 @@ import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform.getCurr
|
||||
|
||||
plugins {
|
||||
kotlin("jvm")
|
||||
id("de.fuerstenau.buildconfig")
|
||||
id("com.gradle.plugin-publish")
|
||||
id("java-gradle-plugin")
|
||||
id("maven-publish")
|
||||
id("com.github.johnrengelman.shadow") version "6.1.0"
|
||||
id("com.github.johnrengelman.shadow") version "7.0.0"
|
||||
}
|
||||
|
||||
gradlePluginConfig {
|
||||
@@ -21,11 +20,19 @@ mavenPublicationConfig {
|
||||
artifactId = "compose-gradle-plugin"
|
||||
}
|
||||
|
||||
buildConfig {
|
||||
packageName = "org.jetbrains.compose"
|
||||
clsName = "ComposeBuildConfig"
|
||||
buildConfigField("String", "composeVersion", BuildProperties.composeVersion(project))
|
||||
buildConfigField("Boolean", "isComposeWithWeb", BuildProperties.isComposeWithWeb(project).toString())
|
||||
val buildConfigDir
|
||||
get() = project.layout.buildDirectory.dir("generated/buildconfig")
|
||||
val buildConfig = tasks.register("buildConfig", GenerateBuildConfig::class.java) {
|
||||
classFqName.set("org.jetbrains.compose.ComposeBuildConfig")
|
||||
generatedOutputDir.set(buildConfigDir)
|
||||
fieldsToGenerate.put("composeVersion", BuildProperties.composeVersion(project))
|
||||
fieldsToGenerate.put("isComposeWithWeb", BuildProperties.isComposeWithWeb(project))
|
||||
}
|
||||
tasks.named("compileKotlin") {
|
||||
dependsOn(buildConfig)
|
||||
}
|
||||
sourceSets.main.configure {
|
||||
java.srcDir(buildConfigDir)
|
||||
}
|
||||
|
||||
val embedded by configurations.creating
|
||||
@@ -67,7 +74,7 @@ val jar = tasks.named<Jar>("jar") {
|
||||
// __SUPPORTED_GRADLE_VERSIONS__
|
||||
testGradleVersion("6.4")
|
||||
testGradleVersion("6.8.3")
|
||||
testGradleVersion("7.0-milestone-3")
|
||||
testGradleVersion("7.1")
|
||||
|
||||
val javaHomeForTests: String? = when {
|
||||
// __COMPOSE_NATIVE_DISTRIBUTIONS_MIN_JAVA_VERSION__
|
||||
@@ -92,7 +99,6 @@ fun testGradleVersion(gradleVersion: String) {
|
||||
filter {
|
||||
includeTestsMatching(gradleTestsPattern)
|
||||
}
|
||||
dependsOn("validateTaskProperties")
|
||||
}
|
||||
tasks.named("check") {
|
||||
dependsOn(taskProvider)
|
||||
@@ -104,7 +110,7 @@ configureJUnit()
|
||||
tasks.withType<Test>().configureEach {
|
||||
configureJavaForComposeTest()
|
||||
|
||||
dependsOn("publishToMavenLocal")
|
||||
dependsOn(":publishToMavenLocal")
|
||||
systemProperty("compose.plugin.version", BuildProperties.deployVersion(project))
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ abstract class AbstractConfigureDesktopPreviewTask : AbstractComposeDesktopTask(
|
||||
|
||||
@get:InputFiles
|
||||
internal val hostClasspath = project.configurations.detachedConfiguration(
|
||||
project.dependencies.create("org.jetbrains.compose:preview-rpc:${ComposeBuildConfig.VERSION}")
|
||||
project.dependencies.create("org.jetbrains.compose:preview-rpc:${ComposeBuildConfig.composeVersion}")
|
||||
)
|
||||
|
||||
@TaskAction
|
||||
|
||||
@@ -18,7 +18,7 @@ class GradlePluginTest : GradlePluginTestBase() {
|
||||
with(
|
||||
testProject(
|
||||
TestProjects.jsMpp,
|
||||
testEnvironment = defaultTestEnvironment.copy(kotlinVersion = TestKotlinVersion.V1_5_20_dev_3226)
|
||||
testEnvironment = defaultTestEnvironment.copy(kotlinVersion = TestKotlinVersion.V1_5_20)
|
||||
)
|
||||
) {
|
||||
gradle(":compileKotlinJs").build().checks { check ->
|
||||
|
||||
@@ -9,5 +9,5 @@ package org.jetbrains.compose.test
|
||||
enum class TestKotlinVersion(val versionString: String) {
|
||||
// __KOTLIN_COMPOSE_VERSION__
|
||||
Default("1.5.10"),
|
||||
V1_5_20_dev_3226("1.5.20-dev-3226")
|
||||
V1_5_20("1.5.20")
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.2-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
Reference in New Issue
Block a user