From 5c9e96a6f1afd637eaf26c0662fc014480074c8a Mon Sep 17 00:00:00 2001 From: Charles Greer Date: Sat, 19 Mar 2016 17:09:52 -0700 Subject: [PATCH 1/2] Schemas data loading --- gradle.properties | 2 +- .../marklogic/gradle/MarkLogicPlugin.groovy | 12 +++++++++ .../task/schemas/LoadSchemasTask.groovy | 26 +++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 src/main/groovy/com/marklogic/gradle/task/schemas/LoadSchemasTask.groovy diff --git a/gradle.properties b/gradle.properties index 2c37efd12..92b8c47f4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ group=com.marklogic publishUrl=file:../gh-pages-marklogic-java/releases version=2.0 -mlAppDeployerDependency=com.marklogic:ml-app-deployer:2.0 +mlAppDeployerDependency=com.marklogic:ml-app-deployer:2.1 diff --git a/src/main/groovy/com/marklogic/gradle/MarkLogicPlugin.groovy b/src/main/groovy/com/marklogic/gradle/MarkLogicPlugin.groovy index f983ff80a..fa314c40a 100644 --- a/src/main/groovy/com/marklogic/gradle/MarkLogicPlugin.groovy +++ b/src/main/groovy/com/marklogic/gradle/MarkLogicPlugin.groovy @@ -26,6 +26,7 @@ import com.marklogic.appdeployer.command.forests.ConfigureForestReplicasCommand import com.marklogic.appdeployer.command.groups.DeployGroupsCommand import com.marklogic.appdeployer.command.mimetypes.DeployMimetypesCommand import com.marklogic.appdeployer.command.modules.LoadModulesCommand +import com.marklogic.appdeployer.command.schemas.LoadSchemasCommand import com.marklogic.appdeployer.command.restapis.DeployRestApiServersCommand import com.marklogic.appdeployer.command.security.DeployAmpsCommand import com.marklogic.appdeployer.command.security.DeployCertificateAuthoritiesCommand @@ -72,6 +73,7 @@ import com.marklogic.gradle.task.forests.DeployForestReplicasTask import com.marklogic.gradle.task.groups.DeployGroupsTask import com.marklogic.gradle.task.mimetypes.DeployMimetypesTask import com.marklogic.gradle.task.scaffold.GenerateScaffoldTask +import com.marklogic.gradle.task.schemas.LoadSchemasTask import com.marklogic.gradle.task.security.DeployAmpsTask import com.marklogic.gradle.task.security.DeployCertificateAuthoritiesTask import com.marklogic.gradle.task.security.DeployCertificateTemplatesTask @@ -181,6 +183,10 @@ class MarkLogicPlugin implements Plugin { project.task("mlWatch", type: WatchTask, group: modulesGroup, description: "Run a loop that checks for new/modified modules every second and loads any that it finds") project.task("mlDeleteModuleTimestampsFile", type: DeleteModuleTimestampsFileTask, group: modulesGroup, description: "Delete the properties file in the build directory that keeps track of when each module was last loaded") + String schemasGroup = "ml-gradle Schemas" + project.task("mlLoadSchemas", type: LoadSchemasTask, group: schemasGroup, description: "Loads special-purpose data into the schemas database (XSD schemas, Inference rules, and [MarkLogic 9] Extraction Templates)") + project.task("mlReloadSchemas", type: LoadSchemasTask, dependsOn: ["mlClearSchemasDatabase", "mlLoadSchemas"], group: schemasGroup, description: "Clears schemas database then loads special-purpose data into the schemas database (XSD schemas, Inference rules, and [MarkLogic 9] Extraction Templates)") + String serverGroup = "ml-gradle Server" project.task("mlDeployServers", type: DeployServersTask, group: serverGroup, dependsOn: "mlPrepareRestApiDependencies", description: "Updates the REST API server (if it exists) and deploys each other server, updating it if it exists, in the configuration directory ") project.task("mlUndeployOtherServers", type: UndeployOtherServersTask, group: serverGroup, description: "Delete any non-REST API servers (e.g. ODBC and XBC servers) defined by server files in the configuration directory") @@ -306,6 +312,12 @@ class MarkLogicPlugin implements Plugin { project.extensions.add("mlDatabaseCommands", dbCommands) commands.addAll(dbCommands) + // Schemas + List schemasCommands = new ArrayList() + schemasCommands.add(new LoadSchemasCommand()) + project.extensions.add("mlLoadSchemasCommands", schemasCommands) + commands.addAll(schemasCommands) + // REST API instance creation commands.add(new DeployRestApiServersCommand()) diff --git a/src/main/groovy/com/marklogic/gradle/task/schemas/LoadSchemasTask.groovy b/src/main/groovy/com/marklogic/gradle/task/schemas/LoadSchemasTask.groovy new file mode 100644 index 000000000..ed59e1e11 --- /dev/null +++ b/src/main/groovy/com/marklogic/gradle/task/schemas/LoadSchemasTask.groovy @@ -0,0 +1,26 @@ +package com.marklogic.gradle.task.schemas + +import org.gradle.api.tasks.TaskAction + +import com.marklogic.appdeployer.AppDeployer +import com.marklogic.appdeployer.command.schemas.LoadSchemasCommand +import com.marklogic.appdeployer.impl.SimpleAppDeployer +import com.marklogic.gradle.task.MarkLogicTask + +class LoadSchemasTask extends MarkLogicTask { + + @TaskAction + void loadSchemas() { + LoadSchemasCommand command = null + // Check for a LoadSchemasCommand in the AppDeployer first, as that may have additional configuration that we + // don't want to have to duplicate on this task + AppDeployer d = getAppDeployer() + if (d instanceof SimpleAppDeployer) { + command = d.getCommand("mlLoadSchemasCommands") + } + if (command == null) { + command = new LoadSchemasCommand() + } + command.execute(getCommandContext()) + } +} From f95f46d767528106543d574fbae8bd9727369121 Mon Sep 17 00:00:00 2001 From: Charles Greer Date: Thu, 31 Mar 2016 20:53:43 -0700 Subject: [PATCH 2/2] Updates based on PR feedback --- src/main/groovy/com/marklogic/gradle/MarkLogicPlugin.groovy | 2 +- .../com/marklogic/gradle/task/schemas/LoadSchemasTask.groovy | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/groovy/com/marklogic/gradle/MarkLogicPlugin.groovy b/src/main/groovy/com/marklogic/gradle/MarkLogicPlugin.groovy index fa314c40a..2b92fbf28 100644 --- a/src/main/groovy/com/marklogic/gradle/MarkLogicPlugin.groovy +++ b/src/main/groovy/com/marklogic/gradle/MarkLogicPlugin.groovy @@ -185,7 +185,7 @@ class MarkLogicPlugin implements Plugin { String schemasGroup = "ml-gradle Schemas" project.task("mlLoadSchemas", type: LoadSchemasTask, group: schemasGroup, description: "Loads special-purpose data into the schemas database (XSD schemas, Inference rules, and [MarkLogic 9] Extraction Templates)") - project.task("mlReloadSchemas", type: LoadSchemasTask, dependsOn: ["mlClearSchemasDatabase", "mlLoadSchemas"], group: schemasGroup, description: "Clears schemas database then loads special-purpose data into the schemas database (XSD schemas, Inference rules, and [MarkLogic 9] Extraction Templates)") + project.task("mlReloadSchemas", dependsOn: ["mlClearSchemasDatabase", "mlLoadSchemas"], group: schemasGroup, description: "Clears schemas database then loads special-purpose data into the schemas database (XSD schemas, Inference rules, and [MarkLogic 9] Extraction Templates)") String serverGroup = "ml-gradle Server" project.task("mlDeployServers", type: DeployServersTask, group: serverGroup, dependsOn: "mlPrepareRestApiDependencies", description: "Updates the REST API server (if it exists) and deploys each other server, updating it if it exists, in the configuration directory ") diff --git a/src/main/groovy/com/marklogic/gradle/task/schemas/LoadSchemasTask.groovy b/src/main/groovy/com/marklogic/gradle/task/schemas/LoadSchemasTask.groovy index ed59e1e11..501af8ca6 100644 --- a/src/main/groovy/com/marklogic/gradle/task/schemas/LoadSchemasTask.groovy +++ b/src/main/groovy/com/marklogic/gradle/task/schemas/LoadSchemasTask.groovy @@ -16,7 +16,7 @@ class LoadSchemasTask extends MarkLogicTask { // don't want to have to duplicate on this task AppDeployer d = getAppDeployer() if (d instanceof SimpleAppDeployer) { - command = d.getCommand("mlLoadSchemasCommands") + command = d.getCommand(LoadSchemasCommand) } if (command == null) { command = new LoadSchemasCommand()