Skip to content

build(e2eTest): give :e2eTest friend-path access to :auth internals - #2528

Closed
demolaf wants to merge 1 commit into
pre-GAfrom
build/e2etest-auth-friend-paths
Closed

demolaf wants to merge 1 commit into
pre-GAfrom
build/e2etest-auth-friend-paths

Conversation

@demolaf

@demolaf demolaf commented Sep 22, 2026

Copy link
Copy Markdown
Member

Wires :e2eTest's Kotlin compilations as friends of :auth, so the e2e tests can drive test seams that are internal. Unblocks narrowing the credential-manager seams before the GA cut.

Changes

  • Add a friendPaths block to e2eTest/build.gradle.kts that filters the compile classpath (libraries) for entries under auth/build, rather than hardcoding the AGP intermediates jar it resolves to today.
  • Use rootProject.layout.projectDirectory.dir("auth/build") rather than project(":auth").layout.buildDirectory, which works but is cross-project model access that breaks under project isolation.

Two approaches that do not work

Appending -Xfriend-paths to compilerOptions.freeCompilerArgs is ignored, because KGP generates that flag itself from the typed friendPaths property. Pointing at auth/build/tmp/kotlin-classes/debug also fails, because :e2eTest never sees that directory. Both were measured.

AGP 9.0 caveat

This wiring hangs off org.jetbrains.kotlin.gradle.tasks.KotlinCompile, so the built-in-Kotlin migration the build already warns about will need it rewritten.


Maintainer note: Fixes internal CPRN-492

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request configures the e2eTest module to have friend access to :auth internals by adding the :auth build directory to the friendPaths of Kotlin compilation tasks. The review feedback suggests avoiding the use of rootProject to maintain Gradle's Project Isolation principles, and recommends using File.startsWith(File) instead of string-based path matching to prevent false positives with similarly named directories.

Comment thread e2eTest/build.gradle.kts
Comment on lines +105 to +108
val authBuildDir = rootProject.layout.projectDirectory.dir("auth/build").asFile.absolutePath
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
friendPaths.from(libraries.filter { it.absolutePath.startsWith(authBuildDir) })
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Using rootProject in a subproject's build script violates Gradle's Project Isolation principles, as it couples the subproject directly to the root project model at configuration time. Instead, you can navigate relatively using the current project's layout.projectDirectory.\n\nAdditionally, using startsWith on absolute path strings can lead to false positives if there are other directories with similar prefixes (e.g., auth/build-cache). Using Kotlin's File.startsWith(File) extension is safer as it compares actual path components.

val authBuildDir = layout.projectDirectory.dir("../auth/build").asFile\ntasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {\n    friendPaths.from(libraries.filter { it.startsWith(authBuildDir) })\n}

@demolaf

demolaf commented Sep 22, 2026

Copy link
Copy Markdown
Member Author

Collapsed into #2529, which now carries both the friend-path wiring and the narrowing against pre-GA. On its own this change was unfalsifiable: nothing in :auth is internal at this commit, so the only thing that demonstrates the wiring works is the narrowing compiling against it.

@demolaf demolaf closed this Sep 22, 2026
@demolaf
demolaf deleted the build/e2etest-auth-friend-paths branch September 22, 2026 09:56
@github-project-automation github-project-automation Bot moved this from Backlog to Done in studio-2394994192-60a69 Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant