ravvi
ravvi

Reputation: 137

how to read content of a xqy file in gradle and pass it to a gradle task as a string value?

I have a xqy file with path a/b/sample.xqy in ml-gradle project which is inserting a custom dictionary in to the DB.

I want to run that xquery file as part of a gradle task. I am able to run the code by providing the code in string format but wanted to run through a file.

Please help:

Gradle task:

task Task1(type: com.marklogic.gradle.task.ServerEvalTask) {
    
    xquery = <how to run the sample.xqy here>
}

Upvotes: 1

Views: 179

Answers (1)

grtjn
grtjn

Reputation: 20414

As suggested by tim_yates, and also mentioned here, you can use something like this:

task Task1(type: com.marklogic.gradle.task.ServerEvalTask) {
    String fileContents = new File('oneplusone.xqy').getText('UTF-8')
    xquery = fileContents
}

Any output is printed to console:

> Task :Task1
Task ':Task1' is not up-to-date because:
  Task has not declared any outputs despite executing actions.
2
Releasing connection

HTH!

Upvotes: 0

Related Questions