-
Notifications
You must be signed in to change notification settings - Fork 80
Common tasks
These tasks are present in both ml-gradle 1.* and 2.*.
"gradle mlWatch" - invokes the WatchTask.
This runs an infinite loop, checking every second for modifications in the application's set of module paths. This is a useful task to run when you're developing modules and you only want to load what you've created/modified, and you don't want to have to run a command after every change to load your modules.
See How modules are loaded for information on how modules are actually loaded.
Note that this does not yet account for deleted modules - i.e. it won't delete the corresponding module from the modules database.
Call "gradle mlClearContentDatabase" (or usually "gradle mlclearcon") to delete all documents in your content database. You must include the property -PdeleteAll=true. This property is required to decrease the chance that you run this task accidentally.
gradle mlClearModules
Invokes the ClearModulesTask for clearing out all or most of the modules in a modules database. Useful for when you need to do a fresh load of modules because some of the ones in the modules database may have been deleted from your project.
You can easily create - i.e. stub out - a new REST API resource (or "service") via the following command:
gradle mlCreateResource -PresourceName=sample
The resourceName project property is required; it is used to name the resource file and its namespace. The following files will be created in your project:
- src/main/xqy/services/sample.xqy
- src/main/xqy/services/metadata/sample.xml
The metadata file is used to provide metadata to the REST API when your resource is installed. You can customize this as you wish.
You can easily create - i.e. stub out - a new REST API transform via the following command:
gradle mlCreateTransform -PtransformName=sample -PtransformType=xsl
where transformType defaults to "xqy" and can be either "xqy" or "xsl".
This will create the following file in your project:
- src/main/xqy/transforms/sample.xqy
gradle mlLoadModules
The purpose of this task is to use the Client REST API to load modules from one or more directory paths. This work of loading modules is handled by the DefaultModulesLoader class found in the ml-java module. See How modules are loaded for more information.
In ml-gradle 2.+, assets - those under /ext - are loaded by XCC by default, as this is typically much faster than loading each module one at a time via the REST API.
By default, this task looks in the src/main/xqy directory for modules to load via the MarkLogic Service Extension REST API. This can be customized in the build.gradle file by modifying the "modulePaths" property in "mlAppConfig" (an instance of AppConfig added by MarkLogicPlugin). For example, a project may have both application modules and test modules that need to be loaded for testing purposes. The build.gradle for such a project would have the following script:
ext {
mlAppConfig {
modulePaths = ["src/main/xqy", "src/test/xqy"]
}
}
gradle mlReloadModules
This task simply combines mlClearModules and mlLoadModules together. This is useful to invoke when you want to ensure you have a clean modules database - i.e. some modules may have been deleted from your version control system, but they're still hanging out in your modules database.