Gradleを使用してプロジェクトを作成する

開始する前に

以下が必要です。

手順

  1. Gradleラッパーをインストールします。
    gradle wrapper --gradle-version 4.6
  2. データハブプロジェクトのディレクトリを作成します。このディレクトリは、「プロジェクトルート」または単に「ルート」と呼ばれています。
  3. コマンドラインウィンドウを開き、プロジェクトのルートディレクトリに移動します。
  4. プロジェクトのルートディレクトリで、Gradeのプロパティプラグイン設定とデータハブプラグイン設定を使用して、build.gradleファイルを作成します。

    以下をbuild.gradleファイルにコピーし、com.marklogic.ml-data-hubのバージョン番号を、使用しているデータハブのバージョンに置き換えます。

    plugins { // Gradle Properties plugin id 'net.saliman.properties' version '1.4.6' // Data Hub plugin id 'com.marklogic.ml-data-hub' version '5.0.0' }
    net.saliman.properties Gradleプロパティプラグイン Gradle導入用に別環境を作成し、gradle-{env}.propertiesファイルをセットアップできます。この{env}は環境名です。Gradleタスクを実行する場合は、environmentNameオプションを使用してターゲット環境を指定できます。詳細については、https://github.com/stevesaliman/gradle-properties-pluginを参照してください。
    com.marklogic.ml-data-hub データハブプラグイン データハブ固有のコマンドを使用して、ml-gradleプラグインを拡張します。
  5. データハブプロジェクトを初期化します。
    ./gradlew hubInitgradlew.bat hubInit

結果

結果の例:

############################## # 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

次に行う手順

MarkLogicサーバーと通信する際に使用するデータハブプラグインのユーザー名とパスワードを指定します。「Gradleを使用してセキュリティ資格情報を設定する」を参照してください。