Reading of in nested projects

I’ve been experimenting with setting versions for my projects in I noticed some aren’t being read, which seemed odd to me, but I’ve only recently been deep diving into gradle. So I won’t be surprised to be incorrect.

I have a top level multi-project build that’s acting as an umbrella build. I have a nested multi-project that has a couple of subprojects. None of this is using composite builds, which is where I think I should end up, but wanted to understand this anyways. Here’s the structure:

umbrella proj
- settings.gradle (includes multi-proj:libA)
- (1)
- multi-proj (includes libA)
-- (2)
-- libA
--- (3)

To test this out, I’ve been running gradle jar in the umbrella directory. If I set the version in (1), libA’s jar file name includes that. If I set version in (3), it uses that instead of (1). If I unset it in (3) and set it in (2), it ignores (2) and uses (1).

Give this text from build environment section of the docs, I assumed that (2) should also be read at some point:

  • in the project’s directory, then its parent project’s directory up to the build’s root directory.

I’d appreciate any insight on if my assumptions are faulty

I can confirm what you see and also that I expected the same as you from the docs.
You should report this (hopefully) wrong behavior.
Actually the behavior is there for really long already (I tried from 2.14.1 on), but the documentation changed over time, never matching what the code does. :smiley:

In Gradle 2.x and 3.x docs said only the file in “project build directory”.
In Gradle 4.x, 5.x, and 6.x docs said only the file in “project root directory”.
Since Gradle 7.x it says “project’s directory, then its parent project’s directory up to the build’s root directory”.

But the outcome was the same in all, project directory, then root project directory and nothing in-between.
So either the docs need to be adjusted to finally match the behavior, or the code changed, as the documented behavior imho makes sense.

Feel free to add this investigation result to the issue.

Would you mind posting the link to your created issue here for reference @cgarman?

Sorry for the delay: in nested multi-projects isn't being read · Issue #24680 · gradle/gradle · GitHub

1 Like