-
Notifications
You must be signed in to change notification settings - Fork 78
How ml gradle works
rjrudin edited this page Jun 26, 2018
·
3 revisions
The primary set of tasks within ml-gradle are related to deploying an application to MarkLogic. The main task is "mlDeploy", and there are many resource-specific deployment tasks as well, such as "mlDeployDatabases" and "mlDeployUsers". Here's how those tasks work:
- ml-gradle is a Gradle plugin, so when you apply it in your Gradle file - e.g. "apply plugin: 'ml-gradle'" - Gradle looks for a plugin class to execute.
- The ml-gradle plugin class is MarkLogicPlugin, which we'll refer to as "MLP".
- MLP has two main jobs - initialize a set of objects from the ml-app-deployer library, and initialize a set of tasks which you can view by running "gradle tasks". ml-gradle doesn't really do much at all - it's a thin, Gradle-specific layer that exposes all the useful functionality in ml-app-deployer. ml-app-deployer has no dependency on ml-gradle so that it can be used in any environment.
- The most important object initialized by MLP is an instance of SimpleAppDeployer under the Gradle property name "mlAppDeployer". MLP adds a few dozen different commands from ml-app-deployer; these commands are invoked when you run "gradle mlDeploy" and "gradle mlUndeploy".
- MLP also applies all the properties in gradle.properties - see Configuring ml-gradle for more info on this. When you run gradle with the "-i" or "--info" parameter, you'll see all the properties that are applied.
- Once Gradle has finished executing MLP, all the ml-app-deployer objects and tasks are ready for use.
A key point to understand though is that when an "mlDeploy*" task is run, it's run one or more ml-app-deployer Command objects, with each Command object being associated with a particular resource. The mlDeploy task doesn't depend on a bunch of other mlDeploy* tasks - it instead relies on ml-app-deployer to know in what order to run all of the commands. This allows that ordering logic to be reused in contexts outside of Gradle.