coditory / gradle-integration-test-plugin

Gradle plugin with integrationTest task
MIT License
77 stars 4 forks source link

Lazy configuration of test tasks #156

Open tarasgor-allegro opened 1 week ago

tarasgor-allegro commented 1 week ago

Context

To improve configuration phase of gradle scripts that uses this plugin.

Expected behavior

If we have the following build script with custom task:

plugins {
    ...
    id("com.coditory.integration-test")
}

val customTask by tasks.registering {
    println("Configuring customTask")
    doLast {
        println("Custom task executed")
    }
}

tasks.withType<Test>().configureEach {
    println("Long running configuration....")
}

Then executing custom task: ./gradlew customTask Should not trigger the configuration of all test tasks:

❯ ./gradlew customTask
Configuring customTask

> Task :customTask
Custom task executed

BUILD SUCCESSFUL in Xs

Observed behavior

If we have the following build script with custom task:

plugins {
    ...
    id("com.coditory.integration-test")
}

val customTask by tasks.registering {
    println("Configuring customTask")
    doLast {
        println("Custom task executed")
    }
}

tasks.withType<Test>().configureEach {
    println("Long running configuration....")
}

Then executing custom task: ./gradlew customTask triggers the configuration of all test tasks:

❯ ./gradlew customTask

> Configure project :XXX
Long running configuration....
Configuring customTask

> Task :customTask
Custom task executed

BUILD SUCCESSFUL in Xs
bgalek commented 1 week ago

I would say it's improvement not a bug ;)

pmendelski commented 1 week ago

@tarasgor-allegro thanks for creating this issue and the draft PR, it was really helpful.

After reading Gradle lazy configuration I added/changed some tests to cover the lazy path and found few more corner cases to cover. Thus created and merged a separate PR https://github.com/coditory/gradle-integration-test-plugin/pull/157

Overall it's a great improvement and my oversight. Please test the newest version 2.2.0 and let me know if all works as intended.

bgalek commented 1 week ago

NICE! :) I'll be happy to test that out :)

tarasgor-allegro commented 1 week ago

👍