m_shige1979のときどきITブログ

プログラムの勉強をしながら学習したことや経験したことをぼそぼそと書いていきます

Github(変なおっさんの顔でるので気をつけてね)

https://github.com/mshige1979

scalaのフレームワークPlay2.3をインストール

scalaまだわかっていないけど空気読まずに実験してみる

まあ、気になるので…

環境

vangrantのCentOS7.x

インストールするもの

Play2.3(activator-dist-1.3.6)
※2.2とかちょっと違うようなきがするけど…

手順

Activatorのダウンロードして解凍
$ wget https://downloads.typesafe.com/typesafe-activator/1.3.6/typesafe-activator-1.3.6.zip
$ unzip typesafe-activator-1.3.6.zip
ディレクトリを変更してパスを設定
$ mv activator-dist-1.3.6 activator
$ echo 'export PATH=$PATH:~/activator' >> ~/.bash_profile
$ source ~/.bash_profile
$ chmod a+x activator
インストールの確認
$ 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_25")
  -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で作成してみる
$ activator new my-first-app play-scala
Getting com.typesafe.activator activator-launcher 1.3.6 ...
downloading file:/home/vagrant/activator/repository/com.typesafe.activator/activator-launcher/1.3.6/jars/activator-launcher.jar ...
	[SUCCESSFUL ] com.typesafe.activator#activator-launcher;1.3.6!activator-launcher.jar (2ms)
downloading file:/home/vagrant/activator/repository/org.scala-lang/scala-library/2.11.7/jars/scala-library.jar ...
	[SUCCESSFUL ] org.scala-lang#scala-library;2.11.7!scala-library.jar (93ms)
downloading file:/home/vagrant/activator/repository/com.typesafe.activator/activator-props/1.3.6/jars/activator-props.jar ...
	[SUCCESSFUL ] com.typesafe.activator#activator-props;1.3.6!activator-props.jar (2ms)
downloading file:/home/vagrant/activator/repository/com.typesafe.activator/activator-ui-common/1.3.6/jars/activator-ui-common.jar ...
	[SUCCESSFUL ] com.typesafe.activator#activator-ui-common;1.3.6!activator-ui-common.jar (1ms)
downloading file:/home/vagrant/activator/repository/org.scala-sbt/launcher-interface/0.13.8/jars/launcher-interface.jar ...
	[SUCCESSFUL ] org.scala-sbt#launcher-interface;0.13.8!launcher-interface.jar (2ms)
downloading file:/home/vagrant/activator/repository/org.scala-sbt/completion_2.11/0.13.8/jars/completion_2.11.jar ...
	[SUCCESSFUL ] org.scala-sbt#completion_2.11;0.13.8!completion_2.11.jar (4ms)
downloading file:/home/vagrant/activator/repository/com.typesafe.activator/activator-templates-cache/1.0-a0afb008ea619bf9d87dc010156cddffa8a6f880/jars/activator-templates-cache.jar ...
	[SUCCESSFUL ] com.typesafe.activator#activator-templates-cache;1.0-a0afb008ea619bf9d87dc010156cddffa8a6f880!activator-templates-cache.jar (3ms)
downloading file:/home/vagrant/activator/repository/com.typesafe.activator/activator-common/1.0-a0afb008ea619bf9d87dc010156cddffa8a6f880/jars/activator-common.jar ...
	[SUCCESSFUL ] com.typesafe.activator#activator-common;1.0-a0afb008ea619bf9d87dc010156cddffa8a6f880!activator-common.jar (3ms)
downloading file:/home/vagrant/activator/repository/org.scala-lang.modules/scala-xml_2.11/1.0.1/bundles/scala-xml_2.11.jar ...
	[SUCCESSFUL ] org.scala-lang.modules#scala-xml_2.11;1.0.1!scala-xml_2.11.jar(bundle) (24ms)
downloading file:/home/vagrant/activator/repository/org.scala-lang.modules/scala-parser-combinators_2.11/1.0.1/bundles/scala-parser-combinators_2.11.jar ...
	[SUCCESSFUL ] org.scala-lang.modules#scala-parser-combinators_2.11;1.0.1!scala-parser-combinators_2.11.jar(bundle) (5ms)
downloading file:/home/vagrant/activator/repository/org.apache.lucene/lucene-core/4.3.0/jars/lucene-core.jar ...
	[SUCCESSFUL ] org.apache.lucene#lucene-core;4.3.0!lucene-core.jar (80ms)
downloading file:/home/vagrant/activator/repository/org.apache.lucene/lucene-analyzers-common/4.3.0/jars/lucene-analyzers-common.jar ...
	[SUCCESSFUL ] org.apache.lucene#lucene-analyzers-common;4.3.0!lucene-analyzers-common.jar (48ms)
downloading file:/home/vagrant/activator/repository/org.apache.lucene/lucene-queryparser/4.3.0/jars/lucene-queryparser.jar ...
	[SUCCESSFUL ] org.apache.lucene#lucene-queryparser;4.3.0!lucene-queryparser.jar (20ms)
downloading file:/home/vagrant/activator/repository/com.typesafe.akka/akka-actor_2.11/2.3.9/jars/akka-actor_2.11.jar ...
	[SUCCESSFUL ] com.typesafe.akka#akka-actor_2.11;2.3.9!akka-actor_2.11.jar (51ms)
downloading file:/home/vagrant/activator/repository/com.amazonaws/aws-java-sdk/1.3.29/jars/aws-java-sdk.jar ...
	[SUCCESSFUL ] com.amazonaws#aws-java-sdk;1.3.29!aws-java-sdk.jar (131ms)
downloading file:/home/vagrant/activator/repository/org.apache.commons/commons-compress/1.4.1/jars/commons-compress.jar ...
	[SUCCESSFUL ] org.apache.commons#commons-compress;1.4.1!commons-compress.jar (37ms)
downloading file:/home/vagrant/activator/repository/org.tukaani/xz/1.0/jars/xz.jar ...
	[SUCCESSFUL ] org.tukaani#xz;1.0!xz.jar (34ms)
downloading file:/home/vagrant/activator/repository/org.apache.lucene/lucene-queries/4.3.0/jars/lucene-queries.jar ...
	[SUCCESSFUL ] org.apache.lucene#lucene-queries;4.3.0!lucene-queries.jar (11ms)
downloading file:/home/vagrant/activator/repository/org.apache.lucene/lucene-sandbox/4.3.0/jars/lucene-sandbox.jar ...
	[SUCCESSFUL ] org.apache.lucene#lucene-sandbox;4.3.0!lucene-sandbox.jar (13ms)
downloading file:/home/vagrant/activator/repository/jakarta-regexp/jakarta-regexp/1.4/jars/jakarta-regexp.jar ...
	[SUCCESSFUL ] jakarta-regexp#jakarta-regexp;1.4!jakarta-regexp.jar (4ms)
downloading file:/home/vagrant/activator/repository/com.typesafe/config/1.2.1/bundles/config.jar ...
	[SUCCESSFUL ] com.typesafe#config;1.2.1!config.jar(bundle) (32ms)
downloading file:/home/vagrant/activator/repository/commons-logging/commons-logging/1.1.1/jars/commons-logging.jar ...
	[SUCCESSFUL ] commons-logging#commons-logging;1.1.1!commons-logging.jar (40ms)
downloading file:/home/vagrant/activator/repository/org.apache.httpcomponents/httpclient/4.1/jars/httpclient.jar ...
	[SUCCESSFUL ] org.apache.httpcomponents#httpclient;4.1!httpclient.jar (21ms)
downloading file:/home/vagrant/activator/repository/commons-codec/commons-codec/1.3/jars/commons-codec.jar ...
	[SUCCESSFUL ] commons-codec#commons-codec;1.3!commons-codec.jar (20ms)
downloading file:/home/vagrant/activator/repository/org.codehaus.jackson/jackson-core-asl/1.8.9/jars/jackson-core-asl.jar ...
	[SUCCESSFUL ] org.codehaus.jackson#jackson-core-asl;1.8.9!jackson-core-asl.jar (23ms)
