build: update to agp 8.2.2 and remove VersionAlignment and DaggerPlatform
authorDa Risk <da_risk@geekorum.com>
Thu, 07 Mar 2024 18:43:47 -0400
changeset 68 e3215d4393f1
parent 67 882d271b5297
child 69 1167496633b2
build: update to agp 8.2.2 and remove VersionAlignment and DaggerPlatform
buildSrc/build.gradle.kts
buildSrc/src/main/kotlin/VersionAlignment.kt
geekdroid/build.gradle.kts
--- a/buildSrc/build.gradle.kts	Sun Jan 28 15:20:28 2024 -0400
+++ b/buildSrc/build.gradle.kts	Thu Mar 07 18:43:47 2024 -0400
@@ -56,7 +56,7 @@
 }
 
 dependencies {
-    implementation("com.android.tools.build:gradle:8.2.1")
+    implementation("com.android.tools.build:gradle:8.2.2")
     implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.22")
     implementation("gradle.plugin.com.hierynomus.gradle.plugins:license-gradle-plugin:0.16.1")
     implementation("com.github.triplet.gradle:play-publisher:3.7.0")
--- a/buildSrc/src/main/kotlin/VersionAlignment.kt	Sun Jan 28 15:20:28 2024 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-/*
- * Geekdroid is a utility library for development on the Android
- * Platform.
- *
- * Copyright (C) 2017-2024 by Frederic-Charles Barthelery.
- *
- * This file is part of Geekdroid.
- *
- * Geekdroid is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Geekdroid is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Geekdroid.  If not, see <http://www.gnu.org/licenses/>.
- */
-package com.geekorum.build
-
-import org.gradle.api.artifacts.ComponentMetadataContext
-import org.gradle.api.artifacts.ComponentMetadataRule
-import org.gradle.api.artifacts.Dependency
-import org.gradle.api.artifacts.dsl.ComponentMetadataHandler
-import org.gradle.api.artifacts.dsl.DependencyHandler
-
-private val componentsPlatform = mutableMapOf<ComponentMetadataHandler, MutableSet<String>>()
-
-fun DependencyHandler.createComponentsPlatforms() {
-    components.apply {
-        getOrCreatePlatform(DaggerPlatform)
-    }
-}
-
-private fun ComponentMetadataHandler.getOrCreatePlatform(platformFactory: PlatformFactory): String {
-    val componentsSet = componentsPlatform.getOrPut(this) { mutableSetOf() }
-    if (!componentsSet.contains(platformFactory.platformName)) {
-        componentsSet.add(platformFactory.createPlatform(this))
-    }
-    return platformFactory.platformName
-}
-
-internal class DaggerPlatform {
-    companion object : PlatformFactory("com.google.dagger:dagger-platform",
-        AlignmentRule::class.java)
-
-    open class AlignmentRule : SameGroupAlignmentRule(platformName, "com.google.dagger")
-}
-
-fun DependencyHandler.daggerPlatform(version: String): Dependency {
-    return platform("${components.getOrCreatePlatform(DaggerPlatform)}:$version")
-}
-
-open class PlatformFactory(
-    internal val platformName: String,
-    private val alignmentRule: Class<out ComponentMetadataRule>
-) {
-    fun createPlatform(components: ComponentMetadataHandler): String {
-        components.all(alignmentRule)
-        return platformName
-    }
-}
-
-internal open class SameGroupAlignmentRule(
-    private val platformName: String,
-    private val group: String
-) : ComponentMetadataRule {
-
-    override fun execute(ctx: ComponentMetadataContext) {
-        ctx.details.run {
-            if (id.group == group) {
-                belongsTo("$platformName:${id.version}")
-            }
-        }
-    }
-
-}
--- a/geekdroid/build.gradle.kts	Sun Jan 28 15:20:28 2024 -0400
+++ b/geekdroid/build.gradle.kts	Thu Mar 07 18:43:47 2024 -0400
@@ -126,21 +126,6 @@
                 }
             }
             inceptionYear.set("2017")
-
-            // exclude dagger-platform
-            withXml {
-                val dependencyManagement = asNode().get("dependencyManagement") as NodeList
-                val dependencies = dependencyManagement.getAt("dependencies") as NodeList
-                dependencies.getAt("dependency")
-                    .forEach {
-                        val node = it as Node
-                        val artifactId = (node.get("artifactId") as NodeList).single() as Node
-                        val artifactIdTxt = (artifactId.value() as NodeList).single()
-                        if (artifactIdTxt == "dagger-platform") {
-                            node.parent().remove(node)
-                        }
-                    }
-            }
         }
 
         register<MavenPublication>("release") {