Conversation
There was a problem hiding this comment.
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.
| 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) }) | ||
| } |
There was a problem hiding this comment.
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}|
Collapsed into #2529, which now carries both the friend-path wiring and the narrowing against |
Wires
:e2eTest's Kotlin compilations as friends of:auth, so the e2e tests can drive test seams that areinternal. Unblocks narrowing the credential-manager seams before the GA cut.Changes
friendPathsblock toe2eTest/build.gradle.ktsthat filters the compile classpath (libraries) for entries underauth/build, rather than hardcoding the AGP intermediates jar it resolves to today.rootProject.layout.projectDirectory.dir("auth/build")rather thanproject(":auth").layout.buildDirectory, which works but is cross-project model access that breaks under project isolation.Two approaches that do not work
Appending
-Xfriend-pathstocompilerOptions.freeCompilerArgsis ignored, because KGP generates that flag itself from the typedfriendPathsproperty. Pointing atauth/build/tmp/kotlin-classes/debugalso fails, because:e2eTestnever 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