![]() Scala program runs on top of Java Virtual Machine. Scala is an acronym for “Scalable Language” *. '% "1.13.1"' > build.sbt Print all BBC News headlines mkdir -p src/main/scala/Ĭat > src/main/scala/SimpleApp.scala << EOFįor feedback, or to subscribe, go to the Feedback form or the Subscription form.Scala is a general-purpose programming language it supports both functional programming and Objects oriented programming paradigm. Src/main/scala/SimpleApp.scala Run the app with arguments sbt "run - 123" Explicitly name the project echo 'name := "new-project"' > build.sbt Explicitly version the project echo 'version := "0.2"' > build.sbt Add JSoup Java library to main project echo 'libraryDependencies = "org.jsoup" % "jsoup"' \ '%% "scalatest" % "3.2.6" % Test)' > build.sbt Continually test the submodule sbt '~fizzbuzz/test' Create a method in the submodule mkdir -p fizzbuzz/src/main/scala/Ĭat > fizzbuzz/src/main/scala/Fizz.scala fizzbuzz/src/test/scala/FizzTest.scala > build.sbt Use the submodule in the app sed -i -e 's/".*"/Fizz.buzz()/'\ settings(libraryDependencies = "org.scalatest"' \ Run the docker image docker run new-project:0.1.0-SNAPSHOT Create a submodule echo 'lazy val fizzbuzz = project' > build.sbt Compile the submodule sbt fizzbuzz/compile Add ScalaTest to submodule echo '. tmp/my-project/new-project-0.1.0-SNAPSHOT/bin/new-project Dockerize your app sbt docker:publishLocal target/universal/new-project-0.1.0-SNAPSHOT.zip > project/plugins.sbt Enable sbt-native-packager echo 'enablePlugins(JavaAppPackaging)' > build.sbt Package the app sbt 'show dist' Run packaged app unzip -o -d /tmp/my-project \ ![]() mkdir -p src/main/scala/Ĭat > src/main/scala/SimpleApp.scala > build.sbt Create a test mkdir -p src/test/scala/Ĭat > src/test/scala/SimpleTest.scala > build.sbt Add the sbt-native-packager plugin echo 'addSbtPlugin("" % '\ Run this command in another terminal window. December 13, 2016: Add references and a changelogĬreate a basic empty SBT project mkdir -p new-projectĮcho 'sbt.version=1.4.9' > project/build.properties Compile the project sbt compile Recompile on code change sbt '~compile'.March 30, 2018: Update article to SBT 1.1.2 and other latest librariesĪdded clearer steps with the continuous stuff.Scala 2.13, ScalaTest 3.2, JSoup 1.13 improve prose and examples fix change in BBC News selectors. August 1, 2020: Update article to use screen space better update article to SBT 1.3.13,.March 16, 2021: Update article to have easier SBT installation instructions, upgrade to latest versions update prose.sbt-native-packager: Code once, deploy anywhere.Table of Contents Toggle Index / Table of Contents Scala Algorithms, the most comprehensive collection of pure Scala algorithms.Īlternatively, email me: Subscribe to updates.Like/Retweet if you found this useful! :-)Įssential #SBT for #Scala - William Narmontas DecemYouTube video My other Scala content Once you've set up the prerequisites and have, simply follow the instructions below and let me know of any feedback in the feedback form! And if you'd like more content like this, subscribe. Linux: follow instructions here: Installing SBT on Linux.macOS: install with Homebrew: brew install sbt.Windows: install with Chocolatey: choco install sbt or download the MSI installer.Prerequisite: Download and install Java.Windows Subsystem for Linux and Ubuntu instructions. Shell: To run these commands you will need a Linux type shell.This means that you can get a project working from scratch without having to go to the documentation, installĬomplex IDEs, text editors, that are not always straightforward. How: I provide a sequence of snippets with a Copy button, which you can paste into a command.This tutorial is aimed to somebody who comes, say, from a Python, Java or PHP backgroundĪnd wants to see immediate results, such as creating and running unit tests, and creatingĪ deployable package from your code and using SBT modules, and how to inter-operate with a Java library to scrape the web.Īnd you can get all that done in less than 30 minutes! ![]() Let's get straight into the meat, because I assure you it is not hopeless SBT is the most powerful build tool I had ever used.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |