All my posts about Scala and programming in Scala. I use Scala every day since about three years, and I plan to write a lot more about this language.
In this categoryPosts in this category, from newest to oldest:
Published Dec 10, 2017. Last revised Dec 12, 2017. In categories: scala
The popular Continuous Integration (CI) server Jenkins provides a JSON API to access information about builds. At my employer we heavily rely on Jenkins and its API to automate our integration and delivery pipeline of our Scala services; our internal tools often uses the API of our Jenkins server to get information such as the latest successful build number for versioning. The Jenkins API speaks JSON, but the JSON it returns has a rather strange shape. I need to extract the Git revision built by a job, but Jenkins hides this information in a specific object in a “catch-all”
actionsarray which contains JSON objects of different shapes, many of which may or may not be present. With Circe—a lovely JSON library for Scala—and some Shapeless magic I managed to decode this irregular JSON in a type-safe and fail-safe way (ignoring unknown JSON objects).
Published Nov 29, 2017. In categories: scala
I had to talk to a web-service that returned JSON without meaningful HTTP status codes (don’t ask). All I had was the JSON itself to figure out whether the service returned a success or failure: Essentially I had to decode an ADT except that all alternatives were flattened into the same level in the JSON. A Circe decoder for these responses needed to inspect the JSON while decoding to pick the right branch.
SBT—Scala’s almighty build tool—continues to amaze me, both, with the amount of WTFs delivered to me, and with the sheer power it puts in my hands. Sometimes I feel like I don’t understand what’s going on at all, and then I find myself writing SBT plugins to automate complex tasks across our build and test infrastructure in a breeze. I curse at SBT when I have to explain how SBT works to my peers, and I love SBT because more than other build tools I know it helps me automate all aspects of project life cycles, even non-trivial tasks in proprietary infrastructures.
Coming from Haskell and Python I found releasing a Scala library a cumbersome process. The standard Maven Central archive—JCenter claims to be a more popular alternative, but all big projects appear to prefer the former—lacks a convenient web interface like that of Python’s package index or Haskell’s Hackage, and comprehensive documentation about publishing. Getting an artifact to Maven Central for the first time involves a surprising number of manual steps and a rather elaborate SBT configuration.
In this article I hope to connect all the loose ends and offer a comprehensive step-by-step guide from nothing to a Maven Central release. I will start with some prerequisites which lie outside the scope of this article, guide you through the necessary bureaucracy and cover the setup. At the end I’ll introduce sbt-release, a powerful plugin to automate the entire release.