downloading file:/home/vagrant/activator/repository/org.codehaus.jackson/jackson-mapper-asl/1.8.9/jars/jackson-mapper-asl.jar ...
	[SUCCESSFUL ] org.codehaus.jackson#jackson-mapper-asl;1.8.9!jackson-mapper-asl.jar (26ms)
downloading file:/home/vagrant/activator/repository/org.apache.httpcomponents/httpcore/4.1/jars/httpcore.jar ...
	[SUCCESSFUL ] org.apache.httpcomponents#httpcore;4.1!httpcore.jar (38ms)
downloading file:/home/vagrant/activator/repository/org.scala-sbt/collections_2.11/0.13.8/jars/collections_2.11.jar ...
	[SUCCESSFUL ] org.scala-sbt#collections_2.11;0.13.8!collections_2.11.jar (26ms)
downloading file:/home/vagrant/activator/repository/org.scala-sbt/control_2.11/0.13.8/jars/control_2.11.jar ...
	[SUCCESSFUL ] org.scala-sbt#control_2.11;0.13.8!control_2.11.jar (3ms)
downloading file:/home/vagrant/activator/repository/org.scala-sbt/io_2.11/0.13.8/jars/io_2.11.jar ...
	[SUCCESSFUL ] org.scala-sbt#io_2.11;0.13.8!io_2.11.jar (27ms)
:: retrieving :: org.scala-sbt#boot-app
	confs: [default]
	30 artifacts copied, 0 already retrieved (20006kB/142ms)
Getting Scala 2.11.7 (for activator-launcher)...
downloading file:/home/vagrant/activator/repository/org.scala-lang/scala-compiler/2.11.7/jars/scala-compiler.jar ...
	[SUCCESSFUL ] org.scala-lang#scala-compiler;2.11.7!scala-compiler.jar (219ms)
downloading file:/home/vagrant/activator/repository/org.scala-lang/scala-reflect/2.11.7/jars/scala-reflect.jar ...
	[SUCCESSFUL ] org.scala-lang#scala-reflect;2.11.7!scala-reflect.jar (62ms)
downloading file:/home/vagrant/activator/repository/org.scala-lang.modules/scala-xml_2.11/1.0.4/bundles/scala-xml_2.11.jar ...
	[SUCCESSFUL ] org.scala-lang.modules#scala-xml_2.11;1.0.4!scala-xml_2.11.jar(bundle) (135ms)
downloading file:/home/vagrant/activator/repository/org.scala-lang.modules/scala-parser-combinators_2.11/1.0.4/bundles/scala-parser-combinators_2.11.jar ...
	[SUCCESSFUL ] org.scala-lang.modules#scala-parser-combinators_2.11;1.0.4!scala-parser-combinators_2.11.jar(bundle) (15ms)
downloading file:/home/vagrant/activator/repository/jline/jline/2.12.1/jars/jline.jar ...
	[SUCCESSFUL ] jline#jline;2.12.1!jline.jar (19ms)
:: retrieving :: org.scala-sbt#boot-scala
	confs: [default]
	6 artifacts copied, 0 already retrieved (26223kB/80ms)

Fetching the latest list of templates...

OK, application "my-first-app" is being created using the "play-scala" template.

To run "my-first-app" from the command line, "cd my-first-app" then:
/home/vagrant/my-first-app/activator run

To run the test for "my-first-app" from the command line, "cd my-first-app" then:
/home/vagrant/my-first-app/activator test

To run the Activator UI for "my-first-app" from the command line, "cd my-first-app" then:
/home/vagrant/my-first-app/activator ui

$

※なんかいろいろダウンロードしました

ディレクトリを移動して実行
$ cd my-first-app/
$ activator run

ながいので割愛

[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...)
ファイアウォールは一応止めておく
$ systemctl stop firewalld
画面

f:id:m_shige1979:20151102220539p:plain

ここまで

所感

ディレクトリをツリーでみたけど結構でかいんであとで見よう
最初の初期化に相当時間を使うけどそれがおわればなんとかなりそうかも…
なんかコンパイルが遅いって聞いたけど実際知らないのでいろいろ試さないといけないし…