gradlemarklogicml-gradle

Enable reusable gradle tasks from the ml-gradle "provider" project pattern?


Within ml-gradle, we can create a "provider" project to bundle shared MarkLogic assets (modules, schemas etc.) and use them from other dependent ml-gradle projects.

https://github.com/marklogic-community/ml-gradle/tree/master/examples/dependency-project

I am wondering if we can also incorporate custom MarkLogic gradle tasks in the provider project. Or we will need to create a gradle plugin to enable such functionality.

https://github.com/marklogic-community/ml-gradle/wiki/Writing-your-own-task

Thank you!


Solution

  • I don't think this is possible, because I believe those are considered two separate kinds of dependencies. "mlBundle" is a project configuration that ml-gradle defines, and users can define dependencies associated with this configuration, such as marklogic-unit-test. But reusable Gradle tasks are packaged up as Gradle plugins, and plugin dependencies are associated with a project's buildscript, which is separate from project configurations.

    I think a reasonable comparison is Spring Boot - you can have a "compile" dependency on the Spring Boot jar so that it's included in your Java application. Separately, your Gradle project can also depend on the Spring Boot Gradle plugin in order to inherit tasks like "bootRun" and "bootJar".

    So for your use case, I believe you'd first need a package that can be depended on via mlBundle, and you'd then need a separate Gradle plugin that users can choose to apply to their project.