2014年4月21日月曜日

Mac MavericksにPlay Frameworkをインストール

Mac MavericksにPlay Frameworkをインストールしました。

バージョン
Mac OS X 10.9.2
Play Framework2.2.2
Java 1.7.0_51
Eclipse 4.3

Macにはhomebrewでインストールできます。便利!
$ brew install play
==> Downloading http://downloads.typesafe.com/play/2.2.2/play-2.2.2.zip
######################################################################## 100.0%
🍺  /usr/local/Cellar/play/2.2.2: 2184 files, 130M, built in 37 seconds
インストールが完了したのでplayを起動
$ play
Getting com.typesafe.play console_2.10 2.2.2 ...
:: retrieving :: org.scala-sbt#boot-app
 confs: [default]
 6 artifacts copied, 0 already retrieved (2012kB/30ms)
Getting Scala 2.10.3 (for console)...
:: retrieving :: org.scala-sbt#boot-scala
 confs: [default]
 5 artifacts copied, 0 already retrieved (24447kB/145ms)
       _
 _ __ | | __ _ _  _
| '_ \| |/ _' | || |
|  __/|_|\____|\__ /
|_|            |__/
 
play 2.2.2 built with Scala 2.10.3 (running Java 1.7.0_51), http://www.playframework.com
 
This is not a play application!
 
Use `play new` to create a new Play application in the current directory,
or go to an existing application and launch the development console using `play`.
 
You can also browse the complete documentation at http://www.playframework.com.


無事に起動したので早速プロジェクトを作成
途中プロジェクト名聞かれるのでそのままEnterを押す
ScalaとJavaどちらにするか聞かれるので、今回はScalaで。
$ play new sample
       _
 _ __ | | __ _ _  _
| '_ \| |/ _' | || |
|  __/|_|\____|\__ /
|_|            |__/
 
play 2.2.2 built with Scala 2.10.3 (running Java 1.7.0_51), http://www.playframework.com
 
The new application will be created in /Users/xxxx/play/sample
 
What is the application name? [sample]
そのままEnter
 
Which template do you want to use for this new application? 
 
  1             - Create a simple Scala application
  2             - Create a simple Java application
 
> 1
OK, application sample is created.
 
Have fun!


プロジェクトを作成したので、とりあえず起動。
$ cd sample/
$ play run
Getting org.scala-sbt sbt 0.13.0 ...
:: retrieving :: org.scala-sbt#boot-app
 confs: [default]
 43 artifacts copied, 0 already retrieved (12440kB/196ms)
[info] Loading project definition from /Users/xxxx/play/sample/project
[info] Set current project to sample (in build file:/Users/xxxx/play/sample/)
[info] Updating {file:/Users/xxxx/play/sample/}sample...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
 
--- (Running the application from SBT, auto-reloading is enabled) ---
 
[info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000
 
(Server started, use Ctrl+D to stop and go back to the console...)
http://localhost:9000 にアクセスしてYour new application is readyのページが出ればOK
アクセスするとコンソールに以下がでる
[info] Compiling 5 Scala sources and 1 Java source to /Users/xxxx/play/sample/target/scala-2.10/classes...
[info] 'compiler-interface' not yet compiled for Scala 2.10.3. Compiling...
[info]   Compilation completed in 11.059 s
[info] play - Application started (Dev)
最初はdevモードで起動するので、起動しただけだとコンパイルはされずに、
初めてアクセスをしたタイミングでコンパイルが走る。

Ctrl+Dで停止すると以下が出て終了
[success] Total time: 155 s, completed 2014/04/15 12:10:15

次にEclipseで開発できるように以下を実行
$ play eclipse
[info] Loading project definition from /Users/xxxx/play/sample/project
[info] Set current project to sample (in build file:/Users/xxxx/play/sample/)
[info] About to create Eclipse project files for your project(s).
[info] Successfully created Eclipse project files for project(s):
[info] sample

Eclipse側の対応もやっていく。
eclipseにScala IDEをインストール
eclipseはeclipse-jee-kepler-SR2-macosx-cocoa-x86_64.tar.gzをダウンロードしてきて使用。
ソフトウエアを追加する。
Help → Install New Software
Addで以下を追加
Name:Scala IDE for Eclipse
Location:http://download.scala-ide.org/sdk/e38/scala210/dev/site/

Scala IDE for Eclipse
Scala IDE for Eclipse development support
Scala IDE for Eclipse Source Feature
Scala IDE plugins(incubation)
Sources
の5つが表示されるのですべてチェックしてNext

Will not be installedに以下が表示されていたけど、
InSynth Feature
keep my installation the same and modify the items being installed tobe compatible
を選択してNext。
もう一回Next。
Review Licensesの画面になるのでI accept〜を選択してFinish

Security Warningが出るけどOK
再起動するか聞かれるのでOK

再起動すると
Upgrade of Scala plugin detected.
Run setup diagnostics to ensure correct plugin settings?
と聞かれるのでYesとして、内容を確認してOKする

File-Import-General-Existing Projects into Workspace
Select root directory:に先ほど作ったplayのプロジェクトのディレクトリを指定してFinish
これでEclipseからPlayのプロジェクトを開発できます。

0 件のコメント:

コメントを投稿