Skip to content

Commit be93279

Browse files
committed
Merge branch '2.x'
2 parents 45209b0 + 2854395 commit be93279

File tree

16 files changed

+551
-60
lines changed

16 files changed

+551
-60
lines changed

.gitignore

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,36 @@
1-
/bin
2-
/.classpath
3-
/build
4-
/.gradle
5-
/.nb-gradle
6-
/.settings
7-
/.project
8-
ml-gradle-all/build/
9-
ml-gradle-all/.gradle/
10-
ml-gradle-all/.classpath
11-
ml-gradle-all/.project
12-
ml-gradle-all/.settings/
13-
sample-project/rob/
14-
sample-project/data/export/
15-
disconnected-project/build/
16-
disconnected-project/.gradle/
17-
sample-project/local.gradle
18-
examples/disconnected-project/build/
19-
examples/disconnected-project/.gradle/
20-
examples/flexrep-project/.gradle/
21-
examples/sample-project/local.gradle
22-
examples/failover-project/.gradle/
23-
examples/mlcp-project/.gradle/
24-
examples/mlcp-project/build/
25-
examples/mlcp-project/data/export/
26-
examples/shell-project/.gradle/
27-
examples/shell-project/build/
28-
examples/shell-project/.gradle
29-
examples/shell-project/.settings
30-
examples/shell-project/.project
31-
examples/shell-project/.classpath
32-
examples/minimal-project/.gradle
33-
examples/ignore-resources-project/.gradle/
34-
.idea
35-
*.iml
1+
/bin
2+
/.classpath
3+
/build
4+
/.gradle
5+
/.nb-gradle
6+
/.settings
7+
/.project
8+
ml-gradle-all/build/
9+
ml-gradle-all/.gradle/
10+
ml-gradle-all/.classpath
11+
ml-gradle-all/.project
12+
ml-gradle-all/.settings/
13+
sample-project/rob/
14+
sample-project/data/export/
15+
disconnected-project/build/
16+
disconnected-project/.gradle/
17+
sample-project/local.gradle
18+
examples/disconnected-project/build/
19+
examples/disconnected-project/.gradle/
20+
examples/flexrep-project/.gradle/
21+
examples/sample-project/local.gradle
22+
examples/failover-project/.gradle/
23+
examples/mlcp-project/.gradle/
24+
examples/mlcp-project/build/
25+
examples/mlcp-project/data/export/
26+
examples/shell-project/.gradle/
27+
examples/shell-project/build/
28+
examples/shell-project/.gradle
29+
examples/shell-project/.settings
30+
examples/shell-project/.project
31+
examples/shell-project/.classpath
32+
examples/minimal-project/.gradle
33+
examples/ignore-resources-project/.gradle/
34+
.idea
35+
*.iml
36+
out

build.gradle

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ plugins {
1717
id "eclipse"
1818
id "idea"
1919
id "com.jfrog.bintray" version "1.6"
20+
id "com.github.jk1.dependency-license-report" version "0.3.11"
21+
id "com.gradle.plugin-publish" version "0.9.7"
2022
}
2123

2224
apply plugin: "com.gradle.plugin-publish"
@@ -37,6 +39,7 @@ dependencies {
3739
compile localGroovy()
3840
compile mlAppDeployerDependency
3941
compile mlcpUtilDependency
42+
compile group: 'commons-io', name: 'commons-io', version: '2.5'
4043
}
4144

4245
task sourcesJar(type: Jar, dependsOn: classes) {
@@ -87,11 +90,11 @@ pluginBundle {
8790
displayName = 'ml-gradle for MarkLogic'
8891
description = 'Gradle plugin for configuring and deploying applications to MarkLogic'
8992
tags = ['marklogic']
90-
version = "2.8.0"
93+
version = "2.9.0"
9194
}
9295
}
9396

9497
mavenCoordinates {
95-
version = "2.8.0"
98+
version = "2.9.0"
9699
}
97100
}

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.8.0
3+
mlGradleVersion=2.9.0
44

55
mlHost=localhost
66
mlAppName=example

examples/roxy-project/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/bin
2+
.classpath
3+
.project
4+
/build
5+
.gradle
6+
.settings
7+
src
8+
backup-*

