nowinandroid icon indicating copy to clipboard operation
nowinandroid copied to clipboard

Fix `printModulePaths` executed during configuration phase

Open SimonMarquis opened this issue 1 year ago • 3 comments

Module paths are currently printed out every time Gradle is executed, because the print statement is part of the configuration phase.

@dturner this has been introduced in:

  • #1257

SimonMarquis avatar Mar 17 '24 13:03 SimonMarquis

Also, to make it configuration-cache compatible, and avoid the need to specify --no-configuration-cache to avoid build errors, we could use this instead:

allprojects {
    if (subprojects.size != 0) return@allprojects
    val projectPath = path
    tasks.register("printModulePaths") {
        doLast {
            println(projectPath)
        }
    }
}

WDYT?

SimonMarquis avatar Mar 17 '24 14:03 SimonMarquis

I've asked someone from the gradle team to take a look at this as I don't have the gradle experience to say whether this is a good practice or not.

dturner avatar May 13 '24 23:05 dturner

Random suggestion (I saw your review request): Check out the new Gradle lifecycle callbacks in Gradle 8.8 (which is still in development but had an RC a few weeks ago). It looks like it'll add an even cleaner way of doing what you need!

timothyfroehlich avatar May 14 '24 15:05 timothyfroehlich

Thanks for attempting to fix this @SimonMarquis, after discussion with the gradle team it seemed better to remove the gradle task altogether and keep everything in the bash script.

dturner avatar May 22 '24 14:05 dturner