Browse Source

Remove variant redirection from Gradle plugin (#3168)

It was experimental and it is not needed
since our published Gradle Metadata
already has references for Android artifacts
for Android variants
pull/3170/head v1.5.0-dev1049
Alexey Tsvetkov 2 years ago committed by GitHub
parent
commit
c162695345
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 40
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposePlugin.kt
  2. 6
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/android/AndroidExtension.kt

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

@ -55,20 +55,6 @@ class ComposePlugin : Plugin<Project> {
project.configureExperimental(composeExtension, experimentalExtension)
project.checkExperimentalTargetsWithSkikoIsEnabled()
if (androidExtension.useAndroidX) {
project.logger.warn("useAndroidX is an experimental feature at the moment!")
RedirectAndroidVariants.androidxVersion = androidExtension.androidxVersion
listOf(
RedirectAndroidVariants::class.java,
).forEach(project.dependencies.components::all)
}
fun ComponentModuleMetadataHandler.replaceAndroidx(original: String, replacement: String) {
module(original) {
it.replacedBy(replacement, "org.jetbrains.compose isn't compatible with androidx.compose, because it is the same library published with different maven coordinates")
}
}
project.tasks.withType(KotlinCompile::class.java).configureEach {
it.kotlinOptions.apply {
freeCompilerArgs = freeCompilerArgs +
@ -80,32 +66,6 @@ class ComposePlugin : Plugin<Project> {
}
}
class RedirectAndroidVariants : ComponentMetadataRule {
override fun execute(context: ComponentMetadataContext) = with(context.details) {
if (id.group.startsWith("org.jetbrains.compose")) {
val group = id.group.replaceFirst("org.jetbrains.compose", "androidx.compose")
val newReference = "$group:${id.module.name}:$androidxVersion"
listOf(
"debugApiElements-published",
"debugRuntimeElements-published",
"releaseApiElements-published",
"releaseRuntimeElements-published"
).forEach { variantNameToAlter ->
withVariant(variantNameToAlter) { variantMetadata ->
variantMetadata.withDependencies { dependencies ->
dependencies.removeAll { true } //there are references to org.jetbrains artifacts now
dependencies.add(newReference)
}
}
}
}
}
companion object {
var androidxVersion: String? = null
}
}
@Suppress("DEPRECATION")
class Dependencies(project: Project) {
val desktop = DesktopDependencies

6
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/android/AndroidExtension.kt

@ -7,10 +7,4 @@ import org.gradle.api.tasks.Input
import javax.inject.Inject
abstract class AndroidExtension @Inject constructor(private val objectFactory: ObjectFactory) : ExtensionAware {
@Input
var useAndroidX : Boolean = false
@Input
var androidxVersion: String = "1.0.1" //should be set by CI, but could be overridden in build script
@Input
var mppSolutionGroup: String = "org.jetbrains.compose" //it is added for future use by Google
}
Loading…
Cancel
Save