Using Gradle
- Last Updated: April 5, 2026
- 9 minute read
Create and Add a Step to a Flow Using Gradle
Before you begin
You need:
- Java SE JDK 8
- MarkLogic Server (See Version Compatibility.)
- Gradle 4.6 or later
About this task
A flow must have at least one step. You can create steps in two ways:
- By customizing the example steps. If you created your flow using Gradle, the resulting flow definition file includes an example step for each predefined type of step (ingestion, mapping, mastering). Simply customize these example steps.
- By creating and customizing a step definition using Gradle. Use the Gradle task
hubCreateStepDefinitionto initialize a step definition, copy the step definition to the flow definition, and customize.
This task describes how to create and customize a step definition using Gradle.
Ingestion
-
Using Gradle, create the step definition.
-
Open a command-line window, and go to your project root directory.
-
At your project root, run the Gradle task
hubCreateStepDefinitionwith the stepType asingestion.Unix systems
./gradlew hubCreateStepDefinition -PstepDefName=your-ingestion-step-name -PstepDefType=ingestion -iWindows
gradlew.bat hubCreateStepDefinition -PstepDefName=your-ingestion-step-name -PstepDefType=ingestion -iTo associate an XQuery module (instead of the default JavaScript module) with the step definition, add the option
-Pformat=xqy. This creates an XQuery sample module, which you can customize, and a JavaScript wrapper.Note: The default stepType is
custom.Result:
The following files are created:
- The step definition file:
your-project-root/step-definitions/ingestion/your-ingestion-step-name/your-ingestion-step-name.step.json- The custom module file:
your-project-root/src/main/ml-modules/root/custom-modules/ingestion/your-ingestion-step-def-name/main.sjsThe modulePath setting in the step definition points to the custom module file.
-
-
Manually add the step to the flow.
-
In a text editor, open the step definition file.
The custom ingestion step definition file contains the following:
{ "language" : "zxx", "name" : "your-ingestion-step-def-name", "description" : null, "type" : "INGESTION", "version" : 1, "options" : { "collections" : [ "your-ingestion-step-def-name" ], "outputFormat" : "json", "targetDatabase" : "data-hub-STAGING" }, "customHook" : { }, "modulePath" : "/custom-modules/ingestion/your-ingestion-step-def-name/main.sjs", "retryLimit" : 0, "batchSize" : 100, "threadCount" : 4, "fileLocations" : { "inputFilePath" : "", "outputURIReplacement" : "", "inputFileType" : "" } } -
Likewise, open the flow definition file.
You can find your flow definition file in
your-project-root/flows.The default flow definition file without any steps contains the following:
{ "name": "your-flow-name", "description": "", "batchSize": 100, "threadCount": 4, "options": { "sourceQuery": null }, "steps": {} } -
In the
stepsnode, add the step as a key-value pair.-
For the key, enter a string containing a number which represents the order of the step in the sequence.
Note: The steps can be listed in any order, as long as the keys are unique within the
stepsnode of the flow. Duplicate keys can produced unexpected results. The key number must be greater than 0. -
For the value, copy and paste the entire content of the step definition file.
-
-
Edit the step in the flow definition file.
-
Rename the name setting to stepDefinitionName.
-
Rename the type setting to stepDefinitionType.
-
Create a new name setting and assign it a name for the step.
-
(Optional) Delete the following settings:
- language
- version
- modulePath
The values for these settings are retrieved from the step definition.
-
After adding a default ingestion step to the default flow as the first step ("1"), the flow definition file looks as follows:
{ "name": "your-flow-name", "description": "", "batchSize": 100, "threadCount": 4, "options": { "sourceQuery": null }, "steps": { "1": { "name" : "your-step-name", "stepDefinitionName" : "your-ingestion-step-def-name", "description" : null, "stepDefinitionType" : "INGESTION", "options" : { "collections" : [ "your-ingestion-step-name" ], "outputFormat" : "json", "targetDatabase" : "data-hub-STAGING" }, "customHook" : { }, "retryLimit" : 0, "batchSize" : 100, "threadCount" : 4, "fileLocations" : { "inputFilePath" : "", "outputURIReplacement" : "", "inputFileType" : "" } } } } -
Mapping
-
Using Gradle, create the step definition.
- Open a command-line window, and go to your project root directory.
- At your project root, run the Gradle task
hubCreateStepDefinitionwith the stepType asmapping.
Unix systems
./gradlew hubCreateStepDefinition -PstepDefName=your-mapping-step-name -PstepDefType=mapping -iWindows
gradlew.bat hubCreateStepDefinition -PstepDefName=your-mapping-step-name -PstepDefType=mapping -iTo associate an XQuery module (instead of the default JavaScript module) with the step definition, add the option
-Pformat=xqy. This creates an XQuery sample module, which you can customize, and a JavaScript wrapper.Note: The default stepType is
custom.Result:
The following files are created:
- The step definition file:
your-project-root/step-definitions/mapping/your-mapping-step-name/your-mapping-step-name.step.json - The custom module file: The modulePath setting in the step definition points to the custom module file.
your-project-root/src/main/ml-modules/root/custom-modules/mapping/your-mapping-step-def-name/main.sjs
-
Manually add the step to the flow.
-
In a text editor, open the step definition file.
The custom ingestion step definition file contains the following:
{ "language" : "zxx", "name" : "your-ingestion-step-def-name", "description" : null, "type" : "INGESTION", "version" : 1, "options" : { "collections" : [ "your-ingestion-step-def-name" ], "outputFormat" : "json", "targetDatabase" : "data-hub-STAGING" }, "customHook" : { }, "modulePath" : "/custom-modules/ingestion/your-ingestion-step-def-name/main.sjs", "retryLimit" : 0, "batchSize" : 100, "threadCount" : 4, "fileLocations" : { "inputFilePath" : "", "outputURIReplacement" : "", "inputFileType" : "" } } -
Likewise, open the flow definition file.
You can find your flow definition file in
your-project-root/flows.The default flow definition file without any steps contains the following:
{ "name": "your-flow-name", "description": "", "batchSize": 100, "threadCount": 4, "options": { "sourceQuery": null }, "steps": {} } -
In the
stepsnode, add the step as a key-value pair.-
For the key, enter a string containing a number which represents the order of the step in the sequence.
Note: The steps can be listed in any order, as long as the keys are unique within the
stepsnode of the flow. Duplicate keys can produced unexpected results. The key number must be greater than 0. -
For the value, copy and paste the entire content of the step definition file.
-
-
Edit the step in the flow definition file.
-
Rename the name setting to stepDefinitionName.
-
Rename the type setting to stepDefinitionType.
-
Create a new name setting and assign it a name for the step.
-
(Optional) Delete the following settings:
- language
- version
- modulePath
The values for these settings are retrieved from the step definition.
-
After adding a default ingestion step to the default flow as the first step ("1"), the flow definition file looks as follows:
{ "name": "your-flow-name", "description": "", "batchSize": 100, "threadCount": 4, "options": { "sourceQuery": null }, "steps": { "1": { "name" : "your-step-name", "stepDefinitionName" : "your-ingestion-step-def-name", "description" : null, "stepDefinitionType" : "INGESTION", "options" : { "collections" : [ "your-ingestion-step-name" ], "outputFormat" : "json", "targetDatabase" : "data-hub-STAGING" }, "customHook" : { }, "retryLimit" : 0, "batchSize" : 100, "threadCount" : 4, "fileLocations" : { "inputFilePath" : "", "outputURIReplacement" : "", "inputFileType" : "" } } } } -
Mastering
-
Using Gradle, create the step definition.
-
Open a command-line window, and go to your project root directory.
-
At your project root, run the Gradle task
hubCreateStepDefinitionwith the stepType asmastering.Unix systems
./gradlew hubCreateStepDefinition -PstepDefName=your-mastering-step-name -PstepDefType=mastering -iWindows
gradlew.bat hubCreateStepDefinition -PstepDefName=your-mastering-step-name -PstepDefType=mastering -iTo associate an XQuery module (instead of the default JavaScript module) with the step definition, add the option
-Pformat=xqy. This creates an XQuery sample module, which you can customize, and a JavaScript wrapper.Note: The default stepType is
custom.Result:
The following files are created:
- The step definition file:
your-project-root/step-definitions/mastering/your-mastering-step-name/your-mastering-step-name.step.json - The custom module file
your-project-root/src/main/ml-modules/root/custom-modules/mastering/your-mastering-step-def-name/main.sjs
The modulePath setting in the step definition points to the custom module file.
- The step definition file:
-
-
Manually add the step to the flow.
-
In a text editor, open the step definition file.
The custom ingestion step definition file contains the following:
{ "language" : "zxx", "name" : "your-ingestion-step-def-name", "description" : null, "type" : "INGESTION", "version" : 1, "options" : { "collections" : [ "your-ingestion-step-def-name" ], "outputFormat" : "json", "targetDatabase" : "data-hub-STAGING" }, "customHook" : { }, "modulePath" : "/custom-modules/ingestion/your-ingestion-step-def-name/main.sjs", "retryLimit" : 0, "batchSize" : 100, "threadCount" : 4, "fileLocations" : { "inputFilePath" : "", "outputURIReplacement" : "", "inputFileType" : "" } } -
Likewise, open the flow definition file.
You can find your flow definition file in
your-project-root/flows.The default flow definition file without any steps contains the following:
{ "name": "your-flow-name", "description": "", "batchSize": 100, "threadCount": 4, "options": { "sourceQuery": null }, "steps": {} } -
In the
stepsnode, add the step as a key-value pair.-
For the key, enter a string containing a number which represents the order of the step in the sequence.
Note: The steps can be listed in any order, as long as the keys are unique within the
stepsnode of the flow. Duplicate keys can produced unexpected results. The key number must be greater than 0. -
For the value, copy and paste the entire content of the step definition file.
-
-
Edit the step in the flow definition file.
-
Rename the name setting to stepDefinitionName.
-
Rename the type setting to stepDefinitionType.
-
Create a new name setting and assign it a name for the step.
-
(Optional) Delete the following settings:
- language
- version
- modulePath
The values for these settings are retrieved from the step definition.
-
After adding a default ingestion step to the default flow as the first step ("1"), the flow definition file looks as follows:
{ "name": "your-flow-name", "description": "", "batchSize": 100, "threadCount": 4, "options": { "sourceQuery": null }, "steps": { "1": { "name" : "your-step-name", "stepDefinitionName" : "your-ingestion-step-def-name", "description" : null, "stepDefinitionType" : "INGESTION", "options" : { "collections" : [ "your-ingestion-step-name" ], "outputFormat" : "json", "targetDatabase" : "data-hub-STAGING" }, "customHook" : { }, "retryLimit" : 0, "batchSize" : 100, "threadCount" : 4, "fileLocations" : { "inputFilePath" : "", "outputURIReplacement" : "", "inputFileType" : "" } } } } -
Custom
-
Using Gradle, create the step definition.
-
Open a command-line window, and go to your project root directory.
-
At your project root, run the Gradle task
hubCreateStepDefinitionwith the stepType ascustom.Unix systems
./gradlew hubCreateStepDefinition -PstepDefName=your-custom-step-name -PstepDefType=custom -iWindows
gradlew.bat hubCreateStepDefinition -PstepDefName=your-custom-step-name -PstepDefType=custom -iTo associate an XQuery module (instead of the default JavaScript module) with the step definition, add the option
-Pformat=xqy. This creates an XQuery sample module, which you can customize, and a JavaScript wrapper.Note: The default stepType is
custom.Result:
The following files are created:
-
The step definition file
your-project-root/step-definitions/custom/your-custom-step-name/your-custom-step-name.step.json -
The custom module file
your-project-root/src/main/ml-modules/root/custom-modules/custom/your-custom-step-def-name/main.sjs
The modulePath setting in the step definition points to the custom module file.
-
-
-
Manually add the step to the flow.
-
In a text editor, open the step definition file.
The custom ingestion step definition file contains the following:
{ "language" : "zxx", "name" : "your-ingestion-step-def-name", "description" : null, "type" : "INGESTION", "version" : 1, "options" : { "collections" : [ "your-ingestion-step-def-name" ], "outputFormat" : "json", "targetDatabase" : "data-hub-STAGING" }, "customHook" : { }, "modulePath" : "/custom-modules/ingestion/your-ingestion-step-def-name/main.sjs", "retryLimit" : 0, "batchSize" : 100, "threadCount" : 4, "fileLocations" : { "inputFilePath" : "", "outputURIReplacement" : "", "inputFileType" : "" } } -
Likewise, open the flow definition file.
You can find your flow definition file in
your-project-root/flows.The default flow definition file without any steps contains the following:
{ "name": "your-flow-name", "description": "", "batchSize": 100, "threadCount": 4, "options": { "sourceQuery": null }, "steps": {} } -
In the
stepsnode, add the step as a key-value pair.-
For the key, enter a string containing a number which represents the order of the step in the sequence.
Note: The steps can be listed in any order, as long as the keys are unique within the
stepsnode of the flow. Duplicate keys can produced unexpected results. The key number must be greater than 0. -
For the value, copy and paste the entire content of the step definition file.
-
-
Edit the step in the flow definition file.
-
Rename the name setting to stepDefinitionName.
-
Rename the type setting to stepDefinitionType.
-
Create a new name setting and assign it a name for the step.
-
(Optional) Delete the following settings:
- language
- version
- modulePath
The values for these settings are retrieved from the step definition.
-
After adding a default ingestion step to the default flow as the first step ("1"), the flow definition file looks as follows:
{ "name": "your-flow-name", "description": "", "batchSize": 100, "threadCount": 4, "options": { "sourceQuery": null }, "steps": { "1": { "name" : "your-step-name", "stepDefinitionName" : "your-ingestion-step-def-name", "description" : null, "stepDefinitionType" : "INGESTION", "options" : { "collections" : [ "your-ingestion-step-name" ], "outputFormat" : "json", "targetDatabase" : "data-hub-STAGING" }, "customHook" : { }, "retryLimit" : 0, "batchSize" : 100, "threadCount" : 4, "fileLocations" : { "inputFilePath" : "", "outputURIReplacement" : "", "inputFileType" : "" } } } } -
What to do next
- Modify your custom module.
- (Optional) To perform other tasks outside the Data Hub space, you can create a custom hook module and add it to a custom hook in the step.
See Also
Previous topic: Create a Flow Using Gradle
Next topic: Run a Flow Using Gradle
Related concepts
Related tasks
Related reference