使用 ml-gradle 将参数传递给 corb uri 阶段
Passing parameters to corb uri stage using ml-gradle
我将 ml-gradle 与 corb2 2.4.5 和 Marklogic 9.0.5 一起使用。
我正在尝试在 运行 gradle 任务时将参数传递给 corb。我已经在
处传递了参数
-DURIS-MODULE.id="sf"
在我的 xquery 模块中,我有
declare variable $id as xs:string external;
corb 进程运行,但未设置 id 变量。我需要更改什么才能使这项工作正常进行?
执行 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:
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
}
请务必使用类型 CorbTask
,而不是 Java 任务,以利用参数处理。
使用:
task some-corbCorbTask(type: com.marklogic.gradle.task.CorbTask) {...}
而不是:
task some-corbJAVA(type: Java) {...}
我将 ml-gradle 与 corb2 2.4.5 和 Marklogic 9.0.5 一起使用。
我正在尝试在 运行 gradle 任务时将参数传递给 corb。我已经在
处传递了参数-DURIS-MODULE.id="sf"
在我的 xquery 模块中,我有
declare variable $id as xs:string external;
corb 进程运行,但未设置 id 变量。我需要更改什么才能使这项工作正常进行?
执行 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:
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
}
请务必使用类型 CorbTask
,而不是 Java 任务,以利用参数处理。
使用:
task some-corbCorbTask(type: com.marklogic.gradle.task.CorbTask) {...}
而不是:
task some-corbJAVA(type: Java) {...}