This message was deleted.
# community-support
s
This message was deleted.
v
Did you simply try it?
d
Yes, and it didn't work
I tried to locate the
includeBuild
by the project coordinate inside of
buildSrc
with
implementation project(":buildtools")
and the error is
Copy code
> Project with path ':buildtools' could not be found in project ':buildSrc'.
Should I be trying to go in the other direction? and if yes, what would the project coordinate be because
implementation project(":buildSrc")
doesn't seem to work
v
An included build is an included build, not an included project. Included projects are part of a multi-project build and can be referenced with
project(...)
. Included builds are own builds and you cannot reference them with
project(...)
, you just reference them by their normal Maven coordinates like any other dependency.
d
I'm pretty sure I tried both, but thanks for the pointer. I'll give it a try later
Do I need to do any dependency substitution maybe?
v
Not if your included build is properly set up. Use it's
outgoingVariants
task and you should see the coordinates you need to use.
šŸ™ 1
d
looks like it's not supported https://github.com/gradle/gradle/issues/12978. I'm getting that same error.
v
"that same error."? That you cannot use
includeBuild
from
buildSrc
? That is expected. I just thought it might maybe work like with the plugin, that you included from the root build and can access it from
buildSrc
since the order changed and settings are now evaluated before
buildSrc
. This was the other way around in older Gradle versions.
And yes, this works just fine.
I just tried it
d
if you're referring to sharing the plugin in
includeBuild
to
buildSrc
, I'm aware that works. The missing piece for me is how to reuse the classes in that plugin as a dependency.
v
No, I'm not, what you want is exactly what I meant and said
You
includeBuild
in the "parent" settings script and just declare the dependency in the
buildSrc
build.
šŸ™Œ 1
Alternatively you can of course simple kick
buildSrc
. I never use it these days, except for exceptional cases like monkey-patching plugin classes. Besides that I always use an included build like
gradle/build-logic
d
oh i see, the
settings.gradle
for
buildSrc
i would get rid of
buildSrc
eventually.. just will take some time
v
No, not the settings script of
buildSrc
, you do not listen
There you will just get the exception from that ticket
The settings script of the "parent" build, where you also would include the plugin in the docs you referred to
d
it's already included in my rootProject's
settings.gradle
v
Then you just need to properly declare the dependency as I said multiple times already.
Unless you are on an ancient Gradle version
d
i'm on Gradle 7.3.3
v
There it should probably work
I tried it witz 7.4.2 and it worked fine.
d
could you perhaps point to a working example? I'm trying my best and it's not as easy for me as it might be for you šŸ˜‰
v
I don't have one, I just wrote it ad-hoc into my play project and it simply worked. But I don't know what to show, it is just the two lines. The
includeBuild
in the parent settings script and the dependency in the
buildSrc
build script with the correct coordinates as can be found as capability in the output of
outgoingVariants
task as already mentioned. There is really nothing more to it.
d
this is what I have in
settings.gradle
Copy code
pluginManagement {
    includeBuild ('gradle/gradle-plugin')
}

includeBuild ('gradle/gradle-plugin')
in
gradle/gradle-plugin/settings.gradle
Copy code
rootProject.name = "plugin"

include(":plugin")
include(":buildtools")
in
buildSrc/build.gradle
, I tried both the maven coordinates and project
v
If you don't get it running, you should try to produce an [MCVE](https://stackoverflow.com/help/mcve) that shows where you have problems.
d
ok i'll try to repro in a smaller project and if I can, i'll post to S/O thanks
my error when trying to pull it in using the proper coordinates
Copy code
Execution failed for task ':buildSrc:generateSourceRoots'.
> Error while evaluating property 'sourceRoots' of task ':buildSrc:generateSourceRoots'
   > Failed to calculate the value of task ':buildSrc:generateSourceRoots' property 'sourceRoots'.
      > Project with path ':buildtools' could not be found in project ':buildSrc'.
v
That does not look like proper coordinates
d
and seems like this was fixed maybe in Gradle 7.4 https://github.com/gradle/gradle/issues/18984
v
Ah, quite possible then. As I said, I tried with 7.4.2. Was not aware there was some bug in previous version.
šŸ‘Œ 1
Well, then you either have to switch to an included build or to newer Gradle version. Both should not be dramatic changes.
āœ… 1
d
turns out you were right all along but I was hitting errors because i'm on Gradle 7.3.3 and even when upgrading to Gradle 7.4.2, I'm hitting an Idea bug that is fixed here, but that's a beta version of Android Studio (Dolphin). I probably can't use this method until Dolphin goes GA. (because large eng org) Recap as you mentioned
The
includeBuild
in the parent settings script and the dependency in the
buildSrc
build script with the correct coordinates as can be found as capability in the output of
outgoingVariants
task as already mentioned.
v
Can't you update the Kotlin plugin? It's not fixed in the IDE but in the Kotlin plugin.
d
oh i see, thanks for pointing that out.. I'll see if that works
got a few meetings today in the meantime
doesn't look like I can update the Kotlin Plugin any further than this.
must be an Android Studio thing
v
It is already on 1.7.0, that's the latest release, what updates do you expect?
d
it's still not working in that release i screenshotted. I don't know how IJ versioning works, but I'm assuming I need 213 Fixed in • IJ 221.1623 (Kotlin 221-1.5.10-release-955-IJ1623) • IJ 213.6094 (Kotlin 213-1.5.10-release-949-IJ6094)
v
If it is fixed in 1.5.10, I strongly assume it is fixed in any 1.7.0 version which comes way later
Unless the bug reappeared