Skip to content

Conversation

@RBusarow
Copy link
Member

Given this dependencies block in a .kts build file for an Android module:

dependencies {
  api(project(path = ":lib2"))
}

If we want to add: androidTestDebugImplementation(project(path = ":lib1")), it'll be added with quotes to be invoked as a string extension:

dependencies {
  "androidTestDebugImplementation"(project(path = ":lib1"))
  api(project(path = ":lib2"))
}

Instead, it should be this:

dependencies {
  androidTestDebugImplementation(project(path = ":lib1"))
  api(project(path = ":lib2"))
}

In short, the existing logic strips the configuration suffix (-Implementation in this case) from the name, in order to get the source set (androidTestDebug). It then checks the source set name against the known default source sets added by this project's plugins (androidTest, debug, main, release, and test since this is Android), and if it matches one of those, then the configuration will be invoked without quotes.

In this case, the source set of androidTestDebug is still known at compile time, since it's just a combination of androidTest and debug.

This problem isn't unique to AGP. Other combined configurations like anvilTest or kaptAndroidTest also have this problem.

The fix is recursion. After stripping away the java configuration suffix, check the source set. If it doesn't match a known one, try stripping away a known source set prefix and try the source set again. This only ever removes precompiled names, so if there's ever a match, then the whole thing is precompiled and no quotes are needed.

@RBusarow RBusarow force-pushed the support_complex_precompiled_configurations branch from 92dc333 to 1e6ad61 Compare March 13, 2022 15:39
@kodiakhq kodiakhq bot merged commit 334ca98 into main Mar 13, 2022
@kodiakhq kodiakhq bot deleted the support_complex_precompiled_configurations branch March 13, 2022 17:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants