Red Hat Training

A Red Hat training course is available for Red Hat Decision Manager

第9章 プロジェクトでの Maven 依存関係の設定

外部の Maven リポジトリーを使用してプロジェクトをデプロイすることができます。プロジェクトの作成時には、Decision Central は、Decision Central 用に設定された Maven リポジトリーを使用します。以下のファイルを変更することで、Maven グローバルまたはユーザー設定を使用して、すべての Red Hat Decision Manager プロジェクトに対して Red Hat Decision Manager の公開リポジトリーから依存関係を取得するように指示できます。

  • Maven settings.xml ファイル。
  • Maven プロジェクトオブジェクトモデル (POM) ファイル (pom.xml)。

詳細は Packaging and deploying a Red Hat Decision Manager project を参照してください。

9.1. Maven 設定ファイルの修正

組み込みリポジトリーの代わりに、Nexus などの外部 Maven リポジトリーを使用するように Decision Central および Decision Server を設定できます。この場合、Decision Central でプロジェクトをビルドする際に、ビルドしたプロジェクトの全 KJAR ファイルがこの外部リポジトリーにプッシュされます。統合プロセスを実装する場合に、必要に応じてリポジトリーからこのファイルを処理し、Decision Central または Decision Server REST API を使用して KJAR ファイルをデプロイできます。

前提条件/事前作業

Decision Central および Decision Server がインストールされている。詳細は、RED HAT DECISION MANAGER インストールのプラニング を参照してください。

手順

  1. 外部リポジトリーの接続およびアクセスの詳細が含まれる Maven settings.xml ファイルを作成します。settings.xml ファイルの詳細は Maven の 「Settings Reference」を参照してください。
  2. 既知の場所 (例: /opt/custom-config/settings.xml) にファイルを保存します。
  3. Red Hat Decision Manager インストールディレクトリーで、standalone-full.xml ファイルに移動します。たとえば、Red Hat Decision Manager に Red Hat JBoss EAP インストールを使用する場合は $EAP_HOME/standalone/configuration/standalone-full.xml に移動します。
  4. standalone-full.xml<system-properties> タグで、kie.maven.settings.custom プロパティーに settings.xml ファイルのフルパス名を設定します。

    以下は例を示しています。

    <property name="kie.maven.settings.custom" value="/opt/custom-config/settings.xml"/>
  5. Decision Central と Decision Server を起動または再起動します。

9.2. Maven POM ファイルの修正

ご自分の Red Hat Decision Manager プロジェクトで適切な Maven 依存関係を使用するには、プロジェクトの pom.xml ファイルに Red Hat Business Automation の BOM (bill of materials) ファイルを追加します。Red Hat Business Automation BOM は、Red Hat Decision Manager と Red Hat Process Automation Manager の両方に適用されます。BOM ファイルを追加すると、提供される Maven リポジトリーから、推移的依存関係の適切なバージョンがプロジェクトに含められます。

Red Hat Business Automation BOM (Bill of Materials) についての詳細情報は、What is the mapping between Red Hat Decision Manager and the Maven library version? を参照してください。

手順

  1. Red Hat Business Automation BOM を pom.xml ファイルで宣言します。

    <dependencyManagement>
     <dependencies>
      <dependency>
       <groupId>com.redhat.ba</groupId>
       <artifactId>ba-platform-bom</artifactId>
       <version>7.1.0.GA-redhat-00002</version>
       <type>pom</type>
       <scope>import</scope>
      </dependency>
     </dependencies>
    </dependencyManagement>
    <dependencies>
    <!-- Your dependencies -->
    </dependencies>
  2. <dependencies> タグでお使いのプロジェクトに必要な依存関係を宣言します。製品の BOM をプロジェクトにインポートしたら、ユーザー向け製品依存関係のバージョンが定義されるため、<dependency> 要素のサブ要素 <version> を指定する必要はありません。ただし、<dependency> 要素を使用して、プロジェクトで使用する依存関係を宣言する必要があります。
  3. Decision Central で作成されないスタンドアロンのプロジェクトでは、お使いのプロジェクトに必要な依存関係をすべて指定します。Decision Central で作成するプロジェクトでは、Decision Central が基本的なデシジョンエンジンの依存関係を自動的に提供します。

    • 標準的な Red Hat Decision Manager プロジェクトでは、使用する機能に応じて、以下の依存関係を宣言します。
    • 標準的な Red Hat Decision Manager プロジェクトでは、以下の依存関係を宣言します。

      埋め込みデシジョンエンジン依存関係

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

    • Red Hat Decision Manager にリモートクライアントを作成するには、以下の依存関係を宣言します。

      クライアントの依存関係

      <dependency>
        <groupId>org.uberfire</groupId>
      </dependency>

    • ルール、プロセス定義など、アセットを含む JAR ファイルを作成する場合は、お使いの Maven プロジェクトのパッケージングの種類を kjar とし、org.kie:kie-maven-plugin を使用して、<project> 要素に置かれた kjar パッケージングタイプを処理します。以下の例の ${kie.version} は、What is the mapping between Red Hat Decision Manager and the Maven library version? に記載されている Maven ライブラリーのバージョンです。

      <packaging>kjar</packaging>
      <build>
       <plugins>
        <plugin>
         <groupId>org.kie</groupId>
         <artifactId>kie-maven-plugin</artifactId>
         <version>${kie.version}</version>
         <extensions>true</extensions>
        </plugin>
       </plugins>
      </build>