-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
551 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,36 @@ | ||
/bin | ||
/.classpath | ||
/build | ||
/.gradle | ||
/.nb-gradle | ||
/.settings | ||
/.project | ||
ml-gradle-all/build/ | ||
ml-gradle-all/.gradle/ | ||
ml-gradle-all/.classpath | ||
ml-gradle-all/.project | ||
ml-gradle-all/.settings/ | ||
sample-project/rob/ | ||
sample-project/data/export/ | ||
disconnected-project/build/ | ||
disconnected-project/.gradle/ | ||
sample-project/local.gradle | ||
examples/disconnected-project/build/ | ||
examples/disconnected-project/.gradle/ | ||
examples/flexrep-project/.gradle/ | ||
examples/sample-project/local.gradle | ||
examples/failover-project/.gradle/ | ||
examples/mlcp-project/.gradle/ | ||
examples/mlcp-project/build/ | ||
examples/mlcp-project/data/export/ | ||
examples/shell-project/.gradle/ | ||
examples/shell-project/build/ | ||
examples/shell-project/.gradle | ||
examples/shell-project/.settings | ||
examples/shell-project/.project | ||
examples/shell-project/.classpath | ||
examples/minimal-project/.gradle | ||
examples/ignore-resources-project/.gradle/ | ||
.idea | ||
*.iml | ||
/bin | ||
/.classpath | ||
/build | ||
/.gradle | ||
/.nb-gradle | ||
/.settings | ||
/.project | ||
ml-gradle-all/build/ | ||
ml-gradle-all/.gradle/ | ||
ml-gradle-all/.classpath | ||
ml-gradle-all/.project | ||
ml-gradle-all/.settings/ | ||
sample-project/rob/ | ||
sample-project/data/export/ | ||
disconnected-project/build/ | ||
disconnected-project/.gradle/ | ||
sample-project/local.gradle | ||
examples/disconnected-project/build/ | ||
examples/disconnected-project/.gradle/ | ||
examples/flexrep-project/.gradle/ | ||
examples/sample-project/local.gradle | ||
examples/failover-project/.gradle/ | ||
examples/mlcp-project/.gradle/ | ||
examples/mlcp-project/build/ | ||
examples/mlcp-project/data/export/ | ||
examples/shell-project/.gradle/ | ||
examples/shell-project/build/ | ||
examples/shell-project/.gradle | ||
examples/shell-project/.settings | ||
examples/shell-project/.project | ||
examples/shell-project/.classpath | ||
examples/minimal-project/.gradle | ||
examples/ignore-resources-project/.gradle/ | ||
.idea | ||
*.iml | ||
out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/bin | ||
.classpath | ||
.project | ||
/build | ||
.gradle | ||
.settings | ||
src | ||
backup-* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
plugins { | ||
id "com.marklogic.ml-gradle" version "2.7.1" | ||
buildscript { | ||
repositories { | ||
mavenLocal() | ||
jcenter() | ||
} | ||
dependencies { | ||
classpath "com.marklogic:ml-gradle:2.9.0" | ||
} | ||
} | ||
|
||
/** | ||
* ml-gradle defaults to a modules path of src/main/ml-modules. Roxy applications almost always store | ||
* asset modules under ./src, so we need to modify the module paths. Note that since Roxy stores REST API | ||
* extensions under ./ext, "gradle mlWatch" will not load these. | ||
*/ | ||
ext { | ||
mlAppConfig { | ||
modulePaths = ["src"] | ||
} | ||
apply plugin: "com.marklogic.ml-gradle" | ||
|
||
repositories { | ||
mavenLocal() | ||
jcenter() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
# | ||
# Put your custom functions in this class in order to keep the files under lib untainted | ||
# | ||
# This class has access to all of the private variables in deploy/lib/server_config.rb | ||
# | ||
# any public method you create here can be called from the command line. See | ||
# the examples below for more information. | ||
# | ||
class ServerConfig | ||
|
||
def hello_world() | ||
@logger.info "trying to run a custom query" | ||
r = execute_query %Q{ | ||
xquery version "1.0-ml"; | ||
("one", "two", "three") ! element span { . } | ||
}, | ||
{ | ||
:app_name => "#{@properties['ml.app-name']}" | ||
} | ||
JSON.parse(r.body).each do |item| | ||
output = item['result'] | ||
@logger.info " " + output | ||
end | ||
end | ||
|
||
def get_document_count() | ||
r = execute_query %Q{ | ||
xdmp:estimate(fn:doc()) | ||
} | ||
@logger.info(r.body) | ||
end | ||
|
||
def delete_view() | ||
r = execute_query %Q{ | ||
xquery version "1.0-ml"; | ||
import module namespace view = "http://marklogic.com/xdmp/view" | ||
at "/MarkLogic/views.xqy"; | ||
try { | ||
view:remove( | ||
"main", | ||
"Compliance" | ||
) | ||
} catch ($e) { () } | ||
(: Deletes a view, of the 'main' schema that contains columns, with a scope on the element, 'html'. :) | ||
}, | ||
{ :db_name => @properties["ml.content-db"] } | ||
end | ||
|
||
def create_view() | ||
r = execute_query %Q{ | ||
xquery version "1.0-ml"; | ||
import module namespace view = "http://marklogic.com/xdmp/view" | ||
at "/MarkLogic/views.xqy"; | ||
try { | ||
view:schema-create( | ||
"main", | ||
() | ||
) | ||
} catch ($e) {()}, | ||
view:create( | ||
"main", | ||
"Compliance", | ||
view:element-view-scope(fn:QName("http://www.w3.org/1999/xhtml","html")), | ||
( view:column("uri", cts:uri-reference()), | ||
view:column("entityName", cts:path-reference('/xhtml:html/xhtml:head/xhtml:meta[@name eq "entityName"]/@content',("collation=http://marklogic.com/collation/"))), | ||
view:column("entityStreetAddress", cts:path-reference('/xhtml:html/xhtml:head/xhtml:meta[@name eq "entityStreetAddress"]/@content',("collation=http://marklogic.com/collation/", ("nullable")))), | ||
view:column("entityCityAddress", cts:path-reference('/xhtml:html/xhtml:head/xhtml:meta[@name eq "entityCityAddress"]/@content',("collation=http://marklogic.com/collation/", ("nullable")))), | ||
view:column("entityCountryAddress", cts:path-reference('/xhtml:html/xhtml:head/xhtml:meta[@name eq "entityCountryAddress"]/@content',("collation=http://marklogic.com/collation//S2", ("nullable")))), | ||
view:column("foreignEntityStatus", cts:path-reference('/xhtml:html/xhtml:head/xhtml:meta[@name eq "foreignEntityStatus"]/@content',("collation=http://marklogic.com/collation/", ("nullable")))), | ||
view:column("intermediaryEntityStatus", cts:path-reference('/xhtml:html/xhtml:head/xhtml:meta[@name eq "intermediaryEntityStatus"]/@content',("collation=http://marklogic.com/collation/codepoint", ("nullable")))), | ||
view:column("EIN", cts:path-reference('/xhtml:html/xhtml:head/xhtml:meta[@name eq "EIN"]/@content',("collation=http://marklogic.com/collation/", ("nullable")))), | ||
view:column("docType", cts:path-reference('/xhtml:html/xhtml:head/xhtml:meta[@name eq "docType"]/@content',("collation=http://marklogic.com/collation//S1", ("nullable")))) | ||
), | ||
() | ||
) | ||
(: Creates a view, of the 'main' schema that contains columns, with a scope on the element, 'html'. :) | ||
}, | ||
{ :db_name => @properties["ml.content-db"] } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
group=com.marklogic | ||
version=2.8.0 | ||
mlAppDeployerDependency=com.marklogic:ml-app-deployer:2.8.0 | ||
version=2.9.0 | ||
mlAppDeployerDependency=com.marklogic:ml-app-deployer:2.9.0 | ||
mlcpUtilDependency=com.marklogic:mlcp-util:0.3.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 24 additions & 1 deletion
25
src/main/groovy/com/marklogic/gradle/task/DeployAppTask.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,34 @@ | ||
package com.marklogic.gradle.task | ||
|
||
import com.marklogic.appdeployer.impl.SimpleAppDeployer | ||
import org.gradle.api.tasks.TaskAction | ||
|
||
class DeployAppTask extends MarkLogicTask { | ||
|
||
/** | ||
* Use "-Pignore" to specify the short class names of ml-app-deployer commands to ignore. The commands are then | ||
* removed from the mlAppDeployer object, as long as it is an instance of SimpleAppDeployer from ml-app-deployer. | ||
*/ | ||
@TaskAction | ||
void deployApp() { | ||
getAppDeployer().deploy(getAppConfig()) | ||
def appDeployer = getAppDeployer() | ||
if (project.hasProperty("ignore")) { | ||
if (appDeployer instanceof SimpleAppDeployer) { | ||
String[] commandNames = project.property("ignore").split(",") | ||
SimpleAppDeployer deployer = (SimpleAppDeployer)appDeployer | ||
for (String commandName : commandNames) { | ||
def command = deployer.removeCommand(commandName) | ||
if (command != null) { | ||
println "Ignoring command: " + commandName | ||
} else { | ||
println "Could not find command specified by ignore property: " + commandName | ||
} | ||
} | ||
} | ||
else { | ||
println "ignore property defined, but mlAppDeployer is not an instance of SimpleAppDeployer, so not able to ignore commands" | ||
} | ||
} | ||
appDeployer.deploy(getAppConfig()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/groovy/com/marklogic/gradle/task/ServerEvalTask.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.marklogic.gradle.task | ||
|
||
import com.marklogic.client.DatabaseClient | ||
import org.gradle.api.tasks.TaskAction | ||
|
||
class ServerEvalTask extends MarkLogicTask { | ||
|
||
String xquery | ||
String javascript | ||
|
||
@TaskAction | ||
void serverEval() { | ||
DatabaseClient client = newClient() | ||
try { | ||
String result | ||
if (xquery != null) { | ||
result = client.newServerEval().xquery(xquery).evalAs(String.class) | ||
} else { | ||
result = client.newServerEval().javascript(javascript).evalAs(String.class) | ||
} | ||
if (result != null) { | ||
println result | ||
} | ||
} finally { | ||
client.release() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.