SBT简介

一、关于SBT

SBT是一个现代构建工具。它是用Scala编写的,并且针对Scala也提供了很多方便快捷的功能。它也是一个通用的构建工具。

二、为什么使用SBT

  • 强大的依赖管理功能
    • Ivy用来管理依赖
    • 一个只会根据需求更新的模型
  • 所有任务的创建都支持Scala
  • 可连续执行命令
  • 可以在工程的上下文里启动REPL

三、SBT工程目录结构

HelloWorld	(base directory)
|__ src		(source code directory)
|      |__ main
|      |      |__ scala	(main scala sources)
|      |      |__ resources	(files to include in main jar here)
|      |      |__ java	(main java sources)
|      |
|      |__ test
|             |__ scala	(test scala sources)
|             |__ resources	(files to include in test jar here)
|             |__ java	(test java sources)
|      
|__ project
|      |__ build.properties	(version definition for SBT)
|      |__ plugins.sbt	(Declaring  plugins)
|
|__ build.sbt	(sbt build definition files)
|
|__ lib		(unmanaged dependencies)
|
|__ target	(generated files, like compiled classes, packaged jars, managed files, caches, and documentation)
|
|__ .gitignore	(Configuring version control)

四、SBT交互模式

在项目目录下运行sbt命令进行交互模式

sbt

在交互模式中能够运行常见的命令,例如,进行compile

>compile

其它常见命令

commanddescription
cleanDeletes all generated files (in the target directory).
compileCompiles the main sources (in src/main/scala and src/main/java directories).
testCompiles and runs all tests.
consoleStarts the Scala interpreter with a classpath including the compiled sources and all dependencies. To return to sbt, type :quit, Ctrl+D (Unix), or Ctrl+Z (Windows).
run <argument>*Runs the main class for the project in the same virtual machine as sbt.
packageCreates a jar file containing the files in src/main/resources and the classes compiled from src/main/scala and src/main/java.
help <command>Displays detailed help for the specified command. If no command is provided, displays brief descriptions of all commands.
reloadReloads the build definition (build.sbt, project/.scala, project/.sbt files). Needed if you change the build definition.

具体可参考:
https://www.scala-sbt.org/1.x/docs/Running.html
https://www.scala-sbt.org/1.x/docs/Command-Line-Reference.html

  • 3
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值