プライマリ・コンテンツに移動
Oracle® Fusion Middleware Oracle SOA SuiteでのSOAアプリケーションの開発
12c (12.1.3)
E53007-05
目次へ移動
目次

前
次

48 Oracle SOA Suite開発Mavenプラグインの使用

この章では、Oracle SOA Suite開発Mavenプラグインを使用してSOAコンポジット・アプリケーション・プロジェクトをビルドし、管理する方法を説明します。Oracle SOA Suite開発Mavenプラグインを使用して、Maven環境でSOAコンポジット・アプリケーションのコンパイル、パッケージ化、デプロイ、テスト、およびアンデプロイを実行できます。

この章の内容は次のとおりです。

Oracle Fusion MiddlewareでのMavenの使用の詳細は、『継続的統合によるアプリケーションの開発』、および『Oracle WebLogic Serverアプリケーションの開発』のWebLogic開発Mavenプラグインの使用に関する項を参照してください。

Mavenを使用したアプリケーションとプロジェクトのビルドの詳細は、http://maven.apache.org/users/index.htmlを参照してください。

48.1 Oracle SOA Suite Mavenプラグインの概要

Mavenは、ランタイム・プロジェクトの作成と管理を可能にするビルド自動化ツールです。Oracle SOA Suite Mavenプラグインを使用して、SOAコンポジット・アプリケーションをビルドおよび管理できます。Mavenは、すべての依存関係についてアーティファクト・リポジトリに準拠します。インストール済のOracleライブラリはすべてMavenリポジトリに伝播されます。これにより、Mavenはこれらをアーティファクトと認識し、プロジェクト・オブジェクト・モデル(POM)ファイル内で指定できます。

48.1.1 POMファイルおよびArchetype

Mavenプロジェクトは、POMファイルを使用して構成されます。POMファイルは、コンポジットのビルドに必要なSOAインフラストラクチャ・ツールなどの依存関係を記述します。

Archetypeは、プロジェクトを作成するためのテンプレートです。Archetypesは、単一のSOAプロジェクトを含む新しいSOAアプリケーションを作成するため、または既存のSOAアプリケーションに追加のSOAプロジェクトを追加するために提供されています。これらのArchetypesを使用して、SOAコンポジット・アプリケーションのコンパイル、パッケージ化、デプロイ、テストおよびアンデプロイを行うことができます。

