Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
rjrudin committed Jun 1, 2018
2 parents cba9e2d + 40fbfba commit c82c408
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ if (project.hasProperty("myBintrayUser")) {
bintray {
user = myBintrayUser
key = myBintrayKey
publications = ['mainJava', 'sourcesJava', 'mavenJavadoc']
publications = ['mainJava', 'sourcesJava']
pkg {
repo = 'maven'
name = project.name
Expand Down
2 changes: 1 addition & 1 deletion examples/local-testing-project/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Set this to the version you used when running
# "gradle -Pversion=(something) publishToMavenLocal" on your local ml-gradle repo
mlGradleVersion=3.6.1
mlGradleVersion=3.7.0-rc1

mlHost=localhost
mlAppName=example
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
group=com.marklogic
version=3.6.3
version=3.7.0
javadocsDir=../gh-pages-marklogic-java/javadocs

mlAppDeployerDependency=com.marklogic:ml-app-deployer:3.6.3
mlAppDeployerDependency=com.marklogic:ml-app-deployer:3.7.0
mlcpUtilDependency=com.marklogic:mlcp-util:0.9.0
mlDataMovementDependency=com.marklogic:marklogic-data-movement-components:1.0
mlUnitTestDependency=com.marklogic:ml-unit-test-client:0.10.0
6 changes: 6 additions & 0 deletions src/main/groovy/com/marklogic/gradle/MarkLogicPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.marklogic.gradle.task.alert.DeleteAllAlertConfigsTask
import com.marklogic.gradle.task.alert.DeployAlertingTask
import com.marklogic.gradle.task.client.*
import com.marklogic.gradle.task.cluster.*
import com.marklogic.gradle.task.configuration.DeployConfigurationsTask
import com.marklogic.gradle.task.cpf.DeployCpfTask
import com.marklogic.gradle.task.cpf.LoadDefaultPipelinesTask
import com.marklogic.gradle.task.databases.*
Expand All @@ -26,6 +27,7 @@ import com.marklogic.gradle.task.forests.ConfigureForestReplicasTask
import com.marklogic.gradle.task.forests.DeleteForestReplicasTask
import com.marklogic.gradle.task.forests.DeployCustomForestsTask
import com.marklogic.gradle.task.forests.DeployForestReplicasTask
import com.marklogic.gradle.task.forests.PrintForestPlanTask
import com.marklogic.gradle.task.groups.DeployGroupsTask
import com.marklogic.gradle.task.groups.SetTraceEventsTask
import com.marklogic.gradle.task.hosts.AssignHostsToGroupsTask
Expand Down Expand Up @@ -106,6 +108,9 @@ class MarkLogicPlugin implements Plugin<Project> {
project.task("mlDeleteAllAlertConfigs", type: DeleteAllAlertConfigsTask, group: alertGroup, description: "Delete all alert configs, which also deletes all of the actions rules associated with them")
project.task("mlDeployAlerting", type: DeployAlertingTask, group: alertGroup, description: "Deploy each alerting resource - configs, actions, and rules - in the configuration directory")

String configurationGroup = "ml-gradle Configuration"
project.task("mlDeployConfigurations", type: DeployConfigurationsTask, group: configurationGroup, description: "Deploy each configuration (requires at least MarkLogic 9.0-5) in the configuration directory")

String cpfGroup = "ml-gradle CPF"
project.task("mlDeployCpf", type: DeployCpfTask, group: cpfGroup, description: "Deploy each CPF resource - domains, pipelines, and CPF configs - in the configuration directory").mustRunAfter("mlClearTriggersDatabase")
project.task("mlRedeployCpf", group: cpfGroup, dependsOn: ["mlClearTriggersDatabase", "mlDeployCpf"], description: "Clears the triggers database and then calls mlDeployCpf; be sure to reload custom triggers after doing this, as they will be deleted as well")
Expand Down Expand Up @@ -187,6 +192,7 @@ class MarkLogicPlugin implements Plugin<Project> {
project.task("mlDeleteForestReplicas", type: DeleteForestReplicasTask, group: forestGroup, description: "Deprecated - delete forest replicas via the command.forestNamesAndReplicaCounts map")
project.task("mlDeployCustomForests", type: DeployCustomForestsTask, group: forestGroup, description: "Deploy custom forests as defined in subdirectories of the forests configuration directory")
project.task("mlDeployForestReplicas", type: DeployForestReplicasTask, group: forestGroup, description: "Prefer this over mlConfigureForestReplicas; it does the same thing, but uses the ConfigureForestReplicasCommand that is used by mlDeploy")
project.task("mlPrintForestPlan", type: PrintForestPlanTask, group: forestGroup, description: "Print a list of primary forests to be created for a database specified by -Pdatabase=(name of database) when the database is next deployed")

String groupsGroup = "ml-gradle Group"
project.task("mlDeployGroups", type: DeployGroupsTask, group: groupsGroup, description: "Deploy each group, updating it if it exists, in the configuration directory")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public String getProperty(String name) {
*
* This currently only includes properties that start with "ml". This is to avoid picking up very generically-named
* properties in Gradle, such as "name" and "version", which may conflict with properties from other sources.
* @return
*/
@Override
public Properties getProperties() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.marklogic.gradle.task.configuration

import com.marklogic.gradle.task.MarkLogicTask
import org.gradle.api.tasks.TaskAction

class DeployConfigurationsTask extends MarkLogicTask {

@TaskAction
void deployConfigurations() {
deployWithCommandListProperty("mlConfigurationCommands")
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.marklogic.gradle.task.forests

import com.marklogic.appdeployer.AppConfig
import com.marklogic.appdeployer.command.databases.DeployContentDatabasesCommand
import com.marklogic.appdeployer.command.databases.DeployDatabaseCommand
import com.marklogic.appdeployer.command.databases.DeploySchemasDatabaseCommand
import com.marklogic.appdeployer.command.databases.DeployTriggersDatabaseCommand
import com.marklogic.appdeployer.impl.SimpleAppDeployer
import com.marklogic.gradle.task.MarkLogicTask
import com.marklogic.mgmt.api.forest.Forest
import org.gradle.api.tasks.TaskAction

class PrintForestPlanTask extends MarkLogicTask {

@TaskAction
void printForestPlan() {
if (!project.hasProperty("database")) {
println "Please specify a database via the 'database' property"
return
}

String database = project.property("database")

/**
* We unfortunately have to do a little work here to determine what command object to use based on the database
* name. That's to account for the "special" stuff that's done for the content database (mlContentForestsPerHost)
* and for the schema/triggers databases (those commands default to only having forests on one host).
*/
AppConfig appConfig = getAppConfig()
SimpleAppDeployer appDeployer = getAppDeployer()
DeployDatabaseCommand command
if (database.equals(appConfig.getContentDatabaseName()) || database.equals(appConfig.getTestContentDatabaseName())) {
command = appDeployer.getCommandOfType(DeployContentDatabasesCommand.class)
} else if (database.equals(appConfig.getSchemasDatabaseName())) {
command = appDeployer.getCommandOfType(DeploySchemasDatabaseCommand.class)
} else if (database.equals(appConfig.getTriggersDatabaseName())) {
command = appDeployer.getCommandOfType(DeployTriggersDatabaseCommand.class)
} else {
command = new DeployDatabaseCommand()
}

/**
* Now that we have a command, use it to build its command for deploying forests, and then use that to build
* the list of forests that will be created.
*/
List<Forest> forests = command.buildDeployForestsCommand(database, getCommandContext()).buildForests(getCommandContext(), true)


if (forests.isEmpty()) {
println "\nNo primary forests will be created the next time the database '" + database + "' is deployed; this is likely because it already has all of the primary desired forests based on the configuration settings."
println "\nIf replicas have been configured for the database - e.g. via mlDatabaseNamesAndReplicaCounts - and these do not exist yet, " +
"then replicas will be created the next time either the mlDeploy task or mlConfigureForestReplicas task is run."
} else {
for (Forest f : forests) {
println f.getJson()
}
println "\nThe " + forests.size() + " forests (and replicas if applicable) that will be created the next time the database '" + database + "' is deployed (e.g. via the mlDeploy task) are listed above."
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ class DeleteAllTasksTask extends MarkLogicTask {

@TaskAction
void deleteAllTasks() {
String group = "Default"
if (project.hasProperty("mlGroupName")) {
group = project.property("mlGroupName")
}
println "Deleting all scheduled tasks in group: " + group
new TaskManager(getManageClient()).deleteAllScheduledTasks()
}
}

0 comments on commit c82c408

Please sign in to comment.