https://kotlinlang.org logo
#gradle
Title
o

OrfeasZ

07/15/2023, 2:40 PM
I am
includeBuild
-ing a third party project in my
settings.gradle.kts
and calling one of its functions, which in turn discovers some other gradle projects and adds them to the build by doing something like
settings.include(':whatever')
and
settings.project(':whatever').projectDir = path
. The problem is that one of those projects does the following:
rootProject.allprojects.find {it.plugins.hasPlugin('com.android.application')}
in order to find the build directory of an android subproject (which exists) and use it as a parameter for an
externalNativeBuild
step, but it fails to find anything because (I'm guessing) the plugins for all the other subprojects haven't been declared yet (
PluginContainer
is empty). Does anyone know what would be the correct way to fix this issue?
v

Vampire

07/15/2023, 5:50 PM
Included builds are executed with the same Brand version as the including build. So if the included build is not compatible with that Gradle version, it might be problematic. Try running that included build standalone with the Gradle version of the including build to see whether it works.
o

OrfeasZ

07/15/2023, 6:03 PM
I am using the same version of gradle. There are no errors, it's just the plugins that are empty because it's probably too early in the evaluation phase or something like that.
v

Vampire

07/15/2023, 6:14 PM
If the build works standalone, it should probably also work when included. But actually I would expect that to not work stand alone either, if you try to query applied plugins during settings script evaluation. Not even the projects should be present.
o

OrfeasZ

07/15/2023, 6:15 PM
Yeah, I'm with you on that, that's why I'm trying to figure out how to do this correctly and maybe send a PR.
Basically what I'm trying to figure out is how to either rework this to be able to evaluate correctly after the plugins have been applied, or whether to replace it with something else (like some extra property in the root project which a lot of these seem to be using for configuration).
v

Vampire

07/15/2023, 6:42 PM
Hard to say out of the blue. But generally it is most probably not a good idea at all to try figuring this out at settings time but should be done somehow differently.