Skip to content

Commit

Permalink
Merge pull request #642 from marklogic-community/feature/task-fix
Browse files Browse the repository at this point in the history
Throwing error when requested command does not exist
  • Loading branch information
rjrudin authored Dec 22, 2022
2 parents d30603b + 1b055d5 commit b0591cc
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/main/groovy/com/marklogic/gradle/task/MarkLogicTask.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.marklogic.client.DatabaseClient
import com.marklogic.mgmt.ManageClient
import com.marklogic.mgmt.admin.AdminManager
import org.gradle.api.DefaultTask
import org.gradle.api.GradleException
import org.gradle.api.tasks.Internal

/**
Expand Down Expand Up @@ -101,13 +102,22 @@ class MarkLogicTask extends DefaultTask {
return deployer
}

Command getCommandWithClassName(String className) {
SimpleAppDeployer d = (SimpleAppDeployer)getAppDeployer()
Command command = d.getCommand(className)
// New in 4.4.0 - before, null was returned and no command was run, which would be very unexpected when the
// caller is asking to run a specific command.
if (command == null) {
throw new GradleException("No command found with class name: " + className)
}
return command
}

void invokeDeployerCommandWithClassName(String className) {
SimpleAppDeployer d = (SimpleAppDeployer)getAppDeployer()
new SimpleAppDeployer(getManageClient(), getAdminManager(), d.getCommand(className)).deploy(getAppConfig())
new SimpleAppDeployer(getManageClient(), getAdminManager(), getCommandWithClassName(className)).deploy(getAppConfig())
}

void undeployWithCommandWithClassName(String className) {
SimpleAppDeployer d = (SimpleAppDeployer)getAppDeployer()
new SimpleAppDeployer(getManageClient(), getAdminManager(), d.getCommand(className)).undeploy(getAppConfig())
new SimpleAppDeployer(getManageClient(), getAdminManager(), getCommandWithClassName(className)).undeploy(getAppConfig())
}
}

0 comments on commit b0591cc

Please sign in to comment.