Skip to content

Commit 1c28dbe

Browse files
committed
#94 Adding support for WorkspaceManager
1 parent 3ca2872 commit 1c28dbe

File tree

6 files changed

+59
-2
lines changed

6 files changed

+59
-2
lines changed

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ dependencies {
3232
compile localGroovy()
3333
compile mlAppDeployerDependency
3434
compile mlcpUtilDependency
35+
compile "com.marklogic:ml-javaclient-util:2.10.0-alpha"
3536
}
3637

3738
task sourcesJar(type: Jar, dependsOn: classes) {

examples/local-testing-project/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Set this to the version you used when running
22
# "gradle -Pversion=(something) publishToMavenLocal" on your local ml-gradle repo
3-
mlGradleVersion=2.3.4
3+
mlGradleVersion=2.4.0-dev
44

55
mlHost=localhost
66
mlAppName=example

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
group=com.marklogic
2-
version=2.3.4
2+
version=2.4.0-dev
33
mlAppDeployerDependency=com.marklogic:ml-app-deployer:2.3.1
44
mlcpUtilDependency=com.marklogic:mlcp-util:0.3.0
55

src/main/groovy/com/marklogic/gradle/MarkLogicPlugin.groovy

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ package com.marklogic.gradle
33
import com.marklogic.appdeployer.command.databases.DeployOtherDatabasesCommand
44
import com.marklogic.appdeployer.command.forests.DeployCustomForestsCommand
55
import com.marklogic.gradle.task.forests.DeployCustomForestsTask
6+
import com.marklogic.gradle.task.qconsole.ExportWorkspacesTask
7+
import com.marklogic.gradle.task.qconsole.ImportWorkspacesTask
68
import com.sun.jersey.core.spi.component.ProviderServices
79
import org.gradle.api.Plugin
810
import org.gradle.api.Project
@@ -206,6 +208,10 @@ class MarkLogicPlugin implements Plugin<Project> {
206208
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")
207209
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")
208210

211+
String qconsoleGroup = "ml-gradle qconsole"
212+
project.task("mlImportWorkspaces", type: ImportWorkspacesTask, group: qconsoleGroup, description: "Import workspaces into qconsole")
213+
project.task("mlExportWorkspaces", type: ExportWorkspacesTask, group: qconsoleGroup, description: "Export workspaces from qconsole")
214+
209215
String schemasGroup = "ml-gradle Schemas"
210216
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)").mustRunAfter("mlClearSchemasDatabase")
211217
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)")
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.marklogic.gradle.task.qconsole
2+
3+
import com.marklogic.client.DatabaseClient
4+
import com.marklogic.client.qconsole.impl.DefaultWorkspaceManager
5+
import com.marklogic.gradle.task.MarkLogicTask
6+
import org.gradle.api.tasks.TaskAction
7+
8+
class ExportWorkspacesTask extends MarkLogicTask {
9+
10+
@TaskAction
11+
void exportWorkspaces() {
12+
DatabaseClient client = newClient()
13+
try {
14+
String user = project.property("user")
15+
String workspaceNames = project.property("workspaceNames")
16+
DefaultWorkspaceManager mgr = new DefaultWorkspaceManager(client);
17+
def files = mgr.exportWorkspaces(user, workspaceNames.split(","))
18+
for (f in files) {
19+
println "Exported workspace to " + f
20+
}
21+
} finally {
22+
client.release()
23+
}
24+
}
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.marklogic.gradle.task.qconsole
2+
3+
import com.marklogic.client.DatabaseClient
4+
import com.marklogic.client.qconsole.impl.DefaultWorkspaceManager
5+
import com.marklogic.gradle.task.MarkLogicTask
6+
import org.gradle.api.tasks.TaskAction
7+
8+
class ImportWorkspacesTask extends MarkLogicTask {
9+
10+
@TaskAction
11+
void importWorkspaces() {
12+
DatabaseClient client = newClient()
13+
try {
14+
String user = project.property("user")
15+
String workspaceNames = project.property("workspaceNames")
16+
DefaultWorkspaceManager mgr = new DefaultWorkspaceManager(client);
17+
def files = mgr.importWorkspaces(user, workspaceNames.split(","))
18+
for (f in files) {
19+
println "Imported workspace from " + f
20+
}
21+
} finally {
22+
client.release()
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)