@@ -9,6 +9,7 @@ import com.marklogic.client.DatabaseClient
99import com.marklogic.mgmt.ManageClient
1010import com.marklogic.mgmt.admin.AdminManager
1111import org.gradle.api.DefaultTask
12+ import org.gradle.api.GradleException
1213import org.gradle.api.tasks.Internal
1314
1415/**
@@ -101,13 +102,22 @@ class MarkLogicTask extends DefaultTask {
101102 return deployer
102103 }
103104
105+ Command getCommandWithClassName (String className ) {
106+ SimpleAppDeployer d = (SimpleAppDeployer )getAppDeployer()
107+ Command command = d. getCommand(className)
108+ // New in 4.4.0 - before, null was returned and no command was run, which would be very unexpected when the
109+ // caller is asking to run a specific command.
110+ if (command == null ) {
111+ throw new GradleException (" No command found with class name: " + className)
112+ }
113+ return command
114+ }
115+
104116 void invokeDeployerCommandWithClassName (String className ) {
105- SimpleAppDeployer d = (SimpleAppDeployer )getAppDeployer()
106- new SimpleAppDeployer (getManageClient(), getAdminManager(), d. getCommand(className)). deploy(getAppConfig())
117+ new SimpleAppDeployer (getManageClient(), getAdminManager(), getCommandWithClassName(className)). deploy(getAppConfig())
107118 }
108119
109120 void undeployWithCommandWithClassName (String className ) {
110- SimpleAppDeployer d = (SimpleAppDeployer )getAppDeployer()
111- new SimpleAppDeployer (getManageClient(), getAdminManager(), d. getCommand(className)). undeploy(getAppConfig())
121+ new SimpleAppDeployer (getManageClient(), getAdminManager(), getCommandWithClassName(className)). undeploy(getAppConfig())
112122 }
113123}
0 commit comments