I'm using ml-gradle with corb2 2.4.5 and Marklogic 9.0.5.
I'm trying to pass a parameter to corb when running the gradle task. I've passed the parameter in at
-DURIS-MODULE.id="sf"
In my xquery module, I have
declare variable $id as xs:string external;
The corb process runs, but it doesn't set the id variable. What do I need to change to make this work?
All system properties should be set and passed to your CoRB job when executing the ml-gradle CoRB task.
I suspect that you might be running an old version of ml-gradle, or there may be something else that is off in your job.
I have verified that I can pass in an external URIS-MODULE variable to this simplified job by executing the following command:
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
and I see that my application servers error log includes the line:
2020-03-12 09:23:44.198 Info: process module id=2
The ml-gradle CoRB task collects all system properties and passes them to CoRB when the task runs:
Map options = buildCorbOptions()
//CoRB2 will evaluate System properties for options
systemProperties(options)
super.exec()
The buildCorbOptions()
method
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
}
invokes the collectSystemProperties()
method:
/**
* 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
}