./gradlew build does not run tests of downstream composite projects?

In gradle 7.1.1 - I have the following modules with the top one depending on the next depending on the next (These links have VERY SIMPLE build.gradle and settings.gradle files)

I temporarily added a “throw new RuntimeException” to a test in core-datawrapper and core-util and built the project core-ssl (in the repo, …/…/gradlew build)

ie. steps

  1. add if(true) throw Runtimeexception to any test in core-util
  2. cd core/core-ssl
  3. Run …/…/gradlew build

The settings of core-ssl (found in above link and pasted here) is

includeBuild '../core-datawrapper'
includeBuild '../core-mock'

The settings of core-datawrapper (again in above links)

includeBuild '../core-util'

I clear out core-util/build and I see these targets run

> Task :core-util:compileJava
> Task :core-util:classes
> Task :core-util:jar

That is it. Why are the tests not running? I thought build depended on assemble and test separately?

Also, …/…/gradlew clean only cleans top project and not downstream projects. I am guessing …/…/gradlew publish has trouble too and I need to publish all artifacts if the build passes

Yes, that’s correct.
This is most probably due to the original use-case of composite builds.
You have some binary dependency on some library, and then you want to change something in the library and test it in your project before even committing or publishing the library.
So the composite build result replaces the binary dependeny and only as much work as really necessary is done, meaning the jar is built.

If you use composite builds as normal structuring element, you either need to wire the lifecycle tasks you want to have wired yourself or search for a plugin that maybe does it.

2 Likes