Gradle Plugin for multiprojects

Please help!

I have a multi projects project and i need to write a plugin that must interact with each project (for instance, print each projects name(e.g., “hello ${project.name}”)

I wonder how to implement it, and how to build it, where the plugin source should be placed, what should be written in the rootDir build.gradle.kts file and etc.

For example, we have the rootDir, where are projA and projB, which just print “Hello from A” and “Hello from B”.
When gradle builds it, the plugin should do the following:

Hello from A
Hello, projA!
Hello from B
Hello, projB!

There can be more then two projects.

Welcome @mikee,

You would need to write a plugin and apply it to the root build. Then you can access all subprojects using project.getSubprojects(). For a plugin that you only need in your own project, you can put the plugin sources in the buildSrc folder or define the plugin class directly in your root build script.

Please follow our documentation and samples for more details. You can start here:
https://docs.gradle.org/current/userguide/custom_plugins.html#sec:writing_a_simple_plugin