SlideShare a Scribd company logo
1 of 19
Sbt + giter8



         2012-12-04
まず何より先に…
  1. sbt インストール
  2. sbt 起動
  3. giter8 インストール
  4. giter8 起動



できてます?
結構時間がかかるのでまだの方はお早めに
・ 伊藤 学
  技術開発部開発課
  scala をお仕事で使い始めて 1 ヶ月未満

・ カメラ
  水槽の魚写すカメラほしくてそろそろ買う
  詳しい人に相談したらさっぱり分からん
    買っても使いこなせるのか・・?
使ってみる前に
 まだ実用化していないけど業務で調査実験したの
 を
 ご紹介
そのときは sbt なんてしらな
かった
 名前だけは知ってました



 Oracle から読み込んでメールを送信するバッチの
 Replace

 ・ scala でバッチ作ろう
 ・ play! で管理画面作ろう
そのバッチのほうの調査

 DB へのアクセス
 できるかどうか
 書いてみた
そのバッチを動かすために
・ squeryl つかうので squeryl_2.9.0-0.9.4.jar をダウンロード
・ cglib も必要みたいなので cglib-nodep-2.2.3.jar をダウン
ロード

そしたらコマンド叩く
scala -classpath ./jars/squeryl_2.9.0-
0.9.4.jar:./jars/ojdbc14.jar:./jars/cglib-nodep-2.2.3.jar
OracleTest3.scala
動かせた!と経験者に報告

・「 sbt つかってないからデプロイ大変そうですね」


・!?

・ sbt?
・ sbt/htmlmailsender-
project/project/HtmlmailsenderProjectBuild.scala を修正
・ sbt だとこれで OK

$ ~/sbt/htmlmailsender-project/
$ sbt run




                                  ご紹介終わり
Sbt って?


・ドキュメント
   http://www.scala-sbt.org/
・ BuildTool です  ant とかと一緒

・ 設定ファイルが xml じゃなくて scala のコード
・ 依存ライブラリの追加が簡単
・ scala のバージョンが異なるプロジェクトの管理が楽
ここからはみんなで!

・ sbt で log4j つかってログを吐いてみるバッチ

を作ってみよう
[m_ito@test-a8-mayuyu sbt]$ mkdir ss27
[m_ito@test-a8-mayuyu sbt]$ cd ss27/
[m_ito@test-a8-mayuyu ss27]$ g8 typesafehub/scala-sbt   時間かかるときありますけ
Scala Project Using sbt
                                                        ど、 Enter 押すと勝手に答
                                                        えちゃうのでじっと我慢!
organization [org.example]:
name [Scala Project]: log4jproject
scala_version [2.9.2]:
version [0.1-SNAPSHOT]:

Applied typesafehub/scala-sbt.g8 in log4jproject

