Maven を使用した Liberty のタスクの自動化
Apache Maven は、プロジェクト・オブジェクト・モデル (POM) の概念に基づいたソフトウェア・プロジェクト管理ツールです。 Liberty で提供された Maven プラグインを使用して、サーバーおよびアプリケーションを管理できます。
始める前に
Liberty 用の Maven プラグインは、WebSphere® Application Server Developer Community (WASdev) の Maven リポジトリーにあります。Liberty 用の Maven プラグインを使用する場合は、プロジェクトの pom.xml ファイルに WASdev プラグイン・リポジトリーが指定されていることを確認してください。
次の例は、このリポジトリーを構成し、プロジェクトで liberty-maven-plugin を使用可能にする方法を示しています。
<project>
...
<pluginRepositories>
<!-- Configure WASdev repository -->
<pluginRepository>
<id>WASdev</id>
<name>WASdev Repository</name>
<url>http://public.dhe.ibm.com/ibmdl/export/pub/software/websphere/wasdev/maven/repository/</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
</pluginRepository>
</pluginRepositories>
...
<build>
<plugins>
<!-- Enable liberty-maven-plugin -->
<plugin>
<groupId>com.ibm.websphere.wlp.maven.plugins</groupId>
<artifactId>liberty-maven-plugin</artifactId>
<version>1.0</version>
<!-- Specify configuration, executions for liberty-maven-plugin -->
...
</plugin>
</plugins>
</build>
...
</project>
Liberty Maven プラグインは、Liberty サーバーのインストール情報を使用して構成する必要があります。このインストール情報は、既存のインストール・ディレクトリー、圧縮アーカイブ、または Maven 成果物として指定できます。
- 既存のインストール・ディレクトリーで構成する。serverHome パラメーターを使用して、既存の Liberty サーバーのインストール済み環境のディレクトリーを指定します。以下に例を示します。
... <plugin> <groupId>com.ibm.websphere.wlp.maven.plugins</groupId> <artifactId>liberty-maven-plugin</artifactId> <version>1.0</version> <configuration> <serverHome>/opt/ibm/wlp</serverHome> </configuration> </plugin> ...
- 圧縮アーカイブで構成する。assemblyArchive パラメーターを使用して、Liberty プロファイル・サーバー・ファイルを含む圧縮アーカイブを指定します。以下に例を示します。
... <plugin> <groupId>com.ibm.websphere.wlp.maven.plugins</groupId> <artifactId>liberty-maven-plugin</artifactId> <version>1.0</version> <configuration> <assemblyArchive>/opt/ibm/wlp.zip</assemblyArchive> </configuration> </plugin> ...
- Maven 成果物名で構成する。assemblyArtifact パラメーターを使用して、Liberty サーバー・ファイルを含む Maven 成果物の名前を指定します。以下に例を示します。
Liberty プロファイル・サーバーの Maven 成果物としてのインストールについて詳しくは、Liberty: Maven 成果物としてのインストールを参照してください。... <plugin> <groupId>com.ibm.websphere.wlp.maven.plugins</groupId> <artifactId>liberty-maven-plugin</artifactId> <version>1.0</version> <configuration> <assemblyArtifact> <groupId>com.ibm.ws.liberty.test</groupId> <artifactId>liberty-test-server</artifactId> <version>1.0</version> <type>zip</type> </assemblyArtifact> </configuration> </plugin> ...
このタスクについて
提供されている Maven プラグインを使用して、Liberty サーバーの作成、始動、停止、パッケージ化、および Liberty でのアプリケーションのテストを行えます。各タスクは、Maven の特定のゴールで表されます。