Skip to content

Commit

Permalink
Delete outdated build services (#4959)
Browse files Browse the repository at this point in the history
We had two build services:
 1) to check unsupported compose compiler plugins were applied
 2) to check a native cache kind configuration

Both of them are outdated and we may get rid of them.

Fixes #4815

## Release Notes
### Fixes - Gradle Plugin
- Delete outdated build services
  • Loading branch information
terrakok committed Jun 13, 2024
1 parent 8432577 commit a73ed61
Show file tree
Hide file tree
Showing 10 changed files with 6 additions and 588 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import org.jetbrains.compose.internal.KOTLIN_JVM_PLUGIN_ID
import org.jetbrains.compose.internal.KOTLIN_MPP_PLUGIN_ID
import org.jetbrains.compose.internal.Version
import org.jetbrains.compose.internal.ideaIsInSyncProvider
import org.jetbrains.compose.internal.mppExtOrNull
import org.jetbrains.compose.internal.service.ConfigurationProblemReporterService
import org.jetbrains.compose.internal.webExt
import org.jetbrains.kotlin.gradle.plugin.KotlinBasePlugin
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
Expand All @@ -26,7 +24,6 @@ import org.jetbrains.kotlin.gradle.plugin.SubpluginArtifact
import org.jetbrains.kotlin.gradle.plugin.SubpluginOption
import org.jetbrains.kotlin.gradle.plugin.getKotlinPluginVersion
import org.jetbrains.kotlin.gradle.targets.js.ir.KotlinJsIrTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

internal fun Project.configureComposeCompilerPlugin() {
//only one of them can be applied to the project
Expand Down Expand Up @@ -84,33 +81,9 @@ class ComposeCompilerKotlinSupportPlugin : KotlinCompilerPluginSupportPlugin {
}

applicableForPlatformTypes = composeExt.platformTypes

collectUnsupportedCompilerPluginUsages(target)
}
}

private fun collectUnsupportedCompilerPluginUsages(project: Project) {
fun Project.hasNonJvmTargets(): Boolean {
val nonJvmTargets = setOf(KotlinPlatformType.native, KotlinPlatformType.js, KotlinPlatformType.wasm)
return mppExtOrNull?.targets?.any {
it.platformType in nonJvmTargets
} ?: false
}

fun SubpluginArtifact.isNonJBComposeCompiler(): Boolean {
return !groupId.startsWith("org.jetbrains.compose.compiler")
}

ConfigurationProblemReporterService.registerUnsupportedPluginProvider(
project,
project.provider {
composeCompilerArtifactProvider.compilerArtifact.takeIf {
project.hasNonJvmTargets() && it.isNonJBComposeCompiler()
}
}
)
}

override fun getCompilerPluginId(): String =
"androidx.compose.compiler.plugins.kotlin"

Expand Down Expand Up @@ -153,14 +126,3 @@ class ComposeCompilerKotlinSupportPlugin : KotlinCompilerPluginSupportPlugin {
private fun options(vararg options: Pair<String, String>): List<SubpluginOption> =
options.map { SubpluginOption(it.first, it.second) }
}

private const val COMPOSE_COMPILER_COMPATIBILITY_LINK =
"https://github.com/JetBrains/compose-jb/blob/master/VERSIONING.md#using-compose-multiplatform-compiler"

internal fun createWarningAboutNonCompatibleCompiler(currentCompilerPluginGroupId: String): String {
return """
WARNING: Usage of the Custom Compose Compiler plugin ('$currentCompilerPluginGroupId')
with non-JVM targets (Kotlin/Native, Kotlin/JS, Kotlin/WASM) is not supported.
For more information, please visit: $COMPOSE_COMPILER_COMPATIBILITY_LINK
""".trimMargin()
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ import org.jetbrains.compose.desktop.preview.internal.initializePreview
import org.jetbrains.compose.experimental.dsl.ExperimentalExtension
import org.jetbrains.compose.experimental.internal.*
import org.jetbrains.compose.internal.*
import org.jetbrains.compose.internal.service.ConfigurationProblemReporterService
import org.jetbrains.compose.internal.service.GradlePropertySnapshotService
import org.jetbrains.compose.internal.utils.currentTarget
import org.jetbrains.compose.resources.ResourcesExtension
import org.jetbrains.compose.resources.configureComposeResources
Expand All @@ -35,15 +33,8 @@ import org.jetbrains.kotlin.gradle.plugin.*

internal val composeVersion get() = ComposeBuildConfig.composeVersion

private fun initBuildServices(project: Project) {
ConfigurationProblemReporterService.init(project)
GradlePropertySnapshotService.init(project)
}

abstract class ComposePlugin : Plugin<Project> {
override fun apply(project: Project) {
initBuildServices(project)

val composeExtension = project.extensions.create("compose", ComposeExtension::class.java, project)
val desktopExtension = composeExtension.extensions.create("desktop", DesktopExtension::class.java)
val androidExtension = composeExtension.extensions.create("android", AndroidExtension::class.java)
Expand All @@ -60,7 +51,6 @@ abstract class ComposePlugin : Plugin<Project> {
composeExtension.extensions.create("web", WebExtension::class.java)

project.configureComposeCompilerPlugin()
project.configureNativeCompilerCaching()

project.configureComposeResources(resourcesExtension)

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit a73ed61

Please sign in to comment.