Browse Source

Fix compatibility with Gradle < 7.1 (#957)

pull/966/head
Alexey Tsvetkov 3 years ago committed by GitHub
parent
commit
8a685b62fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/configureApplication.kt
  2. 7
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/preview/internal/configurePreview.kt
  3. 14
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/projectExtensions.kt

7
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/configureApplication.kt

@ -16,10 +16,7 @@ import org.jetbrains.compose.desktop.application.dsl.Application
import org.jetbrains.compose.desktop.application.dsl.TargetFormat 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.internal.KOTLIN_JVM_PLUGIN_ID import org.jetbrains.compose.internal.*
import org.jetbrains.compose.internal.KOTLIN_MPP_PLUGIN_ID
import org.jetbrains.compose.internal.javaExt
import org.jetbrains.compose.internal.mppExt
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import java.io.File import java.io.File
import java.util.* import java.util.*
@ -34,7 +31,7 @@ fun configureApplicationImpl(project: Project, app: Application) {
if (project.plugins.hasPlugin(KOTLIN_MPP_PLUGIN_ID)) { if (project.plugins.hasPlugin(KOTLIN_MPP_PLUGIN_ID)) {
project.configureFromMppPlugin(app) project.configureFromMppPlugin(app)
} else if (project.plugins.hasPlugin(KOTLIN_JVM_PLUGIN_ID)) { } else if (project.plugins.hasPlugin(KOTLIN_JVM_PLUGIN_ID)) {
val mainSourceSet = project.javaExt.sourceSets.getByName("main") val mainSourceSet = project.javaSourceSets.getByName("main")
app.from(mainSourceSet) app.from(mainSourceSet)
} }
} }

7
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/preview/internal/configurePreview.kt

@ -3,10 +3,7 @@ package org.jetbrains.compose.desktop.preview.internal
import org.gradle.api.Project import org.gradle.api.Project
import org.jetbrains.compose.desktop.application.dsl.ConfigurationSource import org.jetbrains.compose.desktop.application.dsl.ConfigurationSource
import org.jetbrains.compose.desktop.preview.tasks.AbstractConfigureDesktopPreviewTask import org.jetbrains.compose.desktop.preview.tasks.AbstractConfigureDesktopPreviewTask
import org.jetbrains.compose.internal.KOTLIN_JVM_PLUGIN_ID import org.jetbrains.compose.internal.*
import org.jetbrains.compose.internal.KOTLIN_MPP_PLUGIN_ID
import org.jetbrains.compose.internal.javaExt
import org.jetbrains.compose.internal.mppExt
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget
@ -20,7 +17,7 @@ fun Project.initializePreview() {
} }
} }
plugins.withId(KOTLIN_JVM_PLUGIN_ID) { plugins.withId(KOTLIN_JVM_PLUGIN_ID) {
val config = ConfigurationSource.GradleSourceSet(project.javaExt.sourceSets.getByName("main")) val config = ConfigurationSource.GradleSourceSet(project.javaSourceSets.getByName("main"))
registerConfigurePreviewTask(project, config) registerConfigurePreviewTask(project, config)
} }
} }

14
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/internal/projectExtensions.kt

@ -6,7 +6,10 @@
package org.jetbrains.compose.internal package org.jetbrains.compose.internal
import org.gradle.api.Project import org.gradle.api.Project
import org.gradle.api.plugins.JavaPluginConvention
import org.gradle.api.plugins.JavaPluginExtension import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.api.tasks.SourceSetContainer
import org.gradle.util.GradleVersion
import org.jetbrains.compose.ComposeExtension import org.jetbrains.compose.ComposeExtension
import org.jetbrains.compose.web.WebExtension import org.jetbrains.compose.web.WebExtension
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
@ -23,8 +26,9 @@ internal val Project.mppExt: KotlinMultiplatformExtension
internal val Project.mppExtOrNull: KotlinMultiplatformExtension? internal val Project.mppExtOrNull: KotlinMultiplatformExtension?
get() = extensions.findByType(KotlinMultiplatformExtension::class.java) get() = extensions.findByType(KotlinMultiplatformExtension::class.java)
internal val Project.javaExt: JavaPluginExtension internal val Project.javaSourceSets: SourceSetContainer
get() = javaExtOrNull ?: error("Could not find JavaPluginExtension ($project)") get() = if (GradleVersion.current() < GradleVersion.version("7.1")) {
convention.getPlugin(JavaPluginConvention::class.java).sourceSets
internal val Project.javaExtOrNull: JavaPluginExtension? } else {
get() = extensions.findByType(JavaPluginExtension::class.java) extensions.getByType(JavaPluginExtension::class.java).sourceSets
}

Loading…
Cancel
Save