Gradleの使用
- Last Updated: April 5, 2026
- 4 minute read
Gradleを使用してプロジェクトを作成する
開始する前に
以下が必要です。
- Java SE JDK 8以降
- MarkLogic 9.0-7以降
- Gradle 4.6以降
手順
- Gradleラッパーをインストールします。
gradle wrapper --gradle-version 4.6
-
データハブプロジェクトのディレクトリを作成します。このディレクトリは、「プロジェクトルート」または単に「ルート」と呼ばれています。
-
コマンドラインウィンドウを開き、プロジェクトのルートディレクトリに移動します。
-
プロジェクトのルートディレクトリで、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' }
<table class="table-light-border">
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プラグインを拡張します。
-
データハブプロジェクトを初期化します。
Unixシステム
./gradlew hubInit
**Windows**
gradlew.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を使用してセキュリティ資格情報を設定する」を参照してください。
See Also
親トピック:プロジェクト
次のトピック:Gradleによるセキュリティ資格情報の設定
関連リファレンス