Skip to content

Commit e968312

Browse files
committed
#222 Commands can now be ignored when running mlDeploy
Merged from 2.x
1 parent aea8359 commit e968312

File tree

4 files changed

+29
-5
lines changed

4 files changed

+29
-5
lines changed

examples/local-testing-project/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Set this to the version you used when running
22
# "gradle -Pversion=(something) publishToMavenLocal" on your local ml-gradle repo
3-
mlGradleVersion=2.8.0
3+
mlGradleVersion=2.9.0
44

55
mlHost=localhost
66
mlAppName=example

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ class MarkLogicPlugin implements Plugin<Project> {
8383
String deployGroup = "ml-gradle Deploy"
8484
project.task("mlPostDeploy", group: deployGroup, description: "Add dependsOn to this task to add tasks at the end of mlDeploy").mustRunAfter(["mlDeployApp"])
8585
project.task("mlPostUndeploy", group: deployGroup, description: "Add dependsOn to this task to add tasks at the end of mlUndeploy").mustRunAfter(["mlUndeployApp"])
86-
project.task("mlDeploy", group: deployGroup, dependsOn: ["mlDeployApp", "mlPostDeploy"], description: "Deploys all application resources in the configuration directory and allows for additional steps via mlPostDeploy.dependsOn").mustRunAfter("mlClearModulesDatabase")
86+
project.task("mlDeploy", group: deployGroup, dependsOn: ["mlDeployApp", "mlPostDeploy"],
87+
description: "Deploys all application resources in the configuration directory and allows for additional steps via mlPostDeploy.dependsOn. Use -Pignore to specify a comma-delimited list of short class names of ml-app-deployer command classes to ignore while deploying.").mustRunAfter("mlClearModulesDatabase")
8788
project.task("mlUndeploy", group: deployGroup, dependsOn: ["mlUndeployApp", "mlPostUndeploy"], description: "Undeploys all application resources in the configuration directory and allows for additional steps via mlPostUndeploy.dependsOn")
8889
project.task("mlRedeploy", group: deployGroup, dependsOn: ["mlClearModulesDatabase", "mlDeploy"], description: "Clears the modules database and then deploys the application")
8990

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,34 @@
11
package com.marklogic.gradle.task
22

3+
import com.marklogic.appdeployer.impl.SimpleAppDeployer
34
import org.gradle.api.tasks.TaskAction
45

56
class DeployAppTask extends MarkLogicTask {
67

8+
/**
9+
* Use "-Pignore" to specify the short class names of ml-app-deployer commands to ignore. The commands are then
10+
* removed from the mlAppDeployer object, as long as it is an instance of SimpleAppDeployer from ml-app-deployer.
11+
*/
712
@TaskAction
813
void deployApp() {
9-
getAppDeployer().deploy(getAppConfig())
14+
def appDeployer = getAppDeployer()
15+
if (project.hasProperty("ignore")) {
16+
if (appDeployer instanceof SimpleAppDeployer) {
17+
String[] commandNames = project.property("ignore").split(",")
18+
SimpleAppDeployer deployer = (SimpleAppDeployer)appDeployer
19+
for (String commandName : commandNames) {
20+
def command = deployer.removeCommand(commandName)
21+
if (command != null) {
22+
println "Ignoring command: " + commandName
23+
} else {
24+
println "Could not find command specified by ignore property: " + commandName
25+
}
26+
}
27+
}
28+
else {
29+
println "ignore property defined, but mlAppDeployer is not an instance of SimpleAppDeployer, so not able to ignore commands"
30+
}
31+
}
32+
appDeployer.deploy(getAppConfig())
1033
}
1134
}

src/main/groovy/com/marklogic/gradle/task/export/ExportResourcesTask.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import com.marklogic.appdeployer.export.ExportedResources
44
import com.marklogic.appdeployer.export.Exporter
55
import com.marklogic.gradle.task.MarkLogicTask
66
import com.marklogic.mgmt.selector.PrefixResourceSelector
7-
import com.marklogic.mgmt.selector.PropertiesFileResourceSelector
7+
import com.marklogic.mgmt.selector.PropertiesResourceSelector
88
import com.marklogic.mgmt.selector.RegexResourceSelector
99
import com.marklogic.mgmt.selector.ResourceSelector
1010
import org.gradle.api.tasks.TaskAction
@@ -27,7 +27,7 @@ class ExportResourcesTask extends MarkLogicTask {
2727
String filename = getProject().property(filePropName)
2828
File file = new File(filename)
2929
if (file.exists()) {
30-
export(new PropertiesFileResourceSelector(file))
30+
export(new PropertiesResourceSelector(file))
3131
} else {
3232
println "File " + filename + " does not exist"
3333
}

0 commit comments

Comments
 (0)