gradle 7.1.1 not running tests of includedBuilds nor transitive ones?

Viewed 108

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 an throw new RuntimeException to a test in core-datawrapper and core-util and built the project core-ssl (in the repo, ../../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 is the tests not running? I thought build depended on assemble and test separately?

The same for ../../gradlew clean and ../../gradlew publish

Ideally, I want my target to affect all transitive projects as well. As developers add projects, I don't want to have to add code to each gradle project in the transitive deps list either.

1 Answers

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.

As developers add projects, I don't want to have to add code to each gradle project in the transitive deps list either.

You can programmatically iterate through the included builds using gradle.includedBuilds, so you can do the wiring in a generic way.

Related