LoginSignup
13
15

More than 5 years have passed since last update.

Scala + Playでwarファイル作成

Last updated at Posted at 2014-09-25

はじめに

ひさしぶりにScala + Play Frameworkを使ってみたら、昔書いた記事のとおりでは、warファイルを作成できなくなっていた。
しかも、playコマンドがなくなって(?)、activatorというコマンドを使うようだ。

いろいろ調べて、今(2014年9月)のScala + Playでwarファイルを作成できたので備忘録としてまとめておく。

使用しているバージョン

Scala 2.11.2
Play 2.3.4

activatorコマンドのメモ

プロジェクトの新規作成

$ activator new my-first-app play-scala

プロジェクトの実行

$ cd my-first-app
$ activator run

または、

$ activator start

runとstartの違いは、ホットデプロイできるのがrun。主に開発時に使うようだ。
実際の運用時に使うのがstartと思われる。

Eclipseでインポート

$ activator eclipse

と実行しておいてから、Eclipseで、File->Importする。

play2-war-pluginの導入

warファイルを作成するには、play2-war-pluginを導入する必要がある。

以前はプラグインを使うときには、project/Build.scalaにいろいろ設定を書いていたが、Build.scalaはもう使わないようだ。
プラグインなどの設定は、build.sbtとproject/plugins.sbtに書く。

play2-war-pluginに関係するところだけ抜粋する。

build.sbt
import com.github.play2war.plugin._

name := "appname"

version := "1.0-SNAPSHOT"

Play2WarPlugin.play2WarSettings

Play2WarKeys.servletVersion := "3.0"

Play2WarKeys.servletVersionの値が3.0なのは、AWSのElastic BeanstalkがTomcat7だから。

plugins.sbt
// Comment to get more information during initialization
logLevel := Level.Warn

// The Typesafe repository
resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"

// Use the Play sbt plugin for Play projects
addSbtPlugin("com.github.play2war" % "play2-war-plugin" % "1.3-beta3")

warファイルの作成

プロジェクトのホームディレクトリで以下のコマンドを実行する。

$ sbt war

sbt です。 activator ではありません。
正直、activatorから実行する方法がわかりませんでした…。

参考URL

http://cs.hatenablog.jp/entry/2013/12/15/234618
https://github.com/play2war/play2-war-plugin/wiki/Configuration

13
15
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
15