Coder Social home page Coder Social logo

scala-sbt-tutorial's Introduction

SBT Playground

I am using this repo to document some of my experiments to understand SBT better.

Some important key concepts are (obviously) ...

  • Sub-Projects
  • Settings, Tasks, ...
  • Scopes
    • Project, Configuration, Task ...

I am (almost exclusively) use Build.scala, because it exposes the full power (and flexibility) of SBT. I am only using *.sbt to define the version (so that you have something to play around with to see how the *.sbt-files fit into it). In general I recommend to use Build.scala as much as possible, because sooner or later you will run into configuration issues, that will require you to use Build.scala and by then you want to know, how to use it.

Getting started

  • Just run > sbt to compile ./project/Build.scala
  • At the prompt run ...

    inspect show-time inspect hello-world show show-time show hell-world

  • Edit Build.scala to play around with the settings
  • Either restart sbt or run > reload to reload/recompile Build.scala

Getting into it

0.0.2

  • Explore the difference between the configuration Compile and the task compile
  • Explore if and how the build settings will override project settings
    • e.g. if there is a setting for ThisBuild in configuration Compile, then how will that become visible in sub-projects?
  • Run > inspect hello-world and try to guess what the following commands will display

    show sub-project1/:hello-world show sub-project1/compile:hello-world show sub-project1/compile:compile::hello-world show sub-project2/compile:compile::hello-world show sub-project1/:compile::hello-world show sub-project2/*:compile::hello-world

0.0.3

  • Create a dependency between show-timer and show-timer-upper
  • And apply .toUpperCase to show-timer-upper

0.0.4

  • Make sbt-assembly work
  • This shows a lot of good stuff, e.g. ...
    • How to make one task depend on another (with <<=)
    • The difference between compile, package and publish
    • How to use Artifacts (for publishing something)
  • To make it work you can run > sbt clean publish-local and can then run the jar files from the commandline (they are self-contained): > java -jar ./sub1/target/scala-2.9.2/sub-project1_2.9.2-0.0.1-assembly.jar and > java -jar ./sub2/target/scala-2.9.2/sub-project2_2.9.2-0.0.2-assembly.jar

scala-sbt-tutorial's People

Watchers

Roland Tritsch avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.