[m_ito@test-a8-mayuyu ss27]$ cd log4jproject/
[m_ito@test-a8-mayuyu log4jproject]$ tree
.
|-- README
|-- project
| `-- Log4jprojectBuild.scala
`-- src
    `-- main
       `-- scala
          `-- org
             `-- example
                `-- Log4jproject.scala

6 directories, 3 files
[m_ito@test-a8-mayuyu log4jproject]$ sbt run
[info] Loading project definition from /home/m_ito/sbt/ss27/log4jproject/project
[info] Updating {file:/home/m_ito/sbt/ss27/log4jproject/project/}default-149fc3...
[info] Resolving org.scala-sbt#sbt_2.9.1;0.11.3 ...
.
.
.
[info] Resolving org.scala-sbt#precompiled-2_9_2;0.11.3 ...
[info] Done updating.
[info] Compiling 1 Scala source to /home/m_ito/sbt/ss27/log4jproject/project/target/scala-2.9.1/sbt-0.11.3/classes...
[info] Set current project to log4jproject (in build file:/home/m_ito/sbt/ss27/log4jproject/)
[info] Updating {file:/home/m_ito/sbt/ss27/log4jproject/}log4jproject...
[info] Resolving org.scala-lang#scala-library;2.9.2 ...
[info] Done updating.
[info] Compiling 1 Scala source to /home/m_ito/sbt/ss27/log4jproject/target/scala-2.9.2/classes...
[info] Running org.example.Log4jproject
Hello, log4jproject
[success] Total time: 6 s, completed 2012/11/20 16:12:08
[m_ito@test-a8-mayuyu log4jproject]$
[m_ito@test-a8-mayuyu log4jproject]$ cat src/main/scala/org/example/Log4jproject.scala
package org.example

object Log4jproject extends App {
  println("Hello, log4jproject")
}
[m_ito@test-a8-mayuyu log4jproject]$
[m_ito@test-a8-mayuyu log4jproject]$ cat project/Log4jprojectBuild.scala
import sbt._
import sbt.Keys._

object Log4jprojectBuild extends Build {

 lazy val log4jproject = Project(
   id = "log4jproject",
   base = file("."),
   settings = Project.defaultSettings ++ Seq(
     name := "log4jproject",
     organization := "org.example",
     version := "0.1-SNAPSHOT",
     scalaVersion := "2.9.2",
     // add other settings here
     libraryDependencies ++= Seq(                            コレクションの要素追加し
       "log4j" %"log4j" % "1.2.16"
     )                                                       ているので、カンマ忘れず
   )                                                               に
 )
}
[m_ito@test-a8-mayuyu log4jproject]$
[m_ito@test-a8-mayuyu log4jproject]$ sbt run
[info] Loading project definition from /home/m_ito/sbt/ss27/log4jproject/project
[info] Compiling 1 Scala source to /home/m_ito/sbt/ss27/log4jproject/project/target/scala-2.9.1/sbt-0.11.3/classes...
[info] Set current project to log4jproject (in build file:/home/m_ito/sbt/ss27/log4jproject/)
[info] Updating {file:/home/m_ito/sbt/ss27/log4jproject/}log4jproject...
[info] Resolving org.scala-lang#scala-library;2.9.2 ...
[info] Resolving log4j#log4j;1.2.16 ...
[info] downloading http://repo1.maven.org/maven2/log4j/log4j/1.2.16/log4j-1.2.16.jar ...
[info] [SUCCESSFUL ] log4j#log4j;1.2.16!log4j.jar(bundle) (163ms)
[info] Done updating.
[info] Running org.example.Log4jproject
Hello, log4jproject
[success] Total time: 2 s, completed 2012/11/20 16:26:16
[m_ito@test-a8-mayuyu log4jproject]$
                                                                                    Log4j のダウンロー
                                                                                     ドしてくれる
[m_ito@test-a8-mayuyu log4jproject]$ cat src/main/scala/org/example/Log4jproject.scala
package org.example
import org.apache.log4j.Logger;
object Log4jproject extends App {
  //println("Hello, log4jproject")
  val logger: Logger = Logger.getLogger(this.getClass.getName)
  logger.info("info log test")                                                    Log4j 使ってみるコード
  logger.warn("warn log test")                                                               書いてみる
  logger.debug("debug log test")
}
[m_ito@test-a8-mayuyu log4jproject]$ sbt compile
[info] Loading project definition from /home/m_ito/sbt/ss27/log4jproject/project
[info] Set current project to log4jproject (in build file:/home/m_ito/sbt/ss27/log4jproject/)
[info] Compiling 1 Scala source to /home/m_ito/sbt/ss27/log4jproject/target/scala-2.9.2/classes...
[success] Total time: 4 s, completed 2012/11/20 16:45:48
[m_ito@test-a8-mayuyu log4jproject]$
[m_ito@test-a8-mayuyu log4jproject]$ mkdir –p src/main/resources
[m_ito@test-a8-mayuyu log4jproject]$ vi src/main/resources/log4j.properties
[m_ito@test-a8-mayuyu log4jproject]$ cat src/main/resources/log4j.properties
log4j.debug=true
log4j.rootCategory=DEBUG, file
log4j.appender.file=org.apache.log4j.FileAppender
                                                                                               Log4jproperties を
log4j.appender.file.File=/tmp/test.log                                                           忘れてました
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d %-5p %c - %m [%t] (%F:%L)%n
[m_ito@test-a8-mayuyu log4jproject]$
動かしてみる

[m_ito@test-a8-mayuyu log4jproject]$ sbt run
[info] Loading project definition from /home/m_ito/sbt/ss27/log4jproject/project
[info] Set current project to log4jproject (in build file:/home/m_ito/sbt/ss27/log4jproject/)
[info] Compiling 1 Scala source to /home/m_ito/sbt/ss27/log4jproject/target/scala-2.9.2/classes...
[info] Running org.example.Log4jproject
log4j: Parsing for [root] with value=[DEBUG, file].
log4j: Level token is [DEBUG].
log4j: Category root set to DEBUG
log4j: Parsing appender named "file".
log4j: Parsing layout options for "file".
log4j: Setting property [conversionPattern] to [%d [%-5p] %c{1} %M - %m%n].
log4j: End of parsing for "file".
log4j: Setting property [file] to [/tmp/test.log].
log4j: setFile called: /tmp/test.log, true
log4j: setFile ended
log4j: Parsed "file" options.
log4j: Finished configuring.
[success] Total time: 5 s, completed 2012/11/20 17:39:44                                      ログ見てみる
[m_ito@test-a8-mayuyu log4jproject]$ cat /tmp/test.log
2012-11-20 17:45:39,848 INFO org.example.Log4jproject$ - info log test [run-main] (Log4jproject.scala:14)
2012-11-20 17:45:39,850 WARN org.example.Log4jproject$ - warn log test [run-main] (Log4jproject.scala:15)
2012-11-20 17:45:39,851 DEBUG org.example.Log4jproject$ - debug log test [run-main] (Log4jproject.scala:16)
[m_ito@test-a8-mayuyu log4jproject]$
まとめ
Sbt 使うと

必要なライブラリ落としてきてくれるのでデプロイが楽そう。

実行とかのコマンドがみじかくなりますよ。




                       終わり

More Related Content

What's hot

Datasets and tools_from_ncbi_and_elsewhere_for_microbiome_research_v_62817
Datasets and tools_from_ncbi_and_elsewhere_for_microbiome_research_v_62817Datasets and tools_from_ncbi_and_elsewhere_for_microbiome_research_v_62817
Datasets and tools_from_ncbi_and_elsewhere_for_microbiome_research_v_62817Ben Busby
 
MySQL Audit using Percona audit plugin and ELK
MySQL Audit using Percona audit plugin and ELKMySQL Audit using Percona audit plugin and ELK
MySQL Audit using Percona audit plugin and ELKYoungHeon (Roy) Kim
 
InfluxDB IOx Tech Talks: Intro to the InfluxDB IOx Read Buffer - A Read-Optim...
InfluxDB IOx Tech Talks: Intro to the InfluxDB IOx Read Buffer - A Read-Optim...InfluxDB IOx Tech Talks: Intro to the InfluxDB IOx Read Buffer - A Read-Optim...
InfluxDB IOx Tech Talks: Intro to the InfluxDB IOx Read Buffer - A Read-Optim...InfluxData
 
Oracle applications 11i hot backup cloning with rapid clone
Oracle applications 11i hot backup cloning with rapid cloneOracle applications 11i hot backup cloning with rapid clone
Oracle applications 11i hot backup cloning with rapid cloneDeepti Singh
 
Oracle applications 11i hot backup cloning with rapid clone
Oracle applications 11i hot backup cloning with rapid cloneOracle applications 11i hot backup cloning with rapid clone
Oracle applications 11i hot backup cloning with rapid cloneDeepti Singh
 
OpenStack for Centos
OpenStack for CentosOpenStack for Centos
OpenStack for CentosChandan Kumar
 
Crs issue commands
Crs issue commandsCrs issue commands
Crs issue commandsraviranchi02
 
Apache Spark - Dataframes & Spark SQL - Part 2 | Big Data Hadoop Spark Tutori...
Apache Spark - Dataframes & Spark SQL - Part 2 | Big Data Hadoop Spark Tutori...Apache Spark - Dataframes & Spark SQL - Part 2 | Big Data Hadoop Spark Tutori...
Apache Spark - Dataframes & Spark SQL - Part 2 | Big Data Hadoop Spark Tutori...CloudxLab
 
HADOOP 실제 구성 사례, Multi-Node 구성
HADOOP 실제 구성 사례, Multi-Node 구성HADOOP 실제 구성 사례, Multi-Node 구성
HADOOP 실제 구성 사례, Multi-Node 구성Young Pyo
 
Rman cloning when both directory and db name are same.
Rman cloning when both directory and db name are same.Rman cloning when both directory and db name are same.
Rman cloning when both directory and db name are same.subhani shaik
 
glance replicator
glance replicatorglance replicator
glance replicatoririx_jp
 
Big Data Day LA 2016/ Big Data Track - Fluentd and Embulk: Collect More Data,...
Big Data Day LA 2016/ Big Data Track - Fluentd and Embulk: Collect More Data,...Big Data Day LA 2016/ Big Data Track - Fluentd and Embulk: Collect More Data,...
Big Data Day LA 2016/ Big Data Track - Fluentd and Embulk: Collect More Data,...Data Con LA
 
Getting started in Apache Spark and Flink (with Scala) - Part II
Getting started in Apache Spark and Flink (with Scala) - Part IIGetting started in Apache Spark and Flink (with Scala) - Part II
Getting started in Apache Spark and Flink (with Scala) - Part IIAlexander Panchenko
 
Basic H2O for Python with Eric Eckstrand
Basic H2O for Python with Eric EckstrandBasic H2O for Python with Eric Eckstrand
Basic H2O for Python with Eric EckstrandSri Ambati
 
Introduction to Oozie | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to Oozie | Big Data Hadoop Spark Tutorial | CloudxLabIntroduction to Oozie | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to Oozie | Big Data Hadoop Spark Tutorial | CloudxLabCloudxLab
 
InfluxDB IOx Tech Talks: Query Engine Design and the Rust-Based DataFusion in...
InfluxDB IOx Tech Talks: Query Engine Design and the Rust-Based DataFusion in...InfluxDB IOx Tech Talks: Query Engine Design and the Rust-Based DataFusion in...
InfluxDB IOx Tech Talks: Query Engine Design and the Rust-Based DataFusion in...InfluxData
 

What's hot (20)

Git Basic
Git BasicGit Basic
Git Basic
 
Datasets and tools_from_ncbi_and_elsewhere_for_microbiome_research_v_62817
Datasets and tools_from_ncbi_and_elsewhere_for_microbiome_research_v_62817Datasets and tools_from_ncbi_and_elsewhere_for_microbiome_research_v_62817
Datasets and tools_from_ncbi_and_elsewhere_for_microbiome_research_v_62817
 
MySQL Audit using Percona audit plugin and ELK
MySQL Audit using Percona audit plugin and ELKMySQL Audit using Percona audit plugin and ELK
MySQL Audit using Percona audit plugin and ELK
 
Git For Beginer
Git For BeginerGit For Beginer
Git For Beginer
 
InfluxDB IOx Tech Talks: Intro to the InfluxDB IOx Read Buffer - A Read-Optim...
InfluxDB IOx Tech Talks: Intro to the InfluxDB IOx Read Buffer - A Read-Optim...InfluxDB IOx Tech Talks: Intro to the InfluxDB IOx Read Buffer - A Read-Optim...
InfluxDB IOx Tech Talks: Intro to the InfluxDB IOx Read Buffer - A Read-Optim...
 
Oracle applications 11i hot backup cloning with rapid clone
Oracle applications 11i hot backup cloning with rapid cloneOracle applications 11i hot backup cloning with rapid clone
Oracle applications 11i hot backup cloning with rapid clone
 
Oracle applications 11i hot backup cloning with rapid clone
Oracle applications 11i hot backup cloning with rapid cloneOracle applications 11i hot backup cloning with rapid clone
Oracle applications 11i hot backup cloning with rapid clone
 
OpenStack for Centos
OpenStack for CentosOpenStack for Centos
OpenStack for Centos
 
Crs issue commands
Crs issue commandsCrs issue commands
Crs issue commands
 
Apache Spark - Dataframes & Spark SQL - Part 2 | Big Data Hadoop Spark Tutori...
Apache Spark - Dataframes & Spark SQL - Part 2 | Big Data Hadoop Spark Tutori...Apache Spark - Dataframes & Spark SQL - Part 2 | Big Data Hadoop Spark Tutori...
Apache Spark - Dataframes & Spark SQL - Part 2 | Big Data Hadoop Spark Tutori...
 
390a gitintro 12au
390a gitintro 12au390a gitintro 12au
390a gitintro 12au
 
HADOOP 실제 구성 사례, Multi-Node 구성
HADOOP 실제 구성 사례, Multi-Node 구성HADOOP 실제 구성 사례, Multi-Node 구성
HADOOP 실제 구성 사례, Multi-Node 구성
 
Rman cloning when both directory and db name are same.
Rman cloning when both directory and db name are same.Rman cloning when both directory and db name are same.
Rman cloning when both directory and db name are same.
 
Android Libs - Retrofit
Android Libs - RetrofitAndroid Libs - Retrofit
Android Libs - Retrofit
 
glance replicator
glance replicatorglance replicator
glance replicator
 
Big Data Day LA 2016/ Big Data Track - Fluentd and Embulk: Collect More Data,...
Big Data Day LA 2016/ Big Data Track - Fluentd and Embulk: Collect More Data,...Big Data Day LA 2016/ Big Data Track - Fluentd and Embulk: Collect More Data,...
Big Data Day LA 2016/ Big Data Track - Fluentd and Embulk: Collect More Data,...
 
Getting started in Apache Spark and Flink (with Scala) - Part II
Getting started in Apache Spark and Flink (with Scala) - Part IIGetting started in Apache Spark and Flink (with Scala) - Part II
Getting started in Apache Spark and Flink (with Scala) - Part II
 
Basic H2O for Python with Eric Eckstrand
Basic H2O for Python with Eric EckstrandBasic H2O for Python with Eric Eckstrand
Basic H2O for Python with Eric Eckstrand
 
Introduction to Oozie | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to Oozie | Big Data Hadoop Spark Tutorial | CloudxLabIntroduction to Oozie | Big Data Hadoop Spark Tutorial | CloudxLab
Introduction to Oozie | Big Data Hadoop Spark Tutorial | CloudxLab
 
InfluxDB IOx Tech Talks: Query Engine Design and the Rust-Based DataFusion in...
InfluxDB IOx Tech Talks: Query Engine Design and the Rust-Based DataFusion in...InfluxDB IOx Tech Talks: Query Engine Design and the Rust-Based DataFusion in...
InfluxDB IOx Tech Talks: Query Engine Design and the Rust-Based DataFusion in...
 

Viewers also liked

Pecha Kuch – Etiquette - By Sumit Kumar Ray
Pecha Kuch – Etiquette - By Sumit Kumar RayPecha Kuch – Etiquette - By Sumit Kumar Ray
Pecha Kuch – Etiquette - By Sumit Kumar RayCompassites Navigator
 
Pecha Kuch - I - By Shruti Aggarwal
 Pecha Kuch - I - By Shruti Aggarwal Pecha Kuch - I - By Shruti Aggarwal
Pecha Kuch - I - By Shruti AggarwalCompassites Navigator
 
Time in store & Impulse Buying
Time in store & Impulse BuyingTime in store & Impulse Buying
Time in store & Impulse BuyingMerve Arat
 
Pecha Kuch – Important things in life - By Mani Bharathi R
Pecha Kuch – Important things in life - By Mani Bharathi RPecha Kuch – Important things in life - By Mani Bharathi R
Pecha Kuch – Important things in life - By Mani Bharathi RCompassites Navigator
 
Assignment2-Observation
Assignment2-ObservationAssignment2-Observation
Assignment2-Observationteam13088
 
Apostila -curso_de_contabilidade_aplicada_ao_setor_pblico
Apostila  -curso_de_contabilidade_aplicada_ao_setor_pblicoApostila  -curso_de_contabilidade_aplicada_ao_setor_pblico
Apostila -curso_de_contabilidade_aplicada_ao_setor_pblicoMárcio Silveira
 
Pecha Kuch - Gestures - By Dipeeka Patil
Pecha Kuch - Gestures - By Dipeeka PatilPecha Kuch - Gestures - By Dipeeka Patil
Pecha Kuch - Gestures - By Dipeeka PatilCompassites Navigator
 
Perceptual Map
Perceptual MapPerceptual Map
Perceptual MapMerve Arat
 

Viewers also liked (13)

Pecha Kuch – Etiquette - By Sumit Kumar Ray
Pecha Kuch – Etiquette - By Sumit Kumar RayPecha Kuch – Etiquette - By Sumit Kumar Ray
Pecha Kuch – Etiquette - By Sumit Kumar Ray
 
Pecha Kuch - I - By Shruti Aggarwal
 Pecha Kuch - I - By Shruti Aggarwal Pecha Kuch - I - By Shruti Aggarwal
Pecha Kuch - I - By Shruti Aggarwal
 
Time in store & Impulse Buying
Time in store & Impulse BuyingTime in store & Impulse Buying
Time in store & Impulse Buying
 
12206571 pss7
12206571 pss712206571 pss7
12206571 pss7
 
Pecha Kuch – Important things in life - By Mani Bharathi R
Pecha Kuch – Important things in life - By Mani Bharathi RPecha Kuch – Important things in life - By Mani Bharathi R
Pecha Kuch – Important things in life - By Mani Bharathi R
 
12206571 pss7
12206571 pss712206571 pss7
12206571 pss7
 
Plants
PlantsPlants
Plants
 
Research Powerpoint
Research PowerpointResearch Powerpoint
Research Powerpoint
 
Assignment2-Observation
Assignment2-ObservationAssignment2-Observation
Assignment2-Observation
 
Apostila -curso_de_contabilidade_aplicada_ao_setor_pblico
Apostila  -curso_de_contabilidade_aplicada_ao_setor_pblicoApostila  -curso_de_contabilidade_aplicada_ao_setor_pblico
Apostila -curso_de_contabilidade_aplicada_ao_setor_pblico
 
Pecha Kuch - Gestures - By Dipeeka Patil
Pecha Kuch - Gestures - By Dipeeka PatilPecha Kuch - Gestures - By Dipeeka Patil
Pecha Kuch - Gestures - By Dipeeka Patil
 
Pecha Kuch - Coding - By Utsav Dwan
Pecha Kuch - Coding - By Utsav DwanPecha Kuch - Coding - By Utsav Dwan
Pecha Kuch - Coding - By Utsav Dwan
 
Perceptual Map
Perceptual MapPerceptual Map
Perceptual Map
 

Similar to 初心者Scala in f@n 第五回 sbt+giter8

An introduction to maven gradle and sbt
An introduction to maven gradle and sbtAn introduction to maven gradle and sbt
An introduction to maven gradle and sbtFabio Fumarola
 
Where's the source, Luke? : How to find and debug the code behind Plone
Where's the source, Luke? : How to find and debug the code behind PloneWhere's the source, Luke? : How to find and debug the code behind Plone
Where's the source, Luke? : How to find and debug the code behind PloneVincenzo Barone
 
.NET @ apache.org
 .NET @ apache.org .NET @ apache.org
.NET @ apache.orgTed Husted
 
Automating Drupal Development: Makefiles, features and beyond
Automating Drupal Development: Makefiles, features and beyondAutomating Drupal Development: Makefiles, features and beyond
Automating Drupal Development: Makefiles, features and beyondNuvole
 
Scala laboratory. Globus. iteration #1
Scala laboratory. Globus. iteration #1Scala laboratory. Globus. iteration #1
Scala laboratory. Globus. iteration #1Vasil Remeniuk
 
10 Cool Facts about Gradle
10 Cool Facts about Gradle10 Cool Facts about Gradle
10 Cool Facts about GradleEvgeny Goldin
 
Final Project Presentation
Final Project PresentationFinal Project Presentation
Final Project Presentationzroserie
 
Releasing and deploying python tools
Releasing and deploying python toolsReleasing and deploying python tools
Releasing and deploying python toolsQuintagroup
 
Package a PyApp as a Flatpak Package: An HTTP Server for Example @ PyCon APAC...
Package a PyApp as a Flatpak Package: An HTTP Server for Example @ PyCon APAC...Package a PyApp as a Flatpak Package: An HTTP Server for Example @ PyCon APAC...
Package a PyApp as a Flatpak Package: An HTTP Server for Example @ PyCon APAC...Jian-Hong Pan
 
Performance schema and_ps_helper
Performance schema and_ps_helperPerformance schema and_ps_helper
Performance schema and_ps_helperMark Leith
 
ZopeSkel & Buildout packages
ZopeSkel & Buildout packagesZopeSkel & Buildout packages
ZopeSkel & Buildout packagesQuintagroup
 
Logging & Metrics with Docker
Logging & Metrics with DockerLogging & Metrics with Docker
Logging & Metrics with DockerStefan Zier
 
Java Logging discussion Log4j,Slf4j
Java Logging discussion Log4j,Slf4jJava Logging discussion Log4j,Slf4j
Java Logging discussion Log4j,Slf4jRajiv Gupta
 
CISOA Conference 2020 Banner 9 Development
CISOA Conference 2020 Banner 9 DevelopmentCISOA Conference 2020 Banner 9 Development
CISOA Conference 2020 Banner 9 DevelopmentBrad Rippe
 

Similar to 初心者Scala in f@n 第五回 sbt+giter8 (20)

SBT Concepts, part 2
SBT Concepts, part 2SBT Concepts, part 2
SBT Concepts, part 2
 
An introduction to maven gradle and sbt
An introduction to maven gradle and sbtAn introduction to maven gradle and sbt
An introduction to maven gradle and sbt
 
Simple build tool
Simple build toolSimple build tool
Simple build tool
 
Pragmatic sbt
Pragmatic sbtPragmatic sbt
Pragmatic sbt
 
Where's the source, Luke? : How to find and debug the code behind Plone
Where's the source, Luke? : How to find and debug the code behind PloneWhere's the source, Luke? : How to find and debug the code behind Plone
Where's the source, Luke? : How to find and debug the code behind Plone
 
Intro django
Intro djangoIntro django
Intro django
 
.NET @ apache.org
 .NET @ apache.org .NET @ apache.org
.NET @ apache.org
 
Automating Drupal Development: Makefiles, features and beyond
Automating Drupal Development: Makefiles, features and beyondAutomating Drupal Development: Makefiles, features and beyond
Automating Drupal Development: Makefiles, features and beyond
 
Scala laboratory. Globus. iteration #1
Scala laboratory. Globus. iteration #1Scala laboratory. Globus. iteration #1
Scala laboratory. Globus. iteration #1
 
10 Cool Facts about Gradle
10 Cool Facts about Gradle10 Cool Facts about Gradle
10 Cool Facts about Gradle
 
Final Project Presentation
Final Project PresentationFinal Project Presentation
Final Project Presentation
 
Releasing and deploying python tools
Releasing and deploying python toolsReleasing and deploying python tools
Releasing and deploying python tools
 
Package a PyApp as a Flatpak Package: An HTTP Server for Example @ PyCon APAC...
Package a PyApp as a Flatpak Package: An HTTP Server for Example @ PyCon APAC...Package a PyApp as a Flatpak Package: An HTTP Server for Example @ PyCon APAC...
Package a PyApp as a Flatpak Package: An HTTP Server for Example @ PyCon APAC...
 
Performance schema and_ps_helper
Performance schema and_ps_helperPerformance schema and_ps_helper
Performance schema and_ps_helper
 
ZopeSkel & Buildout packages
ZopeSkel & Buildout packagesZopeSkel & Buildout packages
ZopeSkel & Buildout packages
 
Logging & Metrics with Docker
Logging & Metrics with DockerLogging & Metrics with Docker
Logging & Metrics with Docker
 
groovy & grails - lecture 13
groovy & grails - lecture 13groovy & grails - lecture 13
groovy & grails - lecture 13
 
Java Logging discussion Log4j,Slf4j
Java Logging discussion Log4j,Slf4jJava Logging discussion Log4j,Slf4j
Java Logging discussion Log4j,Slf4j
 
CISOA Conference 2020 Banner 9 Development
CISOA Conference 2020 Banner 9 DevelopmentCISOA Conference 2020 Banner 9 Development
CISOA Conference 2020 Banner 9 Development
 
Oracle API Gateway Installation
Oracle API Gateway InstallationOracle API Gateway Installation
Oracle API Gateway Installation
 

初心者Scala in f@n 第五回 sbt+giter8

  • 1. Sbt + giter8 2012-12-04
  • 2. まず何より先に… 1. sbt インストール 2. sbt 起動 3. giter8 インストール 4. giter8 起動 できてます? 結構時間がかかるのでまだの方はお早めに
  • 3. ・ 伊藤 学 技術開発部開発課 scala をお仕事で使い始めて 1 ヶ月未満 ・ カメラ 水槽の魚写すカメラほしくてそろそろ買う 詳しい人に相談したらさっぱり分からん   買っても使いこなせるのか・・?
  • 5. そのときは sbt なんてしらな かった 名前だけは知ってました Oracle から読み込んでメールを送信するバッチの Replace ・ scala でバッチ作ろう ・ play! で管理画面作ろう
  • 6. そのバッチのほうの調査 DB へのアクセス できるかどうか 書いてみた
  • 7. そのバッチを動かすために ・ squeryl つかうので squeryl_2.9.0-0.9.4.jar をダウンロード ・ cglib も必要みたいなので cglib-nodep-2.2.3.jar をダウン ロード そしたらコマンド叩く scala -classpath ./jars/squeryl_2.9.0- 0.9.4.jar:./jars/ojdbc14.jar:./jars/cglib-nodep-2.2.3.jar OracleTest3.scala
  • 10. ・ sbt だとこれで OK $ ~/sbt/htmlmailsender-project/ $ sbt run ご紹介終わり
  • 11. Sbt って? ・ドキュメント    http://www.scala-sbt.org/ ・ BuildTool です  ant とかと一緒 ・ 設定ファイルが xml じゃなくて scala のコード ・ 依存ライブラリの追加が簡単 ・ scala のバージョンが異なるプロジェクトの管理が楽
  • 12. ここからはみんなで! ・ sbt で log4j つかってログを吐いてみるバッチ を作ってみよう
  • 13. [m_ito@test-a8-mayuyu sbt]$ mkdir ss27 [m_ito@test-a8-mayuyu sbt]$ cd ss27/ [m_ito@test-a8-mayuyu ss27]$ g8 typesafehub/scala-sbt 時間かかるときありますけ Scala Project Using sbt ど、 Enter 押すと勝手に答 えちゃうのでじっと我慢! organization [org.example]: name [Scala Project]: log4jproject scala_version [2.9.2]: version [0.1-SNAPSHOT]: Applied typesafehub/scala-sbt.g8 in log4jproject [m_ito@test-a8-mayuyu ss27]$ cd log4jproject/ [m_ito@test-a8-mayuyu log4jproject]$ tree . |-- README |-- project | `-- Log4jprojectBuild.scala `-- src `-- main `-- scala `-- org `-- example `-- Log4jproject.scala 6 directories, 3 files
  • 14. [m_ito@test-a8-mayuyu log4jproject]$ sbt run [info] Loading project definition from /home/m_ito/sbt/ss27/log4jproject/project [info] Updating {file:/home/m_ito/sbt/ss27/log4jproject/project/}default-149fc3... [info] Resolving org.scala-sbt#sbt_2.9.1;0.11.3 ... . . . [info] Resolving org.scala-sbt#precompiled-2_9_2;0.11.3 ... [info] Done updating. [info] Compiling 1 Scala source to /home/m_ito/sbt/ss27/log4jproject/project/target/scala-2.9.1/sbt-0.11.3/classes... [info] Set current project to log4jproject (in build file:/home/m_ito/sbt/ss27/log4jproject/) [info] Updating {file:/home/m_ito/sbt/ss27/log4jproject/}log4jproject... [info] Resolving org.scala-lang#scala-library;2.9.2 ... [info] Done updating. [info] Compiling 1 Scala source to /home/m_ito/sbt/ss27/log4jproject/target/scala-2.9.2/classes... [info] Running org.example.Log4jproject Hello, log4jproject [success] Total time: 6 s, completed 2012/11/20 16:12:08 [m_ito@test-a8-mayuyu log4jproject]$ [m_ito@test-a8-mayuyu log4jproject]$ cat src/main/scala/org/example/Log4jproject.scala package org.example object Log4jproject extends App { println("Hello, log4jproject") } [m_ito@test-a8-mayuyu log4jproject]$
  • 15. [m_ito@test-a8-mayuyu log4jproject]$ cat project/Log4jprojectBuild.scala import sbt._ import sbt.Keys._ object Log4jprojectBuild extends Build { lazy val log4jproject = Project( id = "log4jproject", base = file("."), settings = Project.defaultSettings ++ Seq( name := "log4jproject", organization := "org.example", version := "0.1-SNAPSHOT", scalaVersion := "2.9.2", // add other settings here libraryDependencies ++= Seq( コレクションの要素追加し "log4j" %"log4j" % "1.2.16" ) ているので、カンマ忘れず ) に ) } [m_ito@test-a8-mayuyu log4jproject]$
  • 16. [m_ito@test-a8-mayuyu log4jproject]$ sbt run [info] Loading project definition from /home/m_ito/sbt/ss27/log4jproject/project [info] Compiling 1 Scala source to /home/m_ito/sbt/ss27/log4jproject/project/target/scala-2.9.1/sbt-0.11.3/classes... [info] Set current project to log4jproject (in build file:/home/m_ito/sbt/ss27/log4jproject/) [info] Updating {file:/home/m_ito/sbt/ss27/log4jproject/}log4jproject... [info] Resolving org.scala-lang#scala-library;2.9.2 ... [info] Resolving log4j#log4j;1.2.16 ... [info] downloading http://repo1.maven.org/maven2/log4j/log4j/1.2.16/log4j-1.2.16.jar ... [info] [SUCCESSFUL ] log4j#log4j;1.2.16!log4j.jar(bundle) (163ms) [info] Done updating. [info] Running org.example.Log4jproject Hello, log4jproject [success] Total time: 2 s, completed 2012/11/20 16:26:16 [m_ito@test-a8-mayuyu log4jproject]$ Log4j のダウンロー ドしてくれる
  • 17. [m_ito@test-a8-mayuyu log4jproject]$ cat src/main/scala/org/example/Log4jproject.scala package org.example import org.apache.log4j.Logger; object Log4jproject extends App { //println("Hello, log4jproject") val logger: Logger = Logger.getLogger(this.getClass.getName) logger.info("info log test") Log4j 使ってみるコード logger.warn("warn log test") 書いてみる logger.debug("debug log test") } [m_ito@test-a8-mayuyu log4jproject]$ sbt compile [info] Loading project definition from /home/m_ito/sbt/ss27/log4jproject/project [info] Set current project to log4jproject (in build file:/home/m_ito/sbt/ss27/log4jproject/) [info] Compiling 1 Scala source to /home/m_ito/sbt/ss27/log4jproject/target/scala-2.9.2/classes... [success] Total time: 4 s, completed 2012/11/20 16:45:48 [m_ito@test-a8-mayuyu log4jproject]$ [m_ito@test-a8-mayuyu log4jproject]$ mkdir –p src/main/resources [m_ito@test-a8-mayuyu log4jproject]$ vi src/main/resources/log4j.properties [m_ito@test-a8-mayuyu log4jproject]$ cat src/main/resources/log4j.properties log4j.debug=true log4j.rootCategory=DEBUG, file log4j.appender.file=org.apache.log4j.FileAppender Log4jproperties を log4j.appender.file.File=/tmp/test.log 忘れてました log4j.appender.file.layout=org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern=%d %-5p %c - %m [%t] (%F:%L)%n [m_ito@test-a8-mayuyu log4jproject]$
  • 18. 動かしてみる [m_ito@test-a8-mayuyu log4jproject]$ sbt run [info] Loading project definition from /home/m_ito/sbt/ss27/log4jproject/project [info] Set current project to log4jproject (in build file:/home/m_ito/sbt/ss27/log4jproject/) [info] Compiling 1 Scala source to /home/m_ito/sbt/ss27/log4jproject/target/scala-2.9.2/classes... [info] Running org.example.Log4jproject log4j: Parsing for [root] with value=[DEBUG, file]. log4j: Level token is [DEBUG]. log4j: Category root set to DEBUG log4j: Parsing appender named "file". log4j: Parsing layout options for "file". log4j: Setting property [conversionPattern] to [%d [%-5p] %c{1} %M - %m%n]. log4j: End of parsing for "file". log4j: Setting property [file] to [/tmp/test.log]. log4j: setFile called: /tmp/test.log, true log4j: setFile ended log4j: Parsed "file" options. log4j: Finished configuring. [success] Total time: 5 s, completed 2012/11/20 17:39:44 ログ見てみる [m_ito@test-a8-mayuyu log4jproject]$ cat /tmp/test.log 2012-11-20 17:45:39,848 INFO org.example.Log4jproject$ - info log test [run-main] (Log4jproject.scala:14) 2012-11-20 17:45:39,850 WARN org.example.Log4jproject$ - warn log test [run-main] (Log4jproject.scala:15) 2012-11-20 17:45:39,851 DEBUG org.example.Log4jproject$ - debug log test [run-main] (Log4jproject.scala:16) [m_ito@test-a8-mayuyu log4jproject]$