我在使用ml与corb2 2.4.5和MarkLogic9.0.5。
在运行gradle任务时,我试图向corb传递一个参数。我已经把参数传递给
-DURIS-MODULE.id="sf"
在我的xquery模块中,我
declare variable $id as xs:string external;
corb进程运行,但它不设置id变量。我需要改变什么才能做到这一点?
发布于 2020-03-12 13:28:11
在执行ml任务时,应该设置所有系统属性并将其传递给您的CoRB作业。
我怀疑您可能正在运行旧版本的ml,或者您的工作中可能有其他问题。
通过执行以下命令,我已经验证了可以将外部URIS模块变量传递给这个简化的作业:
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=2ml级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
}发布于 2020-06-12 10:36:36
确保使用CorbTask类型,而不是使用Java任务来利用参数处理。
使用:
task some-corbCorbTask(type: com.marklogic.gradle.task.CorbTask) {...}而不是:
task some-corbJAVA(type: Java) {...}https://stackoverflow.com/questions/60646607
复制相似问题