Create Project Using Gradle

Before you begin

You need:

Procedure

  1. Create a directory for your Data Hub project. This directory will be referred to as "your project root" or simply "root".
  2. Open a command-line window, and go to your project root directory.
  3. In your project root directory, create a build.gradle file with the Grade Properties plugin setting and the Data Hub plugin setting.

    Copy the following to your build.gradle file and replace the com.marklogic.ml-data-hub version number with the Data Hub version that you are using.

       plugins {
          // Gradle Properties plugin
          id 'net.saliman.properties' version '1.4.6'
    
          // Data Hub plugin
          id 'com.marklogic.ml-data-hub' version 'VERSION_NUMBER'
      }
    
    net.saliman.properties Gradle Properties plugin Allows you to create different environments for your Gradle deployment and set up a gradle-env.properties file, where env is the environment name. When running a Gradle task, you can specify the target environment with the environmentName option. For more information, see https://github.com/stevesaliman/gradle-properties-plugin.
    com.marklogic.ml-data-hub Data Hub plugin Extends the ml-gradle plugin with Data Hub-specific commands.
  4. Initialize your Data Hub project.
    gradle hubInit -i

Results

An example result:

   ##############################
  # Your Data Hub Project is ready.
  ##############################

  - Set username and password
      There are several ways to do this. The easiest is to set mlUsername and mlPassword in gradle.properties.
      For other approaches see: https://github.com/marklogic/marklogic-data-hub/wiki/Password-Management

  - To deploy your application into MarkLogic...
      gradle mlDeploy    # this will bootstrap your application
      gradle mlLoadModules        # this will load your custom plugins into MarkLogic

  - Full list of gradle tasks:
      https://github.com/marklogic/marklogic-data-hub/wiki/Gradle-Tasks

  - Curious about the project structure?
      Look here: https://github.com/marklogic/marklogic-data-hub/wiki/Project-Directory-Structure

  BUILD SUCCESSFUL

  Total time: 1.932 secs

What to do next

  • Specify the username and password for the Data Hub plugin to use when communicating with MarkLogic Server. See Set the Security Credentials Using Gradle.
  • After the project is initialized, all project team members must use the Gradle wrapper in the initialized project to run Gradle tasks. This ensures that everyone uses the same version of Gradle.