Skip to content

Commit

Permalink
AGP 8.6 support (#121) (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeppeman authored Sep 7, 2024
1 parent f1e32b6 commit 1829056
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 51 deletions.
18 changes: 0 additions & 18 deletions globallydynamic-gradle-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ buildscript {
apply from: 'deps.gradle'

repositories {
jcenter()
google()
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlin"
classpath "com.github.ben-manes:gradle-versions-plugin:$versions.versionsplugin"
}
}

Expand All @@ -32,7 +30,6 @@ subprojects {
}

repositories {
jcenter()
google()
mavenCentral()
}
Expand All @@ -55,21 +52,6 @@ subprojects {
}
}

apply plugin: "com.github.ben-manes.versions"

dependencyUpdates.resolutionStrategy = {
componentSelection { rules ->
rules.all { ComponentSelection selection ->
boolean rejected = ['alpha', 'beta', 'rc', 'cr', 'm'].any { qualifier ->
selection.candidate.version ==~ /(?i).*[.-]${qualifier}[.\d-]*/
}
if (rejected) {
selection.reject('Release candidate')
}
}
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
2 changes: 1 addition & 1 deletion globallydynamic-gradle-plugin/deps.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import java.nio.file.Paths

def androidPluginVersion = project.hasProperty("agpVersion")
? project.properties.get("agpVersion")
: '8.1.1'
: '8.6.0'

def versions = [
androidplugin : androidPluginVersion,
Expand Down
2 changes: 1 addition & 1 deletion globallydynamic-gradle-plugin/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
GROUP=com.jeppeman.globallydynamic.gradle
VERSION_NAME=1.8.0-SNAPSHOT
VERSION_NAME=1.9.0-SNAPSHOT

POM_DESCRIPTION=GloballyDynamic - Gradle plugin to facilitate for local dynamic delivery for Android.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
1 change: 0 additions & 1 deletion globallydynamic-gradle-plugin/plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ test {
dependencies {
implementation gradleApi()
implementation localGroovy()
implementation deps.kotlin.stdlib
implementation deps.androidplugin
implementation deps.javapoet
implementation deps.gson
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,9 @@ private fun createProjectServices(project: Project): ProjectServices {
fileResolver = project::file,
configurationContainer = project.configurations,
dependencyHandler = project.dependencies,
extraProperties = project.extensions.extraProperties
extraProperties = project.extensions.extraProperties,
emptyTaskCreator = { name -> project.tasks.register(name) },
plugins = project.pluginManager,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,14 @@ open class UploadBundleTask : DefaultTask() {
.resolve("intermediates")
.resolve("intermediary_bundle")
.resolve(applicationVariant.name)
.resolve(applicationVariant.getTaskName("package", "Bundle"))
.toFile()
task.signingConfig = task.project.buildDir
.toPath()
.resolve("intermediates")
.resolve("signing_config_data")
.resolve(applicationVariant.name)
.resolve(applicationVariant.getTaskName("signingConfigWriter"))
.resolve("signing-config-data.json")
.toFile()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,31 +143,12 @@ open class WriteConfigurationSourceFilesTask : DefaultTask() {
task.applicationId = applicationVariant.applicationId!!
task.version = applicationVariant.versionCode
task.outputDir = outputDir
// AGP 3.5 and 3.6 compatibility
task.linkedBundleRes = task.project.files(
task.project
.getLinkedBundleResDir(applicationVariant)
.resolve("bundled-res.ap_")
.toFile(),
task.project
.getLinkedBundleResDir(applicationVariant)
.resolve(applicationVariant.getTaskName("bundle", "Resources"))
.resolve("bundled-res.ap_")
.toFile()
)
task.linkedBundleRes = task.project.bundledProtoRes(applicationVariant)

task.dynamicFeatureInputs = dynamicFeatureVariantMap.map { (project, variant) ->
DynamicFeatureInput(
name = project.name,
linkedBundleRes = project.files(
project.getLinkedBundleResDir(variant)
.resolve("bundled-res.ap_")
.toFile(),
project.getLinkedBundleResDir(variant)
.resolve(variant.getTaskName("bundle", "Resources"))
.resolve("bundled-res.ap_")
.toFile()
)
linkedBundleRes = project.bundledProtoRes(variant)
)
}
task.downloadConnectTimeout = extension.resolveDownloadConnectTimeout(task.project)
Expand All @@ -178,11 +159,40 @@ open class WriteConfigurationSourceFilesTask : DefaultTask() {
}
}

private fun Project.getLinkedBundleResDir(applicationVariant: ApplicationVariant) =
buildDir.toPath()
.resolve("intermediates")
.resolve("linked_res_for_bundle")
.resolve(applicationVariant.name)
private fun Project.bundledProtoRes(variant: ApplicationVariant): FileCollection = files(
// <= AGP 3.5
project
.getLinkedBundleResDir(variant.name, true)
.resolve("bundled-res.ap_")
.toFile(),

// >= AGP 3.6
project
.getLinkedBundleResDir(variant.name, true)
.resolve(variant.getTaskName("bundle", "Resources"))
.resolve("bundled-res.ap_")
.toFile(),

// >= AGP 8.6
project
.getLinkedBundleResDir(variant.name)
.resolve(variant.getTaskName("bundle", "Resources"))
.resolve("linked-resources-proto-format.ap_")
.toFile()
)

private fun Project.getLinkedBundleResDir(variantName: String, legacy: Boolean = false) =
if (legacy) {
buildDir.toPath()
.resolve("intermediates")
.resolve("linked_res_for_bundle")
.resolve(variantName)
} else {
buildDir.toPath()
.resolve("intermediates")
.resolve("linked_resources_for_bundle_proto_format")
.resolve(variantName)
}

private const val ANDROID_XML_NS = "http://schemas.android.com/apk/res/android"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.jeppeman.globallydynamic.gradle

import com.jeppeman.globallydynamic.gradle.extensions.deleteCompletely
import org.gradle.testkit.runner.BuildResult
import org.gradle.testkit.runner.GradleRunner
import org.junit.jupiter.api.BeforeEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import org.junit.jupiter.api.assertThrows
import org.junit.platform.runner.JUnitPlatform
import org.junit.runner.RunWith
import java.nio.file.Paths
import java.util.LinkedList

@RunWith(JUnitPlatform::class)
class UploadBundleTaskTest : BaseTaskTest() {
Expand Down

0 comments on commit 1829056

Please sign in to comment.