Skip to content

Instantly share code, notes, and snippets.

@eouthwaite
Created October 12, 2018 21:23
Show Gist options
  • Save eouthwaite/67f63279c2c885c2ebe1648bea232df7 to your computer and use it in GitHub Desktop.
Save eouthwaite/67f63279c2c885c2ebe1648bea232df7 to your computer and use it in GitHub Desktop.
clunky gradle bits to get ml-unit-test to play nicely with DHF 2.0.4 - tests will only be deployed in test or local environment
// clunky gradle bits to get ml-unit-test to play nicely with DHF 2.0.4 - tests will only be deployed in test or local environment
task copyTests(type: Copy) {
from file("test-src")
into file("plugins")
}
task removeTests(type: Delete) {
delete "plugins/test"
}
task myProjectDeployTestData(type: com.marklogic.gradle.task.MlcpTask) {
description 'Deploys the /test-src directory into the Modules DB without corrupting binaries.'
doFirst {
database = mlModulesDbName
}
classpath = configurations.mlcp
command = "IMPORT"
input_file_path = 'test-src/'
input_file_type = 'documents'
output_uri_replace = ".*/test-src,''"
args = ['-mode', 'local', '-thread_count', '8']
}
// no need to copy the tests when deploying (MLCP used so that binary documents don't get broken)
task myProjectDeployTest(dependsOn: [copyTestDBConfig, copyTestEPConfig, mlDeploy, myProjectDeployTestData, removeTestDBConfig, removeTestEPConfig]) {
description 'Full deployment for testing environment - use myProjectDeploy'
}
// copy the tests to ensure that they are deleted
task myProjectUndeployTest(dependsOn: [copyTestDBConfig, copyTestEPConfig, copyTests, mlUndeploy, removeTestDBConfig, removeTestEPConfig, removeTests]) {
description 'Full undeploy for testing environment - use myProjectUndeploy'
}
if (environmentName in ["local", "test"]) {
println "\nDeploying tests: " + environmentName + " environment\n"
myProjectDeploy.dependsOn myProjectDeployTest
myProjectUndeploy.dependsOn myProjectUndeployTest
} else {
println "\nNOT DEPLOYING TESTS!: " + environmentName + " environment\n"
myProjectDeploy.dependsOn mlDeploy
myProjectUndeploy.dependsOn mlUndeploy
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment