【问题标题】:how to read content of a xqy file in gradle and pass it to a gradle task as a string value?如何在 gradle 中读取 xqy 文件的内容并将其作为字符串值传递给 gradle 任务?
【发布时间】:2021-06-20 07:32:04
【问题描述】:

我在 ml-gradle 项目中有一个路径为 a/b/sample.xqy 的 xqy 文件,该文件将自定义字典插入到数据库中。

我想将该 xquery 文件作为 gradle 任务的一部分运行。我可以通过提供字符串格式的代码来运行代码,但想通过文件运行。

请帮忙:

Gradle 任务:

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

【问题讨论】:

  • file('sample.xqy').text?

标签: marklogic ml-gradle


【解决方案1】:

正如 tim_yates 所建议的,也提到了here,你可以使用这样的东西:

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

任何输出都会打印到控制台:

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

HTH!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-07-18
    • 2017-06-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多