Very long syntax when using type-safe project accessors

The new Gradle 7 type-safe project accessors are cool, but some of the syntax becomes pretty involved.


tasks {
  featureTest {

… becomes …

tasks {
  named("featureTest") {

Is there a simpler way? Or are there plans on improving the syntax?


Long story short: this makes it extremely explicit that you’re reaching to another project state :slight_smile: You should avoid cross-project dependencies like this as much as possible. Can I ask the use case here to figure out if there’s a better way?

1 Like

Thanks for the answer!

We use this for several things. Making sure that all dependant projects are assembled before featureTests are run, for example. Or making sure docker containers have been built for all involved projects when using the gradle-docker-compose plugin.

So basically using this mechanism as “gates”. We’re thinking of a better way to express this, which wouldn’t imply task dependencies. One option for you is to implement a Build Service to coordinate tasks.

Thanks! It’s not immediately obvious to me how I could use a Build Service for this, though.

Not a biggie since the current solution works fine for us right now.