How to import a gradle-plugin project into another project as its plugins dependecies

Thank you, Mr vampire, you are always kind to our beginners. May I ask a further question, if it does not bother you.

“How to import a gradle-plugin project into another project as its plugins dependecies”


And sorry, it is too long to read. I tried my best.

Here is the thing.

I have a multiple-project which organized by includeBuild which I learned from the gradle page composite builds. I thought it is a fresh new idea and it may improve my project structures.

Here is my project structure:

- root
  - build-plugin
  - build-sprict-advance
  - library-shared
  - library-advanced

Let me explain this.

  • build-plugin: a java-gradle-plugin project with self-define gradle plugins
  • build-sprict-advance: a kotlin-dsl project using build-plugin’s plugin with some default settings, which will used by other library project.
  • library-shared: a java project, using build-sprict-advance
  • library-advanced: another java project, using build-sprict-advance

The baisc idea is, I want to write some plugins to share to other projects through repository, which is build-plugin. But the same time, I have some java project provided as library in this project, that needs this custom plugins too, like library-xx.

And these peojcts are sharing same build logic. So I thought I could write a kotlin-dsl project to organizes them.

Here is my problem, I don’t know how to import my custom plugins in the build-sprict-advance project. I know how to use them directly in the library project. Just write a includeBuild under settings.gradle.kts’s root, the dependecies under build.gradle.kts will be recognised.

But when I try to combine them into a kotlin-dsl project, I got confused.

I understood two things:

  1. a project want to use custom plugin project, it just needs to inlucdeBuild it from the settings.gradle.kts file’s pluginManagement block, beacuse this block control plugin’s dependecies.
  2. when kotlin-dsl project file wants to use a plugin, it must defined in the build.gradle.kts 's dependecies, and since a kotlin-dsl project is also gradle plugin project, it means I need to treat it just like java-gradle-plugin

But I got stucked, I just don’t know how to import a java-gradle-plugin project into another java-gradle-plugin project correctly.

I know that I can use a repository to solve my problem, but that means I have to publish first, every time I changed build-plugin.

Again, thank you Mr Vampire.

I don’t mind at all, but this is a forum, not a chat.
So with a new topic, you should create a new thread. :wink:

But to answer your question, the build-plugin is for the build-script-advance just a regular dependency.
So use includeBuild outside pluginManagement { ... } in build-script-advance and then just declare a regular implementation dependency in the build script of build-script-advance.