Gradle 6.7 - Included build isn't working correctly with buildSrc

From Gradle 6.7 Relase Notes

Sometimes, you may also need to share build logic between buildSrc itself and your root build. In the previous releases, that was not possible because buildSrc could not access build logic from other included builds.

In this release, it’s now possible to share build logic between buildSrc and the root build or any other included build. This makes it easier to share common repository declarations or conventions between buildSrc and other builds as demonstrated in this sample.

I need to share some code between buildSrc and subproject. So, I extracted that code into a separate gradle project (commons) and tried to link it as an included build in order to use it as a dependency in buildSrc and subproject. Something like this:

gradle-composite-bug (root directory)
    gradle-composite-bug (root)
        buildSrc
        subproject
    commons (our "included build")

I’ve created the sample which corresponds to the structure above. And it seems to work but with some caveats.

First item. buildSrc is not building separately. It emits the error. The whole root/subproject/commons are building fine. Is it okay ? It seems not to disturb me.

cd gradle-composite-bug/buildSrc
gradle build

Second item. Intelij IDEA doesn’t put commons on buildSrc's classpath. And as result, autocomplete doesn’t work. It’s the most serious problem, because those classes have quite interesting API that will definitely sophisticate my life without autocomplete. And IDE that permanently reports errors - is not fine at all. But it works fine with subproject where IDE have put commons on the classpath.
image
I’m not sure, but may be it’s because IDE differently sees these dependencies. They are declared similarly in corresponding gradle.build.kts files, but for buildSrc it’s a plain library, and for subproject it’s a full-fledged project.


In buildSrc's module configuration/Dependencies tab IDE reports Library 'Gradle::commons:' has broken path.

So, I have several questions:

  1. Did I misconfigure the project ? But, generally It works as intended, via terminal, of course)
  2. First item doesn’t bother me and I’m not sure if it’s a problem at all. But if yes - it’s definitely a Gradle’s one. And the bug should be reported to them.
  3. Second item is critical. It’s kind of hard to work without autocomplete and with all your code being highlighted red. Is it because I misconfigured Gradle or IDE ? Or it’s a Gradle / IDE’s problem ?

Any help/thoughts/suggestions will be appreciated :innocent: I’m afraid I’m already stuck.

I was able to get this project to work in IntelliJ. The project was originally created to demonstrate Issue #3768 (which is fixed by Gradle 6.7)

I notice that in your example] you reference the included build via the project name only

dependencies {
   implementation(":commons")
} 

Whereas in mine I reference the included build by the full group/artifact/version

dependencies {
   compile 'com.example:my-plugin:1.0-SNAPSHOT'
}