Slackbot
06/16/2023, 4:24 PMChris Lee
06/16/2023, 4:26 PMMiles Peele
06/16/2023, 4:32 PMChris Lee
06/16/2023, 4:34 PMonlyIf to conditionally execute them (which would look at something for that logic)Miles Peele
06/16/2023, 4:35 PMTask that always adds app:test library:test and core:test as task dependencies, but use onlyIf to only run app:test based on some condition that I can run during the execution phase?Chris Lee
06/16/2023, 4:36 PMMiles Peele
06/16/2023, 4:37 PMMiles Peele
06/16/2023, 4:37 PMshared and platform. I want to only run tests on relevant code, and there doesn't seem to be a way to register a task in platform that has knowledge of the substituted projects from sharedChris Lee
06/16/2023, 4:39 PMtest in the root project, which would run all test tasks in sub-projects (with their up-to-date checks, etc)?Miles Peele
06/16/2023, 4:40 PMsubProjects of a given RootProjectChris Lee
06/16/2023, 4:41 PMtest task?Miles Peele
06/16/2023, 4:42 PMsubprojects doesn't include any Project that is not a direct descendent of the root, though I could be wrong in that.
e.g. if you have two builds, platform and shared, platform:subprojects won't have the projects it uses from sharedChris Lee
06/16/2023, 4:43 PMsubprojects, that’s legacy and broken. When you run test on the root project Gradle finds all test tasks in any child project (of any level) and runs those. This accounts for any hierarchy, project substitutions, etc.Chris Lee
06/16/2023, 4:44 PMMiles Peele
06/16/2023, 4:45 PMplatform and shared. What's strange is if I run test from the root (parent) directory like ./gradlew platform:test , I get a task not found exception
But when I cd into platform and run test, that works as expected (As you described)Chris Lee
06/16/2023, 4:48 PM./gradlew tasks Of note, the current project in front of me has an included plugin build, those tasks don’t show up (as they shouldn’t - it’s a different lifecycle being a plugin). Or ./gradlew tasks --allMiles Peele
06/16/2023, 5:15 PM./gradlew tasks --all doesn't return anything from the included builds - is that to be expected?Chris Lee
06/16/2023, 5:18 PMMiles Peele
06/16/2023, 5:19 PMsubprojects is legacy, what should we use instead?Chris Lee
06/16/2023, 5:19 PMsubprojects (or allprojects) that breaks project isolation, etc.Miles Peele
06/16/2023, 5:21 PMsubprojects to do things like:
project.subprojects {
val testTask: String? = when {
project.isAndroidApp() || project.isAndroidLib() -> "$path:testDebugUnitTest"
project.isJavaProject() -> "$path:test"
else -> null
}
if (testTask != null) {
this@TestAll.dependsOn(testTask)
}
}
I've been meaning to get rid of this logic anyway - what we should convert this logic to?
This TestAll task was added so we could only run certain variants, as Android projects have both a debug and release test that runsChris Lee
06/16/2023, 5:25 PM./gradlew testAndroid or ./gradlew testAndroidLib
As desired add these as dependencies of test or have a testAll as you’ve noted.Miles Peele
06/16/2023, 5:33 PMMiles Peele
06/16/2023, 5:46 PMMiles Peele
06/16/2023, 5:48 PMMiles Peele
06/16/2023, 5:49 PMplatform and shared, and I want to run tests for shared, I can just run test on platform right?Chris Lee
06/16/2023, 5:50 PMMiles Peele
06/16/2023, 5:53 PMtest, that'll run tests on all dependencies even if we don't need to re-validate them. How can I run test for just the paths in the graph that we know we need to validate?
For context, we do have Gradle Enterprise, some build/ folder caching, etc setup on our CI server.Chris Lee
06/16/2023, 5:54 PMMiles Peele
06/16/2023, 5:55 PMMiles Peele
06/26/2023, 5:20 PMX in my root project, I expect X to run for all subprojects) works as expected but not for our case because we have included builds
2. I was able to dynamically generate a list of tasks to run based on files changed (on top of our Gradle Enterprise/task output caching), but I'm struggling how to model this logic.
You mentioned previously that I should model this all as a build service. I currently have three tasks:
1. Find list of changed files using git
2. Find affected projects by traversing ResolvedComponentResult
3. Use result of 2) to run stuff, but running into a chicken-and-egg problem as you mentioned
How would I migrate this logic to the configuration phase and not the execution phase?Miles Peele
06/26/2023, 5:44 PM