次の例は、Oracle SOA Suite用のMaven POMのサンプル・ファイルを示しています。

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
 http://maven.apache.org/xsd/maven-4.0.0.xsd"
 xmlns="http://maven.apache.org/POM/4.0.0"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.test</groupId>
    <artifactId>MyComposite</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>sar</packaging>
    
    <!--
           This POM was generated from the SOA Maven Archetype.
           Comments in this POM guide you how to use it with your project.
           This POM relates to this SOA Composite, i.e. the one in this same
           directory. There is another POM in the SOA Application directory (up
           one) which handles the whold SOA Application, which may contain
           additional projects.
 
           The parent points to the common SOA parent POM.  That is a special POM
           that is shipped by Oracle as a point of customization (only).  You can
           add default values for properties like serverUrl, etc. to the SOA
           common parent POM, so that you do not have to specify them over and
           over in every project POM. 
    -->
    <parent>
        <groupId>com.oracle.soa</groupId>
        <artifactId>soa-project-common</artifactId>
        <version>12.1.3-0-0</version>
    </parent>
    
    <properties>
        <!-- these parameters are used by the compile goal -->
        <scac.input.dir>${project.basedir}/SOA/</scac.input.dir>
        <scac.output.dir>${project.basedir}/target</scac.output.dir>
        <scac.input>${scac.input.dir}/composite.xml</scac.input>
        <scac.output>${scac.output.dir}/out.xml</scac.output>
        <scac.error>${scac.output.dir}/error.txt</scac.error>
        <scac.displayLevel>1</scac.displayLevel>
        <!-- if you are using a config plan, uncomment the following line and
             update to point to your config plan -->
        <!--<configplan>${scac.input.dir}/configplan.xml</configplan>-->
 
        <!-- these parameters are used by the deploy and undeploy goals -->
        <composite.name>${project.artifactId}</composite.name>
        <composite.revision>${project.version}</composite.revision>
        <composite.partition>default</composite.partition>
        <serverUrl>serverUrl</serverUrl>
        <user>user</user>
        <password>password</password>
        <overwrite>true</overwrite>
        <forceDefault>true</forceDefault>
        <regenerateRulebase>false</regenerateRulebase>
        <keepInstancesOnRedeploy>false</keepInstancesOnRedeploy>
 
        <!-- these parameters are used by the test goal -->
        <!-- if you are using the sca-test (test) goal, you need to uncomment the
             following line and point it to your jndi.properties file. -->
        <jndi.properties.input>${basedir}/jndi.properties</jndi.properties.input>
        <scatest.result>${scac.output.dir}/testResult</scatest.result>
        <!--  input is the name of the composite to run test suties against -->
        	<input>MyComposite</input>
    </properties>
 
    <!--
           These refer to the properties defined above.  You should probably not
           need to make any changes beflow this point - these just point to the
           properties above.
    -->
    <build>
        <plugins>
            <plugin>
                <groupId>com.oracle.soa.plugin</groupId>
                <artifactId>oracle-soa-plugin</artifactId>
                <version>12.1.3-0-0</version>
                <configuration>
                    <compositeName>MyComposite</compositeName>
                    <composite>${scac.input}</composite>
                    <sarLocation>${scac.output.dir}/sca_${project.artifactId}_
                                 rev${composite.revision}.jar</sarLocation>
                    <serverUrl>${serverUrl}</serverUrl>
                    <!-- note: compositeRevision is needed to package, revision is
                         needed to undeploy -->
                    <compositeRevision>${composite.revision}</compositeRevision>
                    <revision>${composite.revision}</revision>
                    <scacInputDir>${scac.input.dir}</scacInputDir>
                    <!-- note: if this composite contains a component that depends
                         on MDS to build, e.g. a Human Task or Business Rule, then
                         you will need to uncomment the next line, and edit it to
                         point to your application directory (which contains
                         .adf/adf-config.xml file with MDS configuration in it -->
                    <!--<appHome>${project.basedir}/..</appHome>-->
                    <!--  If you have a composite which contains a component that 
                          depends on MDS (eg. Human Task, Business Rule) AND you 
                          want to use a file-based MDS repository, then you
                          need to do either:
                          1. update the .adf/META-INF/adf-config.xml to point to
                             the correct location of the file based repository,
                             i.e. remove the reference to ${oracle.home} in that
                             file, or
                          2. define oracleHome here and leave the adf-config.xml
                             file as is.  Note that the correct value is the path
                             to your SOA Quickstart or JDeveloper install
                             directory, with "/soa" appended to it.
                    -->
                    <!--<oracleHome>JDEV_HOME/soa</oracleHome>-->
                    <user>${user}</user>
                    <password>${password}</password>
		                    <input>${input}</input>
                </configuration>
                <!-- extensions=true is needed to use the custom sar packaging
                     type -->
                <extensions>true</extensions>
            </plugin>
        </plugins>
    </build>
</project>

注意:

ヒューマン・タスクやビジネス・ルールなどのMDSに依存するコンポジットでコンポーネントを使用している場合は、<appHome>${project.basedir}/..</appHome>行をコメント解除して、使用するアプリケーション・ディレクトリを指すように編集します。

MDSに依存するコンポーネントを使用している場合で、デフォルトのadf-config.xmlファイルから参照されるようなファイルベースのMDSを使用する場合も、<oracleHome>JDEV_HOME/soa</oracleHome>をコメント解除して、/soaを付加し、使用するSOAクイック・スタートまたはJDeveloperインストール・ディレクトリを指すように編集する必要があります。

次の例は、Oracle SOA Suiteアプリケーションを作成するためのPOMファイル内のArchetype座標を示しています。

<groupId>com.oracle.soa.archetype</groupId>
<artifactId>oracle-soa-application</artifactId>
<version>12.1.3-0-0</version>

48.1.2 Mavenプラグインのゴール

ゴールは、コンポジット・ライフ・サイクルの様々なフェーズに関連しています。

ライフ・サイクル・フェーズに関連付けられているゴールを起動すると、指定したゴールまで(そのゴールを含む)マップされているすべてのゴールが実行されます。たとえば、testゴールを実行すると、compile、packageおよびdeployのゴールがtestゴールの前に実行されます。この項の各ゴールの説明には、各コールが起動されたときに実行されるアクションがリストされています。

SOAコンポジット・アプリケーションのビルドとデプロイのライフ・サイクルをサポートするために、次の実行可能プラグイン・ゴールが提供されています。

  • compile (scac)

  • package (sar)

  • deploy

  • test (sca-test)

  • undeploy

ゴールを実行する前に、そのゴールに必要なすべてのパラメータがPOMファイルに指定されていることを確認してください。POMファイルのサンプルについては、「POMファイルおよびArchetype」を参照してください。

注意:

プロジェクト、コンポジットまたはプロジェクト・ディレクトリの名前を変更した場合は、これらのゴールを実行する前に新しい名前でPOMファイルを更新してください。

次の例は、POMファイル内のOracle SOA SuiteプラグインのgroupIdartifactId、およびversionの各座標を示しています。

<groupId>com.oracle.soa.plugin</groupId>
<artifactId>oracle-soa-plugin</artifactId>
<version>12.1.3-0-0</version>

48.1.2.1 compile

compileゴールは、SOAコンポジット・アプリケーションをコンパイルします。Oracle SOA Suiteは、このゴール用のネイティブMaven実装を提供しています。次のコマンドは、SOAコンポジット・アプリケーションをコンパイルします。

mvn compile

48.1.2.2 package

packageゴールは、SOAコンポジット・アプリケーションのアーティファクトをSOAアーカイブ(SAR)ファイルにパッケージ化します。次のコマンドは、SOAコンポジット・アプリケーションをコンパイルし、パッケージ化します。

mvn package

48.1.2.3 deploy

deployゴールは、SOAコンポジット・アプリケーションをデプロイします。Oracle SOA Suiteは、このゴール用のネイティブMaven実装を提供しています。次のコマンドは、SOAコンポジット・アプリケーションをコンパイルし、コンポジットをSARファイルにパッケージ化し、SARファイルをサーバーにデプロイします。

mvn pre-integration-test

48.1.2.4 test

testゴールは、SOAコンポジット・アプリケーションのテストを実行します。Oracle SOA Suiteは、このゴール用のネイティブMaven実装を提供しています。

Oracle JDeveloperでテストを作成してからtestゴールを実行する必要があります。JDeveloperを使用したテストの作成方法の詳細は、「SOAコンポジット・アプリケーションのテストの自動化」を参照してください。

testゴールを実行する前に、jndi.properitesファイルを含める必要もあります。POMファイルで次の行を編集して、jndi.properties file: <jndi.properties.input>${basedir}/jndi.properties</jndi.properties.input>を指すようにします。

次に、jndi.propertiesファイルのサンプルを示します。

         java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory
         java.naming.provider.url=t3://servername:7103/soa-infra
         java.naming.security.principal=weblogic
         java.naming.security.credentials=welcome1
         dedicated.connection=true
         dedicated.rmicontext=true

次のコマンドは、コンポジットをコンパイルし、コンポジットをSARファイルにパッケージ化し、SARファイルをサーバーにデプロイして、コンポジットをテストします。

mvn verify

48.1.2.5 undeploy

undeployゴールは、SOAコンポジット・アプリケーションをアンデプロイします。Oracle SOA Suiteは、このゴール用のネイティブMaven実装を提供しています。次のコマンドはコンポジットをアンデプロイします。

注意:

undeployゴールは、ライフ・サイクル・フェーズにマッピングされません。このステップは、名前を指定して明示的に呼び出す必要があります。

mvn com.oracle.soa.plugin:oracle-soa-plugin:undeploy

48.1.3 Mavenオンライン・ヘルプの使用

Mavenオンライン・ヘルプでは、ゴールとその関連コマンドのリストが提供されます。たとえば、次のコマンドを入力すると、Maven testゴールのオンライン・ヘルプが表示されます。

mvn help:describe -Ddetail=true -Dplugin=com.oracle.soa.plugin:oracle-soa-plugin:12.1.3-0-0 -Dgoal=test

このコマンドは、次のヘルプ詳細を表示します。

oracle-soa:test
Description: Description: To execute SCA Test Suites.
Implementation: com.oracle.soa.plugin.SoaTest
Language: java
Bound to phase: verify
Goal Prefix: oracle-soa

Available parameters:

   format (Default: native)
      User property: format
      The format of the output - 'native' or 'junit'.

   input
      Required: true
      User property: input
      The name of the composite to execute tests against.

   jndiPropertiesInput
         Required: true
         User property: jndi.properties.input
         Path to JNDI properties file required for SCA Test execution.
         This file should contain contents similar to the following:
         java.naming.factory.initial=weblogic.jndi.WLInitialContextFactory
         java.naming.provider.url=t3://servername:7103/soa-infra
         java.naming.security.principal=weblogic
         java.naming.security.credentials=welcome1
         dedicated.connection=true
         dedicated.rmicontext=true

      partition (Default: default)
         User property: partition
         Which SOA partition the composite is deployed in.

      result (Default: ${java.io.tmpdir}/out)
         User property: result
         Where to place the results.

      timeout (Default: 300)
         User property: timeout
         How long to wait for tests to complete before timing out.

48.2 Oracle SOA Suite Mavenプラグインのインストール

Maven 3.0.5のディストリビューションは、次の場所のOracle Fusion Middlewareに含まれています。

Middleware_Home/Oracle_Home/oracle_common/modules/org.apache.maven_3.0.5

Oracle Fusion MiddlewareでのMavenのインストールの詳細は、『継続的統合によるアプリケーションの開発』の「ビルド自動化と依存性管理のためのMavenのインストールおよび構成」を参照してください。第5.1項「Mavenディストリビューションの設定」および第5.2項「Maven設定のカスタマイズ」の設定手順に従ってください。

48.2.1 Oracle SOA Suite Mavenプラグインの構成方法

Oracle SOA Suite Mavenプラグインを使用する前に、MavenリポジトリにOracle Artifactsを移入する必要があります。リポジトリの移入の詳細は、『継続的統合によるアプリケーションの開発』のMavenリポジトリ・マネージャへの移入に関する項を参照してください。次の各手順は、このガイドの特定の項にリンクされています。

Oracle SOA Suite開発Mavenプラグインを構成する手順は、次のとおりです。

  1. ORACLE_HOME/oracle_common/plugins/maven/com/oracle/maven/oracle-maven-sync/12.1.3に移動します。
  2. 次のコマンドを実行してMaven同期プラグインをインストールします。
    mvn install:install-file -DpomFile=oracle-maven-sync-12.1.3.pom -Dfile=oracle-maven-sync-12.1.3.jar
    

    その他のオプションについては、「Oracle Maven同期プラグインのインストール」を参照してください。

  3. 次のコマンドを実行して、Oracle SOA Suite開発MavenプラグインをMavenリポジトリにシードします。
    mvn com.oracle.maven:oracle-maven-sync:push -DoracleHome=ORACLE_HOME
    

    ここでORACLE_HOMEは、Oracle Fusion Middlewareインストールのフルパスです。その他のオプションについては、「Oracle Maven同期プラグインの実行」を参照してください。

  4. Maven help:describeゴールを使用して、プラグインのインストールが成功したかどうかを検証します。
    mvn help:describe -DgroupId=com.oracle.soa.plugin
    -DartifactId=oracle-soa-plugin -Dversion=12.1.3-0-0
    

    Oracle SOA Suiteプラグインのインストールを確認する情報の抜粋を次に示します。

    Name: Oracle SOA Maven Plugin
    Description: This plugin allows users to compile, package, deploy, test and  undeploy SOA composites.
    Group Id: com.oracle.soa.plugin
    Artifact Id: oracle-soa-plugin
    Version: 12.1.3-0-0
    Goal Prefix: oracle-soa
    This plugin has 6 goals:
    oracle-soa:compile
    

48.3 Oracle SOA Suite Maven Archetypeの使用

Oracle SOA SuiteのArchetypeを使用して、SOAアプリケーション用のPOMファイルを生成します。SOAアプリケーションを追加するディレクトリの親ディレクトリから次のコマンドを実行します。SOAアプリケーションは、artifactIdプロパティの値から名前が付けられたサブディレクトリに作成されます。

注意:

Oracle SOA Suite Maven Archetypeを使用して作成されたSOAアプリケーションは、SOAアプリケーションの作成ウィザードを使用してOracle JDeveloperに作成されたものと同じです。

mvn archetype:generate 
 -DarchetypeGroupId=com.oracle.soa.archetype
 -DarchetypeArtifactId=oracle-soa-application
 -DarchetypeVersion=12.1.3-0-0 
 -DarchetypeRepository=local
 -DgroupId=org.my.test
 -DartifactId=test-soa-application
 -DprojectName=test-soa-project
 -Dversion=1.0-SNAPSHOT

説明:


プロパティ 説明

archetypeGroupId

使用するArchetypeのグループIDを入力します(com.oracle.soa.archetype)。

archetypeArtifactId

使用するArchetypeのアーティファクトIDを入力します(oracle-soa-application)。

archetypeVersion

Archetypeバージョンを入力します(12.1.3-0-0)。

archetypeRepository

使用するMavenリポジトリを入力します。(オプション)

groupId

ビルドするプロジェクトのグループIDを入力します(この例では、org.my.test)。

artifactId

ビルドするプロジェクトのアーティファクトIDを入力します。これは、現行ディレクトリ内のサブディレクトリの名前になります(この例では、test-soa-project)。SOAアプリケーションおよび最初のSOAプロジェクトがこのサブディレクトリに作成されます。

projectName

SOAアプリケーション内に作成されるSOAプロジェクトの名前を入力します。これはコンポジットの名前にもなります。

package

SOAアプリケーション内に作成されるSOAプロジェクトの名前を入力します。(オプション)

version

ビルドするプロジェクトのバージョンを入力します(この例では、1.0-SNAPSHOT)