Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump to AGP 8.8.x #131

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -265,20 +265,21 @@ class DependencyConfigurator(
AndroidArtifacts.TYPE_PLATFORM_ATTR
)

val sharedLibSupport = projectOptions[BooleanOption.CONSUME_DEPENDENCIES_AS_SHARED_LIBRARIES]

val libraryCategory = project.objects.named(Category::class.java, Category.LIBRARY)
for (transformTarget in AarTransform.getTransformTargets(aarOrJarTypeToConsume)) {
dependencies.registerTransform(
AarTransform::class.java
) { spec ->
spec.from.attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, AndroidArtifacts.ArtifactType.EXPLODED_AAR.type)
spec.from.attribute(Category.CATEGORY_ATTRIBUTE, libraryCategory)
spec.to.attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, transformTarget.type)
spec.to.attribute(Category.CATEGORY_ATTRIBUTE, libraryCategory)
spec.parameters.projectName.setDisallowChanges(project.name)
spec.parameters.targetType.setDisallowChanges(transformTarget)
spec.parameters.sharedLibSupport.setDisallowChanges(sharedLibSupport)
val namespacedSharedLibSupport = projectOptions[BooleanOption.CONSUME_DEPENDENCIES_AS_SHARED_LIBRARIES]
val sharedLibSupport = projectOptions[BooleanOption.SUPPORT_OEM_TOKEN_LIBRARIES]

val libraryCategory = project.objects.named(Category::class.java, Category.LIBRARY)
for (transformTarget in AarTransform.getTransformTargets(aarOrJarTypeToConsume, sharedLibSupport)) {
dependencies.registerTransform(
AarTransform::class.java
) { spec ->
spec.from.attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, AndroidArtifacts.ArtifactType.EXPLODED_AAR.type)
spec.from.attribute(Category.CATEGORY_ATTRIBUTE, libraryCategory)
spec.to.attribute(ArtifactTypeDefinition.ARTIFACT_TYPE_ATTRIBUTE, transformTarget.type)
spec.to.attribute(Category.CATEGORY_ATTRIBUTE, libraryCategory)
spec.parameters.projectName.setDisallowChanges(project.name)
spec.parameters.targetType.setDisallowChanges(transformTarget)
spec.parameters.namespacedSharedLibSupport.setDisallowChanges(namespacedSharedLibSupport)
}
}
if (projectOptions[BooleanOption.PRECOMPILE_DEPENDENCIES_RESOURCES]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,11 @@ abstract class BaseDexingTransform<T : BaseDexingTransform.Parameters> : Transfo
globalSyntheticsOutputDir: File?,
desugarGraphOutputFile: File
) {
val desugarGraph = DesugarGraph.read(desugarGraphOutputFile, rootDir = inputDir)
val desugarGraph = DesugarGraph.read(
desugarGraphFile = desugarGraphOutputFile,
rootDir = inputDir,
filesToIgnore = parameters.bootClasspath.files
)

// Compute impacted files based on the changed files and the desugaring graph
val removedFiles = inputDirChanges.removedFiles.map { it.file }
Expand Down Expand Up @@ -227,9 +231,13 @@ abstract class BaseDexingTransform<T : BaseDexingTransform.Parameters> : Transfo
desugarGraphOutputFile?.let { FileUtils.deleteIfExists(it) }

val desugarGraph = if (provideIncrementalSupport) {
// `inputDirOrJar` must be a directory when `provideIncrementalSupport == true`
// (see the definition of `provideIncrementalSupport`)
DesugarGraph(rootDir = inputDirOrJar)
// `inputDirOrJar` must be a directory when `provideIncrementalSupport == true`
// (see the definition of `provideIncrementalSupport`)
DesugarGraph(
rootDir = inputDirOrJar,
relocatableDesugarGraph = MutableDependencyGraph(),
filesToIgnore = parameters.bootClasspath.files
)
} else null

process(
Expand Down Expand Up @@ -316,11 +324,27 @@ internal class DesugarGraph(
private val rootDir: File,

/** The relocatable desugaring graph, which contains Unix-style relative paths of the files. */
private val relocatableDesugarGraph: MutableDependencyGraph<String> = MutableDependencyGraph()
private val relocatableDesugarGraph: MutableDependencyGraph<String>,

/**
* Files located outside [rootDir] which don't need to be recorded in the desugaring graph.
*
* Context (b/362339872): In some cases, D8 may report dependencies between the project's
* classes and android.jar, which is likely located outside [rootDir]. Instead of failing the
* build, we can ignore those dependencies. It is safe to ignore because:
* - [BaseDexingTransform.Parameters.bootClasspath] is a non-incremental transform input, so
* any changes to it will cause the transform to run non-incrementally (i.e., we don't need to
* track changes to `bootClasspath` and files that are impacted by those changes).
* - `bootClasspath` is self-contained, it doesn't depend on anything else, so we don't need
* to track its dependencies.
*/
private val filesToIgnore: Set<File>

) : DependencyGraphUpdater<File> {

override fun addEdge(dependent: File, dependency: File) {
if (dependent in filesToIgnore || dependency in filesToIgnore) return

relocatableDesugarGraph.addEdge(
dependent.toUnixStyleRelativePath(),
dependency.toUnixStyleRelativePath()
Expand Down Expand Up @@ -357,14 +381,15 @@ internal class DesugarGraph(

companion object {

fun read(desugarGraphFile: File, rootDir: File): DesugarGraph {
fun read(desugarGraphFile: File, rootDir: File, filesToIgnore: Set<File>): DesugarGraph {
return DesugarGraph(
rootDir = rootDir,
relocatableDesugarGraph =
ObjectInputStream(desugarGraphFile.inputStream().buffered()).use {
@Suppress("UNCHECKED_CAST")
it.readObject() as MutableDependencyGraph<String>
}
},
filesToIgnore = filesToIgnore
)
}
}
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[versions]
agp = "8.7.2" # keep in sync with android-tools
android-tools = "31.7.2" # = 23.0.0 + agp
agp = "8.8.0-rc01" # keep in sync with android-tools
android-tools = "31.8.0-rc01" # = 23.0.0 + agp
compilerTesting = "0.2.1"
compose = "1.5.14"
kotlin = "1.9.24"
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Tue Sep 17 07:31:50 EDT 2024
#Tue Oct 29 10:05:49 EDT 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading