Is there a project isolation compatible way to spe...
# community-support
e
Is there a project isolation compatible way to specify that all subprojects should have a specific plugin applied? My use case is that I have a convention plugin that I want applied to all subprojects, but I don't want to have to remember to add it for any new subproject.
v
gradle.lifecycle.beforeProject { ... }
iirc
e
Nice, thanks!
Looks like that will run for empty directories as well. So if I have two project
:data:one
and
:data:two
, then the lambda will run for
:data
,
:data:one
, and
:data:two
c
β€˜:data’ phantom project can be avoided by adjusting the project dir. docs: https://docs.gradle.org/current/userguide/multi_project_builds.html#modifying_a_subproject_path
thank you 1
πŸ‘ 1
e
For my use case
Copy code
if(childProjects.isNotEmpty()) return@beforeProject
is a little cleaner
πŸ‘ 1
m
For more context, the issue where this was discussed: https://github.com/gradle/gradle/issues/22514#issuecomment-2099179052
thank you 1
e
Seems to be working pretty well (other than needing to use
afterEvaluate
to apply precompiled script plugins)
v
Dooon't
πŸ˜‚ 1
There's also
afterProject
sibling
e
Thanks! I know
afterEvaluate
is usually the wrong answer, but this is in my WIP branch for Gradle 9 so I figured I'd get the solution before I merged it (which I did thanks to you πŸ˜„ )
πŸ‘Œ 1