Scala Play activator on OSX
久しぶりにScala Play環境作ったらactivator というものが出てきたらしい。
"Typesafe Activator は activator ui と activator new という 2つのコマンドを追加するカスタム版の sbt だ。 つまり、activator は sbt のスーパーセットであると言える。"
始める sbt — Typesafe Activator (sbt を含む) のインストール
あ、はい。
以下を見ながらすすめた。
https://www.playframework.com/documentation/ja/2.3.x/Installing
javaのバージョン確認
Download | The Scala Programming Language
[dela@MacBook-Air dela] javac -version Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 javac 1.6.0_65 [dela@MacBook-Air dela] java -version Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 java version "1.6.0_65" Java(TM) SE Runtime Environment (build 1.6.0_65-b14-466.1-11M4716) Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-466.1, mixed mode)
Scala 2.11.7はjdk1.6以上が必要。だから大丈夫な、はず。更新はあとでやろうと思う。
brew installで最新がインストールされる。
[dela@MacBook-Air dela] brew info scala scala: stable 2.11.7 (bottled), devel 2.12.0-M1 Scala programming language http://www.scala-lang.org/ /usr/local/Cellar/scala/2.11.7 (46 files, 31M) * Poured from bottle From: https://github.com/Homebrew/homebrew/blob/master/Library/Formula/scala.rb ==> Options --with-docs Also install library documentation --with-src Also install sources for IDE support --devel Install development version 2.12.0-M1 ==> Caveats To use with IntelliJ, set the Scala home to: /usr/local/opt/scala/idea Bash completion has been installed to: /usr/local/etc/bash_completion.d [dela@MacBook-Air dela] brew install scala ==> Downloading https://homebrew.bintray.com/bottles/scala-2.11.7.yosemite.bottle.tar.gz ######################################################################## 100.0% ==> Pouring scala-2.11.7.yosemite.bottle.tar.gz ==> Caveats To use with IntelliJ, set the Scala home to: /usr/local/opt/scala/idea Bash completion has been installed to: /usr/local/etc/bash_completion.d ==> Summary 🍺 /usr/local/Cellar/scala/2.11.7: 46 files, 31M
activatorをダウンロードしてパスを通す。
Build Reactive Applications with Typesafe Activator | @typesafe
export PATH=$PATH:/path/to/activator-dist-1.3.7
activatorコマンドの確認
[dela@MacBook-Air dela] activator -help Usage: activator <command> [options] Command: ui Start the Activator UI new [name] [template-id] Create a new project with [name] using template [template-id] list-templates Print all available template names -h | -help Print this message Options: -v | -verbose Make this runner chattier -d | -debug Set sbt log level to debug -mem <integer> Set memory options (default: , which is -Xms1024m -Xmx1024m -XX:MetaspaceSize=64m -XX:MaxMetaspaceSize=256m) -jvm-debug <port> Turn on JVM debugging, open at the given port. # java version (default: java from PATH, currently java version "1.8.0_65") -java-home <path> Alternate JAVA_HOME # jvm options and output control -Dkey=val Pass -Dkey=val directly to the java runtime -J-X Pass option -X directly to the java runtime (-J is stripped) # environment variables (read from context) JAVA_OPTS Environment variable, if unset uses "" SBT_OPTS Environment variable, if unset uses "" ACTIVATOR_OPTS Environment variable, if unset uses "" In the case of duplicated or conflicting options, the order above shows precedence: environment variables lowest, command line options highest.
Scala Play アプリを新規作成して、activatorコンソールを起動する。
[dela@MacBook-Air develop] activator new my-first-app play-scala [dela@MacBook-Air develop] cd my-first-app/ [dela@MacBook-Air my-first-app] activator #省略 [error] java.lang.UnsupportedClassVersionError: org/webjars/WebJarExtractor$Cache : Unsupported major.minor version 51.0
jdkを更新。使おうとしてるバージョンに合わせる。
Java SE - Downloads | Oracle Technology Network | Oracle
ダウンロードして.zshrcのJAVA_HOMEを以下に変更
export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
activatorコンソールを再起動する。
[dela@MacBook-Air my-first-app] activator Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8 [info] Loading project definition from /Users/dela/Documents/develop/scala/my-first-app/project [info] Set current project to my-first-app (in build file:/Users/dela/Documents/develop/scala/my-first-app/) [my-first-app] $
アプリを起動。初回は相変わらずすごく時間かかる
[my-first-app] $ run [info] Updating {file:/Users/dela/Documents/develop/scala/my-first-app/}root... [info] Resolving jline#jline;2.12.1 ... [info] downloading https://repo1.maven.org/maven2/com/typesafe/play/play-server_2.11/2.4.6/play-server_2.11-2.4.6.jar ... [info] [SUCCESSFUL ] com.typesafe.play#play-server_2.11;2.4.6!play-server_2.11.jar (847ms) [info] downloading https://repo1.maven.org/maven2/com/typesafe/play/play-netty-server_2.11/2.4.6/play-netty-server_2.11-2.4.6.jar ... [info] [SUCCESSFUL ] com.typesafe.play#play-netty-server_2.11;2.4.6!play-netty-server_2.11.jar (539ms) [info] downloading https://repo1.maven.org/maven2/com/typesafe/play/play-jdbc_2.11/2.4.6/play-jdbc_2.11-2.4.6.jar ... [info] [SUCCESSFUL ] com.typesafe.play#play-jdbc_2.11;2.4.6!play-jdbc_2.11.jar (430ms) [info] downloading https://repo1.maven.org/maven2/com/typesafe/play/play-cache_2.11/2.4.6/play-cache_2.11-2.4.6.jar ... [info] [SUCCESSFUL ] com.typesafe.play#play-cache_2.11;2.4.6!play-cache_2.11.jar (426ms) [info] downloading https://repo1.maven.org/maven2/com/typesafe/play/play-ws_2.11/2.4.6/play-ws_2.11-2.4.6.jar ... [info] [SUCCESSFUL ] com.typesafe.play#play-ws_2.11;2.4.6!play-ws_2.11.jar (651ms) [info] downloading https://repo1.maven.org/maven2/com/typesafe/play/play_2.11/2.4.6/play_2.11-2.4.6.jar ... [info] [SUCCESSFUL ] com.typesafe.play#play_2.11;2.4.6!play_2.11.jar (1459ms) [info] downloading https://repo1.maven.org/maven2/com/typesafe/play/play-iteratees_2.11/2.4.6/play-iteratees_2.11-2.4.6.jar ... [info] [SUCCESSFUL ] com.typesafe.play#play-iteratees_2.11;2.4.6!play-iteratees_2.11.jar (553ms) [info] downloading https://repo1.maven.org/maven2/com/typesafe/play/play-json_2.11/2.4.6/play-json_2.11-2.4.6.jar ... [info] [SUCCESSFUL ] com.typesafe.play#play-json_2.11;2.4.6!play-json_2.11.jar (552ms) [info] downloading https://repo1.maven.org/maven2/com/typesafe/play/play-netty-utils/2.4.6/play-netty-utils-2.4.6.jar ... [info] [SUCCESSFUL ] com.typesafe.play#play-netty-utils;2.4.6!play-netty-utils.jar (419ms) [info] downloading https://repo1.maven.org/maven2/com/typesafe/play/play-functional_2.11/2.4.6/play-functional_2.11-2.4.6.jar ... [info] [SUCCESSFUL ] com.typesafe.play#play-functional_2.11;2.4.6!play-functional_2.11.jar (438ms) [info] downloading https://repo1.maven.org/maven2/com/typesafe/play/play-datacommons_2.11/2.4.6/play-datacommons_2.11-2.4.6.jar ... [info] [SUCCESSFUL ] com.typesafe.play#play-datacommons_2.11;2.4.6!play-datacommons_2.11.jar (426ms) [info] downloading https://repo1.maven.org/maven2/com/typesafe/play/play-jdbc-api_2.11/2.4.6/play-jdbc-api_2.11-2.4.6.jar ... [info] [SUCCESSFUL ] com.typesafe.play#play-jdbc-api_2.11;2.4.6!play-jdbc-api_2.11.jar (424ms) [info] downloading https://repo1.maven.org/maven2/com/typesafe/play/play-test_2.11/2.4.6/play-test_2.11-2.4.6.jar ... [info] [SUCCESSFUL ] com.typesafe.play#play-test_2.11;2.4.6!play-test_2.11.jar (431ms) [info] downloading https://repo1.maven.org/maven2/com/typesafe/play/play-specs2_2.11/2.4.6/play-specs2_2.11-2.4.6.jar ... [info] [SUCCESSFUL ] com.typesafe.play#play-specs2_2.11;2.4.6!play-specs2_2.11.jar (424ms) [info] downloading https://repo1.maven.org/maven2/com/typesafe/play/play-omnidoc_2.11/2.4.6/play-omnidoc_2.11-2.4.6.jar ... [info] [SUCCESSFUL ] com.typesafe.play#play-omnidoc_2.11;2.4.6!play-omnidoc_2.11.jar (2169ms) [info] downloading https://repo1.maven.org/maven2/com/typesafe/play/play-docs_2.11/2.4.6/play-docs_2.11-2.4.6.jar ... [info] [SUCCESSFUL ] com.typesafe.play#play-docs_2.11;2.4.6!play-docs_2.11.jar (1464ms) [info] Done updating. --- (Running the application, auto-reloading is enabled) --- [info] p.c.s.NettyServer - 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...) [info] Compiling 7 Scala sources and 1 Java source to /Users/dela/Documents/develop/scala/my-first-app/target/scala-2.11/classes... [info] 'compiler-interface' not yet compiled for Scala 2.11.6. Compiling... [info] Compilation completed in 16.004 s [info] - play.api.Play - Application started (Dev)
activator ui 使ってみた。
[dela@MacBook-Air my-first-app] activator ui
脇のメニューから大体できること想像がつく。サーバーのコードをブラウザから変更できそう。
使ってみないと判断できないけど、思想は進んでる。