Slim3プロジェクトをMaven2でGAEにデプロイする方法
Slim3公式サイトのMavenのページでSlim3プロジェクトをMaven2で作成する手順がまとまっていますが、このままだとGAEへのデプロイは失敗します。以下の対応により、Maven2からGAEへのデプロイも可能となります。
pom.xmlの修正
<build> <finalName>slim3-maven</finalName> ・・・ <pluginManagement> <plugins> ・・・ <!-- maven-gae-pluginの追加 --> <plugin> <groupId>net.kindleit</groupId> <artifactId>maven-gae-plugin</artifactId> <version>0.7.2</version> </plugin> </plugins> </pluginManagement> <plugins> ・・・ <!-- maven-gae-pluginの追加 --> <plugin> <groupId>net.kindleit</groupId> <artifactId>maven-gae-plugin</artifactId> <version>0.7.2</version> <configuration> <serverId>appengine.google.com</serverId> <sdkDir><!-- GAEのSDKのルートディレクトリを指定。 EclipseのGoogleプラグイン内のSDK (/plugins/com.google.appengine.eclipse.sdkbundle.1.3.8_1.3.8.v201010161055/appengine-java-sdk-1.3.8)を 指定することもできます。 --></sdkDir> <appDir>${basedir}/war</appDir> </configuration> </plugin> <!-- maven-war-pluginの追加 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <version>2.1.1</version> <configuration> <webResources> <resource> <directory>${basedir}/war</directory> <filtering>true</filtering> <includes> <include>**</include> </includes> <excludes> <exclude>ktrwjr/**</exclude> <exclude>WEB-INF/appengine-generated/**</exclude> </excludes> </resource> </webResources> </configuration> </plugin> </plugins> </build>
.m2/settings.xmlの修正
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> ・・・ <!-- サーバ設定を追加 --> <servers> <server> <id>appengine.google.com</id> <username><!-- ユーザ名 --></username> <password><!-- パスワード --></password> </server> </servers> </settings>
パスワードは平文が危険であれば、暗号化して保持することもできます。詳細は以下。
http://maven.apache.org/guides/mini/guide-encryption.html
実行は以下のコマンドです。
mvn clean gae:deploy
Maven GAE pluginの詳細は以下。
http://www.kindleit.net/maven_gae_plugin/index.html