console games in Scala

The foundation of rich console application is based on physical terminal machines like VT100 from the 1970s, and ANSI X3.64 control sequences that standarized the byte sequence to control the cursor, text formats, etc. Modern terminal applications emulate the behaviors of these terminals.

Thus, if we can assume a good terminal app, all we need is an ability to println(...) the control sequences and listen for the standard input to write a rich console app. This should be possible in almost any programming language.

console5

all your JDKs on Travis CI using jabba

in

Whether you want to try using OpenJDK 11-ea, GraalVM, Eclipse OpenJ9, or you are stuck needing to build using OpenJDK 6, jabba has got it all. jabba is a cross-platform Java version manager written by Stanley Shyiko (@shyiko).

Here's how we can use jabba on Travis CI to run a build using Azul Zulu OpenJDK 6:

sudo: false
dist: trusty
group: stable
 
language: scala
 
env:
  global:
    - TRAVIS_JDK=zulu@1.6.107
    - JABBA_HOME=/home/travis/.jabba
  matrix:

2018.06 mixtape

Spotify: https://open.spotify.com/user/1235450353/playlist/4jqNCyUylGh9zCYt0JHqEv...
YouTube: https://www.youtube.com/playlist?list=PLSUh6oJ5ZotVoTIXr6OBeLuUSor-PDN_p

  • The Seed - ANIMA!
  • Looped - Kiasmos
  • Naive - RKCB
  • Making Distractions - Kllo
  • Lights - YOSIE, LO
  • CR-V - Cuco
  • Arisen My Senses - Björk
  • Hush - Tourist
  • You and Me - Shallou
  • Last Day… - Shallou
  • Life, Life (Andy Stott Remodel) - Ryuichi Sakamoto
  • Nix - Dawn of Midi
  • A Meaningful Moment Through a Meaning(less) Process - Stars Of The Lid
  • Obfuse - Floating Points

bringing back power assert with Expecty

in

I wanted give Expecty a try, so I forked the repo to eed3si9n/expecty, added sbt build, patched up the code so it works with 2.10, 2.11, 2.12, and 2.13.0-M4, sent a few pull requests upstream, changed the package name, and published my fork to Maven Central:

libraryDependencies += "com.eed3si9n.expecty" %% "expecty" % "0.11.0" % Test

and for Scala.JS and Scala Native:

libraryDependencies += "com.eed3si9n.expecty" %%% "expecty" % "0.11.0" % Test

Here's how we can use this:

scala> import com.eed3si9n.expecty.Expecty.assert
import com.eed3si9n.expecty.Expecty.assert
 
scala> assert(a * b == 7)
java.lang.AssertionError:
 
assert(a * b == 7)
       | | | |
       1 3 3 false
 
  at com.eed3si9n.expecty.Expecty$ExpectyListener.expressionRecorded(Expecty.scala:25)
  at com.eed3si9n.expecty.RecorderRuntime.recordExpression(RecorderRuntime.scala:34)
  ... 38 elide

As you can see, you get a nicer error message automatically.

hot source dependencies using sbt-sriracha

in

Source dependencies is one of features that existed in sbt since ever, but hasn't been documented well.

Using sbt-sriracha, we can define a hybrid dependency to µTest as follows:

lazy val utestJVMRef = ProjectRef(uri("git://github.com/eed3si9n/utest.git#5b19f47c"), "utestJVM")
lazy val utestJVMLib = "com.lihaoyi" %% "utest" % "0.6.4"
 
lazy val root = (project in file("."))
  .sourceDependency(utestJVMRef, utestJVMLib)
  .settings(
    name := "Hello world",
    testFrameworks += new TestFramework("utest.runner.Framework"),
  )

Now using these changes I can run custom µTest on Scala 2.13.0-M4.

detecting Java version from Bash

in

Yesterday I wrote about cross JVM testing using Travis CI.

testing Scala apps on macOS using Travis CI

Here's how we can test Scala apps on macOS using Travis CI. This is adapted from Lars and Muuki's method: Testing Scala programs with Travis CI on OS X

dist: trusty
 
language: scala
 
matrix:
  include:
    ## build using JDK 8, test using JDK 8
    - script:

cross JVM testing using Travis CI

in

Oracle is moving to ship non-LTS JDK every 6 months, and LTS JDK every 3 years. Also it's converging to OpenJDK. In this scheme, JDK 9 will be EOL in March 2018; JDK 10 will come out in March 2018, and EOL in September 2018; and LTS JDK 11 that replaces JDK 8 in September 2018 will stay with us until 2021.

As we will see quick succession of JDKs in the upcoming months, here's a how-to on testing your app on JDK 8, JDK 9, and JDK 10 Early Access using Travis CI.

dist: trusty
 
language: scala
 
matrix:
  include:

removing commas with sbt-nocomma

in

This post introduces sbt-nocomma that introduces nocomma { ... } macro that removes commas from build.sbt:

import Dependencies._
 
lazy val root = (project in file("."))
  .settings(nocomma {
    ThisBuild / organization := "com.example"
    ThisBuild / scalaVersion := "2.12.4"
    ThisBuild / version      := "0.1.0-SNAPSHOT"
 
    name := "Hello"
 
    // comment works
    libraryDependencies += scalaTest % Test
  })

sbt-sticker

in

As tweeted, I made some sbt stickers.

I made these for myself, but I've been sharing them with the contributors to the sbt ecosystem.

If you've ever reported a bug, answered Stackoverflow question, helped someone else's build problem, created an sbt plugin, given a talk about sbt, or sent in a pull request, please come say hello at ScalaMatsuri or Scala Days.

herding cats: day 17

in

Wrote herding cats: day 17 featuring initial and terminal objects, product, duality, and coproduct.

Syndicate content