Skip to content

Commit e0e9129

Browse files
committed
#594 Added mlDeployToReplica
1 parent 56af157 commit e0e9129

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins {
44
id "signing"
55

66
id "com.github.jk1.dependency-license-report" version "1.3"
7-
id "com.gradle.plugin-publish" version "0.11.0"
7+
id "com.gradle.plugin-publish" version "0.15.0"
88
id "java-gradle-plugin"
99

1010
id "net.saliman.properties" version "1.5.1"
@@ -29,7 +29,7 @@ repositories {
2929
dependencies {
3030
implementation gradleApi()
3131
implementation localGroovy()
32-
api "com.marklogic:ml-app-deployer:4.2.1"
32+
api "com.marklogic:ml-app-deployer:4.3.0-SNAPSHOT"
3333
implementation "com.marklogic:mlcp-util:1.0"
3434
implementation "com.marklogic:marklogic-data-movement-components:2.3.0"
3535
implementation "commons-io:commons-io:2.8.0"

src/main/groovy/com/marklogic/gradle/MarkLogicPlugin.groovy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ class MarkLogicPlugin implements Plugin<Project> {
113113
project.task("mlRedeploy", group: deployGroup, dependsOn: ["mlClearModulesDatabase", "mlDeploy", "mlDeleteResourceTimestampsFile"], description: "Clears the modules database and then deploys the application")
114114
project.task("mlDeleteResourceTimestampsFile", type: DeleteResourceTimestampsFileTask, group: deployGroup, description: "Delete the properties file in the build directory (stored there by default) that keeps track of when each resource was last deployed; the file path can be overridden by setting the filePath property of this class")
115115
project.task("mlPreviewDeploy", type: PreviewDeployTask, group: deployGroup, description: "Preview a deployment without making any changes")
116+
project.task("mlDeployToReplica", type: DeployToReplicaTask, group: deployGroup,
117+
description: "Deploys application resources in the same manner as mlDeploy, but will not deploy anything that " +
118+
"involves writing data to a database - such as modules, schemas, and triggers - thus making it safe for use " +
119+
"when deploying an application to a replica cluster")
116120

117121
String adminGroup = "ml-gradle Admin"
118122
project.task("mlInit", type: InitTask, group: adminGroup, description: "Perform a one-time initialization of a MarkLogic server; uses the properties 'mlLicenseKey' and 'mlLicensee'")
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.marklogic.gradle.task
2+
3+
import com.marklogic.appdeployer.command.Command
4+
import com.marklogic.appdeployer.command.CommandMapBuilder
5+
import com.marklogic.appdeployer.impl.SimpleAppDeployer
6+
import org.gradle.api.tasks.Input
7+
import org.gradle.api.tasks.Optional
8+
import org.gradle.api.tasks.TaskAction
9+
10+
import java.util.function.Supplier
11+
12+
class DeployToReplicaTask extends MarkLogicTask {
13+
14+
@Input
15+
@Optional
16+
// Intended to allow for DHF, or even a user, to provide a custom list of commands.
17+
// A user may wish to do this so that e.g. security commands are not included, in case the Security database is
18+
// being replicated.
19+
Supplier<List<Command>> commandListSupplier
20+
21+
@TaskAction
22+
void deployToReplica() {
23+
List<Command> commands = commandListSupplier != null ?
24+
commandListSupplier.get() :
25+
new CommandMapBuilder().getCommandsForReplicaCluster()
26+
27+
new SimpleAppDeployer(commands).deploy(getAppConfig())
28+
}
29+
}

0 commit comments

Comments
 (0)