Skip to content

Writing your own management task

rjrudin edited this page Jun 21, 2015 · 11 revisions

ml-gradle wraps ml-app-deployer with a number of tasks, but in case you want to do something with the MarkLogic Management API that isn't yet supported by ml-gradle, you can simply write a new Gradle task and use an instance of ManageClient to easily invoke Management API endpoints. The ManageClient wraps an instance of Spring's RestTemplate and is already configured with the connection properties in your gradle.properties file.

The sample-project Gradle file shows an example of how to do this, which is shown below as well:

task mergeContentDatabase(type: com.marklogic.gradle.task.MarkLogicTask) {
    doLast {
        getManageClient().postJson("/manage/v2/databases/" + getAppConfig().getContentDatabaseName(), '{"operation":"merge-database"}')
    }
}
Clone this wiki locally