Scalaビルドツールsbt(simple build tool)のティップス
Scala導入ティップスの記事でも紹介したsbtについて、別途ここで纏めます。
sbtリファレンス
https://www.scala-sbt.org/1.x/docs/
参考ブログ: sbt
SDKMANによるインストール
https://sdkman.io/install
SDKMANのインストールについてもScala導入ティップスの記事を参照して下さい。
インストールするsbtのバージョンを確認します。
$sdk list sbt
================================================================================
Available Sbt Versions
================================================================================
1.4.4 1.3.4 1.1.2
1.4.3 1.3.3 1.1.1
1.4.2 1.3.1 1.1.0
1.4.1 1.3.0 * 1.0.4
1.4.0 1.2.8 1.0.3
1.4.0-RC2 1.2.7 1.0.2
* 1.3.13 1.2.6 1.0.1
1.3.12 1.2.5 1.0.0
1.3.11 1.2.4 > * 0.13.18
1.3.10 1.2.3 0.13.17
1.3.9 1.2.1
1.3.8 1.2.0
1.3.7 1.1.6
1.3.6 1.1.5
1.3.5 1.1.4
================================================================================
+ - local version
* - installed
> - currently in use
複数バージョンのインストールが可能です。バージョンの切り換えは、バージョンを指定して defaultコマンド で行います。
$sdk default sbt 1.3.13
sdkヘルプ一覧
Usage: sdk <command> [candidate] [version]
sdk offline <enable|disable>
commands:
install or i <candidate> [version] [local-path]
uninstall or rm <candidate> <version>
list or ls [candidate]
use or u <candidate> <version>
default or d <candidate> [version]
home or h <candidate> <version>
env or e [init]
current or c [candidate]
upgrade or ug [candidate]
version or v
broadcast or b
help
offline [enable|disable]
selfupdate [force]
update
flush [archives|tmp|broadcast|version]
candidate : the SDK to install: groovy, scala, grails, gradle, kotlin, etc.
use list command for comprehensive list of candidates
eg: $ sdk list
version : where optional, defaults to latest stable if not provided
eg: $ sdk install groovy
local-path : optional path to an existing local installation
eg: $ sdk install groovy 2.4.13-local /opt/groovy-2.4.13
sbtシェルからscalaシェルへ
$ sbt console
scala>
またはsbtにてsbtシェル起動後consoleコマンドを入力
$ sbt
[info] welcome to sbt 1.3.13 (AdoptOpenJDK Java 11.0.9.1)
[info] loading global plugins from /home/takanobu/.sbt/1.0/plugins
[info] loading settings for project chapter-cluster-build from plugins.sbt ...
[info] loading project definition from /home/takanobu/IdeaProjects/akka-in-action/chapter-cluster/project
[info] loading settings for project chapter-cluster from scala.sbt,build.sbt ...
[info] set current project to words-cluster (in build file:/home/takanobu/IdeaProjects/akka-in-action/chapter-cluster/)
[info] sbt server started at local:///home/takanobu/.sbt/1.0/server/540c81ed307cf8174db4/sock
sbt:words-cluster> console
[info] Compiling 6 Scala sources to /home/takanobu/IdeaProjects/akka-in-action/chapter-cluster/target/scala-2.13/classes ...
[info] Non-compiled module 'compiler-bridge_2.13' for Scala 2.13.4. Compiling...
[info] Compilation completed in 18.928s.
[info] Starting scala interpreter...
Welcome to Scala 2.13.4 (OpenJDK 64-Bit Server VM, Java 11.0.9.1).
Type in expressions for evaluation. Or try :help.
scala>