您的位置:首页 > 其它

Scala学习1之用sbt和脚本一步编译打包运行scala程序

2016-01-29 17:34 651 查看
用sbt和脚本一步编译打包运行scala程序

脚本:

cp /home/hadoop/cloud/scala-2.10.5/sbt/LocalScala1/build* ./
cp -r /home/hadoop/cloud/scala-2.10.5/sbt/LocalScala1/project ./
sbt compile
sbt package
sbt run


代码程序:testPrintHelloXubo.scala

//package scala2

/**
* @author xubo601450868
*/
object testPrintHelloXubo{
def main(args:Array[String]):Unit={
println("hello,scala");
println("hello,eclipse")
//     sum4(f2)(2,1);

}
def sum4(f:Int=>Int)(a:Int,b:Int)={
//     if(a>b)  return 0 else  sum4(f)(a+1,b)
}
}


cp的文件请见另外一片博文:参考【1】

运行:

hadoop@Master:~/cloud/scala-2.10.5/sbt/examples$ cp ../LocalScala1/testPrintHelloXubo.scala ./
hadoop@Master:~/cloud/scala-2.10.5/sbt/examples$ sbtRun.sh
[info] Set current project to helloworld project (in build file:/home/hadoop/cloud/scala-2.10.5/sbt/examples/)
[info] Updating {file:/home/hadoop/cloud/scala-2.10.5/sbt/examples/}examples...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Compiling 1 Scala source to /home/hadoop/cloud/scala-2.10.5/sbt/examples/target/scala-2.10/classes...
[success] Total time: 11 s, completed Jan 29, 2016 5:30:08 PM
[info] Set current project to helloworld project (in build file:/home/hadoop/cloud/scala-2.10.5/sbt/examples/)
[info] Packaging /home/hadoop/cloud/scala-2.10.5/sbt/examples/target/scala-2.10/helloworld-project_2.10-1.0.jar ...
[info] Done packaging.
[success] Total time: 2 s, completed Jan 29, 2016 5:30:15 PM
[info] Set current project to helloworld project (in build file:/home/hadoop/cloud/scala-2.10.5/sbt/examples/)
[info] Running testPrintHelloXubo
hello,scala
hello,eclipse
[success] Total time: 2 s, completed Jan 29, 2016 5:30:22 PM
hadoop@Master:~/cloud/scala-2.10.5/sbt/examples$


成功了

参考:
【1】 http://blog.csdn.net/xubo245/article/details/50603502
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息