Zak Taccardi
12/10/2025, 9:03 PMTest task that can run some live network tests, when -PnetworkTest=true. If -PnetworkTest=false - then regular local tests will be run, not live network tests.
For network tasks to run successfully, I need to specify a myServer.secretToken=XXX gradle property.
By default, to not cause configuration issues for the Test task when -PnetworkTest=false, gradle.properties contains a blank value for `myServer.secretToken`:
myServer.secretToken=
This way, the Provider<String> that represents it contains a blank value and does not cause issues when devs aren’t running integration tests.
However, I would like to throw a build time error BEFORE test execution, ONLY when:
• that specific Test task is scheduled for execution
• -PnetworkTest=true
• myServer.secretToken is blank
What would be the best way to achieve this?Philip W
12/10/2025, 9:16 PMTheGoesen
12/10/2025, 9:22 PMZak Taccardi
12/10/2025, 10:52 PMThomas Broyer
12/11/2025, 8:07 AMProperty<String> to an empty string if absent and networkTest=false, and absent if networkTest=true (so it will fail the build)?
val networkTestProvider = providers.gradleProperty("networkTest").map(String::toBoolean)
providers.gradleProperty("myServer.secretToken").zip(networkTestvider, (secretToken, networkTest) -> secretToken.takeUnless { it.isBlank() && networkTest == true })