Red Hat Training
A Red Hat training course is available for Red Hat Decision Manager
第3章 関連ツールのインストール
3.1. プロジェクトでの Maven リポジトリーの使用
Red Hat Decision Manager は、Red Hat Decision Manager Maven リポジトリーと共に使用するように作られています。以下の方法のいずれかを用いて、ご自分のプロジェクトで Maven が Red Hat Decision Manager Maven リポジトリーを使用するように設定できます。
- プロジェクトオブジェクトモデル (POM) ファイル (pom.xml) を設定する。
-
Maven
settings.xml
ファイルを修正する。このファイルは、Red Hat カスタマーポータル からダウンロード可能な Maven リポジトリーに含まれています。
Red Hat では、Maven グローバル設定またはユーザー設定を使用して、すべてのプロジェクトで Maven が Red Hat Decision Manager Maven リポジトリーを使用するように設定することを推奨します。
3.1.1. プロジェクト設定ファイル (pom.xml
) を使用した Maven の設定
Maven を使用してご自分の Red Hat Decision Manager プロジェクトをビルドおよび管理するには、Maven を使用してプロジェクトがビルドされるように設定する必要があります。Maven には、プロジェクトの設定詳細を保持する POM ファイル (pom.xml
) が必要です。詳細については、「Apache Maven Project」を参照してください。
手順
-
Maven プロジェクトを生成します。
pom.xml
ファイルは、Maven プロジェクトの作成時に自動的に生成されます。 pom.xml
を編集して、追加の依存関係および新たなリポジトリーを追加します。プロジェクトのコンパイルおよびパッケージング時に、Maven がすべての JAR ファイルおよび依存関係にある JAR ファイル を Maven リポジトリーからダウンロードします。
pom.xml
ファイルのスキーマは、http://maven.apache.org/maven-v4_0_0.xsd から取得できます。POM ファイルの詳細については、「Apache Maven Project」を参照してください。
3.1.2. 設定ファイルを使用した Maven の設定
Maven 設定ファイル (settings.xml
) を使用して、Maven の実行を設定します。このファイルは、以下の場所にあります。
-
Maven インストールディレクトリー (
$M2_HOME/conf/settings.xml
)。これらの設定は、グローバル設定と呼ばれます。 -
ユーザーのインストールディレクトリー (
$USER_HOME/.m2/settings.xml
)。これらの設定は、ユーザー設定と呼ばれます。 -
システムプロパティー
kie.maven.settings.custom
で指定した特定の場所。
使用される設定は、これらの場所にあるファイルをマージしたものです。詳細については、「Apache Maven Project」を参照してください。
3.1.3. Maven 依存関係の管理
前提条件
ご自分の Red Hat Decision Manager プロジェクトで適切な Maven 依存関係を使用するには、プロジェクトの pom.xml
ファイルに該当する BOM (bill of materials) ファイルを追加する必要があります。BOM ファイルを追加すると、提供される Maven リポジトリーから、推移的依存関係の適切なバージョンがプロジェクトに含められます。
詳細については、「What is the mapping between RHDM product and maven library version?」を参照してください。
手順
pom.xml
で BOM を宣言します。以下に例を示します。例3.1 Red Hat Decision Manager 7.0.0 用の BOM
<dependencyManagement> <dependencies> <dependency> <groupId>org.jboss.bom.rhdm</groupId> <artifactId>rhdm-platform-bom</artifactId> <version>7.0.0.Final-redhat-4</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <!-- Your dependencies --> </dependencies>
プロジェクトに必要な依存関係を
<dependencies>
タグで宣言します。標準的な Red Hat ビジネス自動化プロジェクトでは、以下の依存関係を宣言します。
埋め込まれた jBPM エンジン依存関係
<dependency> <groupId>org.jbpm</groupId> <artifactId>jbpm-kie-services</artifactId> </dependency> <!-- Dependency needed for default WorkItemHandler implementations. --> <dependency> <groupId>org.jbpm</groupId> <artifactId>jbpm-workitems-core</artifactId> </dependency> <!-- Logging dependency. You can use any logging framework compatible with slf4j. --> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-classic</artifactId> <version>${logback.version}</version> </dependency> <dependency> <groupId>org.kie</groupId> <artifactId>kie-api</artifactId> </dependency>
CDI を使用する Red Hat ビジネス自動化プロジェクトでは、以下の依存関係を宣言します。
CDI 対応 jBPM エンジン依存関係
<dependency> <groupId>org.kie</groupId> <artifactId>kie-api</artifactId> </dependency> <dependency> <groupId>org.jbpm</groupId> <artifactId>jbpm-kie-services</artifactId> </dependency> <dependency> <groupId>org.jbpm</groupId> <artifactId>jbpm-services-cdi</artifactId> </dependency>
標準的な Red Hat Decision Manager プロジェクトでは、以下の依存関係を宣言します。
埋め込まれた Drools エンジン依存関係
<dependency> <groupId>org.drools</groupId> <artifactId>drools-compiler</artifactId> </dependency> <!-- Dependency for persistence support. --> <dependency> <groupId>org.drools</groupId> <artifactId>drools-persistence-jpa</artifactId> </dependency> <!-- Dependencies for decision tables, templates, and scorecards. For other assets, declare org.drools:drools-workbench-models-* dependencies. --> <dependency> <groupId>org.drools</groupId> <artifactId>drools-decisiontables</artifactId> </dependency> <dependency> <groupId>org.drools</groupId> <artifactId>drools-templates</artifactId> </dependency> <dependency> <groupId>org.drools</groupId> <artifactId>drools-scorecards</artifactId> </dependency> <!-- Dependency for loading KJARs from a Maven repository using KieScanner. --> <dependency> <groupId>org.kie</groupId> <artifactId>kie-ci</artifactId> </dependency>
Decision Server を使用するには、以下の依存関係を宣言します。
クライアントアプリケーション Decision Server 依存関係
<dependency> <groupId>org.kie.server</groupId> <artifactId>kie-server-client</artifactId> </dependency> <dependency> <groupId>org.kie.server</groupId> <artifactId>kie-server-api</artifactId> </dependency> <!-- Dependency for Red Hat JBoss BRMS functionality. --> <dependency> <groupId>org.drools</groupId> <artifactId>drools-core</artifactId> </dependency> <dependency> <groupId>org.kie</groupId> <artifactId>kie-api</artifactId> </dependency>
Red Hat ビジネス自動化または Red Hat Decision Manager のリモートクライアントを作成するには、以下の依存関係を宣言します。
クライアント依存関係
<dependency> <groupId>org.uberfire</groupId> <artifactId>uberfire-rest-client</artifactId> </dependency>
KJAR
パッケージのアセットを使用するには、kie-maven-plugin
を含める方法を推奨します。Kie Maven プラグイン
<packaging>kjar</packaging> <build> <plugins> <plugin> <groupId>org.kie</groupId> <artifactId>kie-maven-plugin</artifactId> <version>7.0.0.Final-redhat-4</version> <extensions>true</extensions> </plugin> </plugins> </build>
3.2. Git リポジトリーからのプロジェクトのインポート
Git は分散バージョン管理システムであり、リビジョンをコミットオブジェクトとして実装します。変更をリポジトリーにコミットすると、Git リポジトリーに新規コミットオブジェクトが作成されます。Decision Central でプロジェクトを作成すると、そのプロジェクトが Decision Central に接続された Git リポジトリーに追加されます。
他の Git リポジトリーにプロジェクトがある場合は、それらを Decision Central のスペースにインポートすることができます。
前提条件
外部の Git リポジトリーにある Red Hat Decision Manager プロジェクト
手順
- Decision Central で Menu → Design → Projects の順にクリックします。
- プロジェクトをインポートするスペースを選択または作成します。デフォルトのスペースは myteam です。
- 画面右側の縦に並んだ 3 つの点をクリックし、Import Project を選択します。
- Import Project ウィンドウにおいて、インポートするプロジェクトが含まれる Git リポジトリーの URL および認証情報を入力し、Import をクリックします。プロジェクトが現在のスペースに追加されます。
3.3. Red Hat JBoss Developer Studio のインストールおよび設定
Red Hat JBoss Developer Studio は Eclipse をベースにした JBoss 統合開発環境 (IDE) です。Red Hat JBoss Developer Studio は Red Hat Decision Manager 用のツールおよびインターフェースを持つプラグインを提供します。
手順
- Red Hat カスタマーポータル から最新の Red Hat JBoss Developer Studio をダウンロードします。
- Red Hat JBoss Developer Studio のドキュメントに記載された設定およびインストール手順に従います。
- 次のセクションに記載される手順に従って、Red Hat JBoss Developer Studio プラグインをインストールします。
複数バイトのルール名を処理する方法に関する問題により、JBoss Developer Studio のインスタンスは、ファイルエンコーディングを UTF-8
に設定して起動する必要があります。そのためには、$JBDS_HOME/studio/devstudio.ini
ファイルを編集し、"-Dfile.encoding=UTF-8"
というプロパティーを追加します。
3.3.1. Red Hat JBoss Developer Studio プラグインのインストール
Red Hat JBoss Developer Studio は Red Hat Decision Manager 用のツールおよびインターフェースを持つプラグインを提供します。これらのプラグインはコミュニティーバージョンの製品が基になっています。そのため、Red Hat Decision Manager プラグインは Drools プラグインと呼ばれます。
Red Hat カスタマーポータル から最新の Red Hat JBoss Developer Studio を取得します。Red Hat JBoss Developer Studio の Red Hat Decision Manager プラグインは、更新サイトより入手できます。
手順
- Red Hat JBoss Developer Studio を起動します。
- Help → Install New Software をクリックします。
- Add をクリックして Add Repository メニューに入ります。
-
Name フィールドの横で名前を指定し、Location フィールドに
https://devstudio.jboss.com/11/stable/updates/integration-stack/
の URL を追加します。 - OK をクリックします。
- 利用可能なオプションから JBoss Business Process and Rule Development 機能を選択して Next をクリックし、もう一度 Next をクリックします。
- ライセンス内容を確認して、適切なラジオボタンを押してライセンス内容に同意し、Finish をクリックします。
- インストールプロセスが終了したら、Red Hat JBoss Developer Studio を再起動します。
3.3.2. Red Hat Decision Manager サーバーの設定
Red Hat Decision Manager サーバーを実行するように Red Hat JBoss Developer Studio を設定することができます。
前提条件
- Red Hat JBoss Developer Studio
- Red Hat JBoss Developer Studio プラグインと共にインストールした Red Hat Decision Manager
手順
- Red Hat JBoss Developer Studio を起動します。
- Drools ビューを開くには、Window → Open Perspective → Other の順にクリックし、Drools を選択し、特定のビューを選択して OK をクリックします。
- Window → Show View → Other… の順にクリックし、Server → Servers を選択してサーバービューを追加します。
- Servers パネルを右クリックし、New → Server を選択してサーバーメニューを開きます。
- JBoss Enterprise Middleware → JBoss Enterprise Application Platform 7.1+ をクリックし、Next をクリックしてサーバーを定義します。
Browse ボタンをクリックしてホームディレクトリーを設定します。Red Hat Decision Manager をインストールした Red Hat JBoss EAP ディレクトリーに移動します。
Red Hat Decision Manager サーバーを設定するには、Red Hat Decision Manager をインストールした Red Hat JBoss EAP ディレクトリーを選択します。
- Name フィールドにサーバーの名前を指定して、設定ファイルが設定されていることを確認し、Finish をクリックします。
3.3.3. Git リポジトリーから Red Hat JBoss Developer Studio へのプロジェクトのインポート
Red Hat JBoss Developer Studio は、集中 Git アセットリポジトリーに接続するように設定できます。リポジトリーにはルール、モデル、関数、およびプロセスが保存されます。
ローカルの Git リポジトリーをインポートする、またはリモート Git リポジトリーのクローンを作成することができます。
3.3.4. リモート Git リポジトリーのクローン作成
Git リポジトリーのクローンを作成して Red Hat JBoss Developer Studio で使用できます。
前提条件
クローンを作成するリモート Git リポジトリーへのアクセスパーミッション
手順
- Red Hat JBoss Developer Studio の Server タブからサーバーを選択し、Start アイコンをクリックして選択したサーバーを起動します。
セキュアシェルサーバーがまだ実行されていなければ、ターミナルに以下のコマンドを入力してサーバーを起動します。
/sbin/service sshd start
注記このコマンドは、Linux および Apple Macintosh 固有のものです。これらのプラットフォームで
sshd
がすでに起動していると、このコマンドに失敗しますが、その場合はこのステップを無視しても問題ありません。- Red Hat JBoss Developer Studio で File → Import… を選択し、Git フォルダーに移動します。Git フォルダーを開き、Projects from Git を選択して Next をクリックします。
- リポジトリーのソースに Clone URI を選択し、Next をクリックします。
- 次のウィンドウで Git リポジトリーの詳細を入力して、次へ をクリックします。
- 次のウインドウでインポートするブランチを選択し、Next をクリックします。
- このプロジェクトのローカルストレージを定義するために、空ではないディレクトリーを入力 (または選択) して設定を変更し、Next をクリックします。
- 次のウィンドウでプロジェクトを一般プロジェクトとしてインポートし、Next をクリックします。
- このプロジェクトに名前を付け、Finish をクリックします。
3.3.5. ローカル Git リポジトリーのインポート
ローカルの Git リポジトリーをインポートして Red Hat JBoss Developer Studio で使用することができます。
手順
- Server タブからサーバーを選択し、Start アイコンをクリックしてサーバーを起動します。
- Red Hat JBoss Developer Studio で File → Import… を選択し、Git フォルダーに移動します。Git フォルダーを開き、Projects from Git を選択して Next をクリックします。
- リポジトリーのソースに Existing local repository を選択し、Next をクリックします。
- 使用可能なリポジトリーの一覧から設定するリポジトリーを選択し、Next をクリックします。
- 表示されたダイアログウィンドウで、Wizard for project import グループから Import as general project ラジオボタンを選択し、Next をクリックします。
- このプロジェクトに名前を付け、Finish をクリックします。