Skip to content

Commit

Permalink
Remove variant redirection from Gradle plugin (#3168)
Browse files Browse the repository at this point in the history
It was experimental and it is not needed
since our published Gradle Metadata
already has references for Android artifacts
for Android variants
  • Loading branch information
AlexeyTsvetkov authored May 15, 2023
1 parent b08134e commit c162695
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 +
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit c162695

Please sign in to comment.