Locked History Actions

Diff for "sbt/Getting-Started-Summary"

Differences between revisions 1 and 2
Deletions are marked like this. Additions are marked like this.
Line 5: Line 5:
Getting Started Summary sbtを使うのに理解する必要がある概念としては少数だ。
若干のラーニングカーブはあるものの、positive sideであるし、これらの概念以外にはあまり多く無い(訳注:?)。
sbtは小さなコアコンセプトの上に、すべてを行う。
Line 7: Line 9:
    Page History
Line 9: Line 10:
Previous Getting Started Guide page 14 of 14. Getting Startedシリーズのすべてを読んだなら、もう知るべきことを知っているだろう。
Line 11: Line 12:
This page wraps up the Getting Started Guide. == sbtのコアコンセプト ==
Line 13: Line 14:
To use sbt, there are a small number of concepts you must understand. These have some learning curve, but on the positive side, there isn't much to sbt except these concepts. sbt uses a small core of powerful concepts to do everything it does. === Scalaの基本 ===
Scalaの文法に慣れておくことは疑いなく有用だ。Scalaの作者による「Programming in Scala」をおすすめしたい。
Line 15: Line 17:
If you've read the whole Getting Started series, now you know what you need to know.
sbt: The Core Concepts
=== .sbtビルド定義 ===
Line 18: Line 19:
    the basics of Scala. It's undeniably helpful to be familiar with Scala syntax. Programming in Scala written by the creator of Scala is a great introduction.
    .sbt build definition
        your build definition is one big list of Setting objects, where a Setting transforms the set of key-value pairs sbt uses to perform tasks.
        to create a Setting, call one of a few methods on a key (the := and <<= methods are particularly important).
        there is no mutable state, only transformation; for example, a Setting transforms sbt's collection of key-value pairs into a new collection. It doesn't change anything in-place.
        each setting has a value of a particular type, determined by the key.
        tasks are special settings where the computation to produce the key's value will be re-run each time you kick off a task. Non-tasks compute the value once, when first loading the build definition.
    Scopes
        each key may have multiple values, in distinct scopes.
        scoping may use three axes: configuration, project, and task.
        scoping allows you to have different behaviors per-project, per-task, or per-configuration.
        a configuration is a kind of build, such as the main one (Compile) or the test one (Test).
        the per-project axis also supports "entire build" scope.
        scopes fall back to or delegate to more general scopes.
    .sbt vs. .scala build definition
君のビルド定義は、Settingオブジェクトからなる一つの大きなリストであり、
それぞれのSettingは、sbtがタスクを実行する際に用いるキー・値ペアの集合を変換する。
Settingを作成するには、キーに対して、いくつかあるメソッドのうちの一つを使う(:=と<<=メソッドが特に重要だ)。

ミュータブルな状態というものはなく、変換だけだ。例えば、Settingはsbtのキー・値ペアのコレクションを変換して、新しいコレクションを作成する。
その場で変更されるということはない。

それぞれのSettingは特有のタイプを持ち、それはキーによって決定される。
タスクは特別なSettingであり、タスクを起動されるたびに計算を行い、キーの値を生成する。
タスクでないものは、値を一度だけ計算する、ビルド定義がロードされたときに。

=== スコープ ===

各キーは、異なるスコープについて異なる値を持ちうる。
スコープには三つの軸がある。コンフィギュレーション、プロジェクト、タスクだ。
スコーピングによって、プロジェクト毎、タスク毎、コンフィギュレーション毎に異なる振る舞いをさせることができる。

コンフィギュレーションとはビルドの種類である。メインのもの(Compile)あるいはテスト用のもの(Test)のような。

プロジェクト軸は「全体ビルド」スコープもサポートしている。

スコープは、より一般的なスコープにフォールバックする、あるいは委譲することがある。

=== .sbt vs. .scalaビルド定義 ===
Line 35: Line 46:
    Plugins are extensions to the build definition
===
Plugins are extensions to the build definition ===

サマリ

https://github.com/harrah/xsbt/wiki/Getting-Started-Summaryの訳(2011/10/30時点)

sbtを使うのに理解する必要がある概念としては少数だ。 若干のラーニングカーブはあるものの、positive sideであるし、これらの概念以外にはあまり多く無い(訳注:?)。 sbtは小さなコアコンセプトの上に、すべてを行う。

Getting Startedシリーズのすべてを読んだなら、もう知るべきことを知っているだろう。

sbtのコアコンセプト

Scalaの基本

Scalaの文法に慣れておくことは疑いなく有用だ。Scalaの作者による「Programming in Scala」をおすすめしたい。

.sbtビルド定義

君のビルド定義は、Settingオブジェクトからなる一つの大きなリストであり、 それぞれのSettingは、sbtがタスクを実行する際に用いるキー・値ペアの集合を変換する。 Settingを作成するには、キーに対して、いくつかあるメソッドのうちの一つを使う(:=と<<=メソッドが特に重要だ)。

ミュータブルな状態というものはなく、変換だけだ。例えば、Settingはsbtのキー・値ペアのコレクションを変換して、新しいコレクションを作成する。 その場で変更されるということはない。

それぞれのSettingは特有のタイプを持ち、それはキーによって決定される。 タスクは特別なSettingであり、タスクを起動されるたびに計算を行い、キーの値を生成する。 タスクでないものは、値を一度だけ計算する、ビルド定義がロードされたときに。

スコープ

各キーは、異なるスコープについて異なる値を持ちうる。 スコープには三つの軸がある。コンフィギュレーション、プロジェクト、タスクだ。 スコーピングによって、プロジェクト毎、タスク毎、コンフィギュレーション毎に異なる振る舞いをさせることができる。

コンフィギュレーションとはビルドの種類である。メインのもの(Compile)あるいはテスト用のもの(Test)のような。

プロジェクト軸は「全体ビルド」スコープもサポートしている。

スコープは、より一般的なスコープにフォールバックする、あるいは委譲することがある。

.sbt vs. .scalaビルド定義

  • put most of your settings in build.sbt, but use .scala build definition files to define multiple subprojects, and to factor out common values, objects, and methods. the build definition is an sbt project in its own right, rooted in the project directory.

Plugins are extensions to the build definition

  • add plugins with the addSbtPlugin method in project/build.sbt (NOT build.sbt in the project's base directory).

If any of this leaves you wondering rather than nodding, please ask for help on the mailing list, go back and re-read, or try some experiments in sbt's interactive mode.

Good luck! Advanced Notes

The rest of this wiki consists of deeper dives and less-commonly-needed information.

Since sbt is open source, don't forget you can check out the source code too!