使用ml-gradle将参数传递到corb uri阶段

问题描述 投票:1回答:1

我正在使用带有corb2 2.4.5和Marklogic 9.0.5的ml-gradle。

我正在尝试运行gradle任务时将参数传递给corb。我已经在

中传递了参数

-DURIS-MODULE.id="sf"

在我的xquery模块中,我有

declare variable $id as xs:string external;

corb进程运行,但未设置id变量。要进行这项工作,我需要更改什么?

marklogic ml-gradle marklogic-corb
1个回答
1
投票

执行ml-gradle CoRB任务时,应设置所有系统属性并将其传递给您的CoRB作业。

我怀疑您可能正在运行旧版本的ml-gradle,或者您的工作中还有其他问题。

我已验证可以通过执行以下命令将外部URIS-MODULE变量传递给此简化的作业:

gradle -DURIS-MODULE.id=2 -DURIS-MODULE="INLINE-XQUERY|declare variable $id external;concat('PROCESS-MODULE.id=',string($id)),1,1|ADHOC" -DPROCESS-MODULE="INLINE-XQUERY|declare variable $id external;xdmp:log(concat('process module id=',$id))|ADHOC" corb

并且我看到我的应用程序服务器错误日志包括以下行:

2020-03-12 09:23:44.198 Info: process module id=2

ml-gradle CoRB任务收集所有系统属性,并在任务运行时将它们传递给CoRB:

https://github.com/marklogic-community/ml-gradle/blob/master/src/main/groovy/com/marklogic/gradle/task/CorbTask.groovy#L102

Map options = buildCorbOptions()
//CoRB2 will evaluate System properties for options
systemProperties(options)

super.exec()

buildCorbOptions()方法https://github.com/marklogic-community/ml-gradle/blob/master/src/main/groovy/com/marklogic/gradle/task/CorbTask.groovy#L121

  /**
  * Construct CoRB2 options from the following sources:
  * task variables - lowerCamelCase names that correspond to their CoRB2
  *                  option (i.e. optionsFile => OPTIONS-FILE)
  * project properties - Project properties with the naming convention
  *                      of a 'corb' prefix and CamelCased CoRB2 option name
  *                      (i.e. corbOptionsFile => OPTIONS-FILE)
  * System properties - Any System property with a CoRB2 option name
  *
  * If properties are defined in more than one place, System properties will take
  * precedence over Project properties, which take precedence over task member variables.
  *
  * @return Map of CoRB2 options
  */
  public Map buildCorbOptions() {
    //first, convert legacy task properties and generate options from conventions
    Map options = collectNormalizedOptions()
    //collect all of the corb task options (i.e. threadCount=12)
    options << collectMemberVariables()
    //apply any corb project properties (i.e. -PcorbThreadCount=12)
    options << collectCorbProjectProperties()
    //apply any CoRB2 System properties (i.e. -DTHREAD-COUNT=12)
    options << collectSystemProperties()
    options //return the merged options
  }

调用collectSystemProperties()方法:

  /**
  * Collect all System.properties. This allows for any CoRB option to be set, including those not statically known such
  * as CoRB custom inputs (e.g. URIS-MODULE.foo, PROCESS-MODULE.bar, etc) as well as settings for other libraries, such
  * as xcc.httpCompliant to enable XCCS compatability for XCC.
  * @return all System.properties
  */
  public Map collectSystemProperties() {
    System.properties
  }
© www.soinside.com 2019 - 2024. All rights reserved.