examples/roxy-project/build.gradle

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
plugins {
2-
id "com.marklogic.ml-gradle" version "2.7.1"
1+
buildscript {
2+
repositories {
3+
mavenLocal()
4+
jcenter()
5+
}
6+
dependencies {
7+
classpath "com.marklogic:ml-gradle:2.9.0"
8+
}
39
}
410

5-
/**
6-
* ml-gradle defaults to a modules path of src/main/ml-modules. Roxy applications almost always store
7-
* asset modules under ./src, so we need to modify the module paths. Note that since Roxy stores REST API
8-
* extensions under ./ext, "gradle mlWatch" will not load these.
9-
*/
10-
ext {
11-
mlAppConfig {
12-
modulePaths = ["src"]
13-
}
11+
apply plugin: "com.marklogic.ml-gradle"
12+
13+
repositories {
14+
mavenLocal()
15+
jcenter()
1416
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#
2+
# Put your custom functions in this class in order to keep the files under lib untainted
3+
#
4+
# This class has access to all of the private variables in deploy/lib/server_config.rb
5+
#
6+
# any public method you create here can be called from the command line. See
7+
# the examples below for more information.
8+
#
9+
class ServerConfig
10+
11+
def hello_world()
12+
@logger.info "trying to run a custom query"
13+
r = execute_query %Q{
14+
xquery version "1.0-ml";
15+
("one", "two", "three") ! element span { . }
16+
},
17+
{
18+
:app_name => "#{@properties['ml.app-name']}"
19+
}
20+
JSON.parse(r.body).each do |item|
21+
output = item['result']
22+
@logger.info " " + output
23+
end
24+
end
25+
26+
def get_document_count()
27+
r = execute_query %Q{
28+
xdmp:estimate(fn:doc())
29+
}
30+
@logger.info(r.body)
31+
end
32+
33+
def delete_view()
34+
r = execute_query %Q{
35+
xquery version "1.0-ml";
36+
37+
import module namespace view = "http://marklogic.com/xdmp/view"
38+
at "/MarkLogic/views.xqy";
39+
40+
try {
41+
view:remove(
42+
"main",
43+
"Compliance"
44+
)
45+
} catch ($e) { () }
46+
(: Deletes a view, of the 'main' schema that contains columns, with a scope on the element, 'html'. :)
47+
},
48+
{ :db_name => @properties["ml.content-db"] }
49+
end
50+
51+
def create_view()
52+
r = execute_query %Q{
53+
xquery version "1.0-ml";
54+
55+
import module namespace view = "http://marklogic.com/xdmp/view"
56+
at "/MarkLogic/views.xqy";
57+
58+
try {
59+
view:schema-create(
60+
"main",
61+
()
62+
)
63+
} catch ($e) {()},
64+
view:create(
65+
"main",
66+
"Compliance",
67+
view:element-view-scope(fn:QName("http://www.w3.org/1999/xhtml","html")),
68+
( view:column("uri", cts:uri-reference()),
69+
view:column("entityName", cts:path-reference('/xhtml:html/xhtml:head/xhtml:meta[@name eq "entityName"]/@content',("collation=http://marklogic.com/collation/"))),
70+
view:column("entityStreetAddress", cts:path-reference('/xhtml:html/xhtml:head/xhtml:meta[@name eq "entityStreetAddress"]/@content',("collation=http://marklogic.com/collation/", ("nullable")))),
71+
view:column("entityCityAddress", cts:path-reference('/xhtml:html/xhtml:head/xhtml:meta[@name eq "entityCityAddress"]/@content',("collation=http://marklogic.com/collation/", ("nullable")))),
72+
view:column("entityCountryAddress", cts:path-reference('/xhtml:html/xhtml:head/xhtml:meta[@name eq "entityCountryAddress"]/@content',("collation=http://marklogic.com/collation//S2", ("nullable")))),
73+
view:column("foreignEntityStatus", cts:path-reference('/xhtml:html/xhtml:head/xhtml:meta[@name eq "foreignEntityStatus"]/@content',("collation=http://marklogic.com/collation/", ("nullable")))),
74+
view:column("intermediaryEntityStatus", cts:path-reference('/xhtml:html/xhtml:head/xhtml:meta[@name eq "intermediaryEntityStatus"]/@content',("collation=http://marklogic.com/collation/codepoint", ("nullable")))),
75+
view:column("EIN", cts:path-reference('/xhtml:html/xhtml:head/xhtml:meta[@name eq "EIN"]/@content',("collation=http://marklogic.com/collation/", ("nullable")))),
76+
view:column("docType", cts:path-reference('/xhtml:html/xhtml:head/xhtml:meta[@name eq "docType"]/@content',("collation=http://marklogic.com/collation//S1", ("nullable"))))
77+
),
78+
()
79+
)
80+
81+
(: Creates a view, of the 'main' schema that contains columns, with a scope on the element, 'html'. :)
82+
},
83+
{ :db_name => @properties["ml.content-db"] }
84+
end
85+
end

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
group=com.marklogic
2-
version=2.8.0
3-
mlAppDeployerDependency=com.marklogic:ml-app-deployer:2.8.0
2+
version=2.9.0
3+
mlAppDeployerDependency=com.marklogic:ml-app-deployer:2.9.0
44
mlcpUtilDependency=com.marklogic:mlcp-util:0.3.0
55

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ import com.marklogic.gradle.task.groups.SetTraceEventsTask
3333
import com.marklogic.gradle.task.mimetypes.DeployMimetypesTask
3434
import com.marklogic.gradle.task.qconsole.ExportWorkspacesTask
3535
import com.marklogic.gradle.task.qconsole.ImportWorkspacesTask
36+
import com.marklogic.gradle.task.roxy.RoxyMigrateBuildStepsTask
37+
import com.marklogic.gradle.task.roxy.RoxyMigrateFilesTask
38+
import com.marklogic.gradle.task.roxy.RoxyMigratePropertiesTask
3639
import com.marklogic.gradle.task.scaffold.GenerateScaffoldTask
3740
import com.marklogic.gradle.task.schemas.LoadSchemasTask
3841
import com.marklogic.gradle.task.security.*
@@ -80,7 +83,8 @@ class MarkLogicPlugin implements Plugin<Project> {
8083
String deployGroup = "ml-gradle Deploy"
8184
project.task("mlPostDeploy", group: deployGroup, description: "Add dependsOn to this task to add tasks at the end of mlDeploy").mustRunAfter(["mlDeployApp"])
8285
project.task("mlPostUndeploy", group: deployGroup, description: "Add dependsOn to this task to add tasks at the end of mlUndeploy").mustRunAfter(["mlUndeployApp"])
83-
project.task("mlDeploy", group: deployGroup, dependsOn: ["mlDeployApp", "mlPostDeploy"], description: "Deploys all application resources in the configuration directory and allows for additional steps via mlPostDeploy.dependsOn").mustRunAfter("mlClearModulesDatabase")
86+
project.task("mlDeploy", group: deployGroup, dependsOn: ["mlDeployApp", "mlPostDeploy"],
87+
description: "Deploys all application resources in the configuration directory and allows for additional steps via mlPostDeploy.dependsOn. Use -Pignore to specify a comma-delimited list of short class names of ml-app-deployer command classes to ignore while deploying.").mustRunAfter("mlClearModulesDatabase")
8488
project.task("mlUndeploy", group: deployGroup, dependsOn: ["mlUndeployApp", "mlPostUndeploy"], description: "Undeploys all application resources in the configuration directory and allows for additional steps via mlPostUndeploy.dependsOn")
8589
project.task("mlRedeploy", group: deployGroup, dependsOn: ["mlClearModulesDatabase", "mlDeploy"], description: "Clears the modules database and then deploys the application")
8690

@@ -207,6 +211,15 @@ class MarkLogicPlugin implements Plugin<Project> {
207211
String shellGroup = "ml-gradle Shell"
208212
project.task("mlShell", type: ShellTask, group: shellGroup, description: "Run groovysh with MarkLogic-specific support built in")
209213

214+
String roxyGroup = "ml-gradle Roxy";
215+
project.task("mlRoxyMigrateBuildSteps", type: RoxyMigrateBuildStepsTask, group: roxyGroup, description: "Migrate build steps from deploy/app_specific.rb into custom Gradle tasks. " +
216+
"Use -ProxyProjectPath to define the location of your Roxy project, and -PappSpecificPath to define a path other than deploy/app_specific.rb")
217+
project.task("mlRoxyMigrateFiles", type: RoxyMigrateFilesTask, group: roxyGroup, description: "Migrate Roxy source files into this Gradle project. " +
218+
"Use -ProxyProjectPath to define the location of your Roxy project.")
219+
project.task("mlRoxyMigrateProperties", type: RoxyMigratePropertiesTask, group: roxyGroup, description: "Migrate Roxy properties into the gradle.properties file in this project. " +
220+
"Use -ProxyProjectPath to define the location of your Roxy project.")
221+
project.task("mlRoxyMigrateProject", group: roxyGroup, description: "Run all tasks for migrating a Roxy project into this Gradle project. " +
222+
"Use -ProxyProjectPath to define the location of your Roxy project.", dependsOn: ["mlRoxyMigrateBuildSteps", "mlRoxyMigrateFiles", "mlRoxyMigrateProperties"])
210223
logger.info("Finished initializing ml-gradle\n")
211224
}
212225

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,34 @@
11
package com.marklogic.gradle.task
22

3+
import com.marklogic.appdeployer.impl.SimpleAppDeployer
34
import org.gradle.api.tasks.TaskAction
45

56
class DeployAppTask extends MarkLogicTask {
67

8+
/**
9+
* Use "-Pignore" to specify the short class names of ml-app-deployer commands to ignore. The commands are then
10+
* removed from the mlAppDeployer object, as long as it is an instance of SimpleAppDeployer from ml-app-deployer.
11+
*/
712
@TaskAction
813
void deployApp() {
9-
getAppDeployer().deploy(getAppConfig())
14+
def appDeployer = getAppDeployer()
15+
if (project.hasProperty("ignore")) {
16+
if (appDeployer instanceof SimpleAppDeployer) {
17+
String[] commandNames = project.property("ignore").split(",")
18+
SimpleAppDeployer deployer = (SimpleAppDeployer)appDeployer
19+
for (String commandName : commandNames) {
20+
def command = deployer.removeCommand(commandName)
21+
if (command != null) {
22+
println "Ignoring command: " + commandName
23+
} else {
24+
println "Could not find command specified by ignore property: " + commandName
25+
}
26+
}
27+
}
28+
else {
29+
println "ignore property defined, but mlAppDeployer is not an instance of SimpleAppDeployer, so not able to ignore commands"
30+
}
31+
}
32+
appDeployer.deploy(getAppConfig())
1033
}
1134
}

src/main/groovy/com/marklogic/gradle/task/MarkLogicTask.groovy

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ class MarkLogicTask extends DefaultTask {
4444
project.hasProperty("mlAdminPassword") ? project.property("mlAdminPassword") : project.property("mlPassword")
4545
}
4646

47-
DatabaseClient newClient() {
47+
DatabaseClient newClient() {
4848
getAppConfig().newDatabaseClient()
4949
}
50-
50+
5151
void deployWithCommandListProperty(String propertyName) {
5252
deployWithCommands(getProject().property(propertyName))
5353
}
@@ -57,7 +57,7 @@ class MarkLogicTask extends DefaultTask {
5757
deployer.setCommands(commands)
5858
deployer.deploy(getAppConfig())
5959
}
60-
60+
6161
void undeployWithCommandListProperty(String propertyName) {
6262
undeployWithCommands(getProject().property(propertyName))
6363
}
@@ -67,12 +67,12 @@ class MarkLogicTask extends DefaultTask {
6767
deployer.setCommands(commands)
6868
deployer.undeploy(getAppConfig())
6969
}
70-
70+
7171
void invokeDeployerCommandWithClassName(String className) {
7272
SimpleAppDeployer d = (SimpleAppDeployer)getAppDeployer()
7373
new SimpleAppDeployer(getManageClient(), getAdminManager(), d.getCommand(className)).deploy(getAppConfig())
7474
}
75-
75+
7676
void undeployWithCommandWithClassName(String className) {
7777
SimpleAppDeployer d = (SimpleAppDeployer)getAppDeployer()
7878
new SimpleAppDeployer(getManageClient(), getAdminManager(), d.getCommand(className)).undeploy(getAppConfig())

0 commit comments

Comments
 (0)