Posts

Article hero image

How I SBT - VI

I had planned to finish the series with this post. But Plugin s wouldn’t let me. I am going to show you how to write/publish a SBT project that is a Plugin, and I will show a nifty trick. It is not a trick, it is what SBT can do like a piece of pie.

Publishing a Plugin Project

I am sorry I don’t nothing new to tell you here other than all you have to do to publish a Plugin project is to set sbtPlugin := true ๐Ÿคทโ€โ™‚๏ธ. Essentially, everything else you read in the previous posts applies to a Plugin project, additionally setting sbtPlugin.

More ...

Article hero image

How I SBT - V

So far, we have everything we need to write the build definition for a single project. Today, we’ll see another powerful feature of SBT: Multi-module builds.

Multi-module Builds

A multi-module1 build is when you have multiple projects, contrasting with the single project we saw in earlier posts. It is particularly useful for building libraries- cats or Http4s, for example.

More ...

Article hero image

The Interview Bluff

Recently, I had a lunch meeting with an acquaintance who shared their interview experience, particularly behavioral questions. One of the questions asked was, “Works and on time or Perfect and late?” This question sparked a debate, as the interviewer was firmly in the former camp.

Article hero image

How I SBT - IV

Previously, we discussed Plugin s. Today, let us see how to better organize build code.

Build Code Organization

Build code involves everything SBT will consume for the build

Yep, you can have SBT consume Scala files with regular Scala code. But the Scala files must be in the project/ folder.

More ...

Article hero image

How I SBT - III

Previously, we discussed how to quickly write a simple build.sbt without fuss. We briefly understood how it is processed by SBT along with Settings and Tasks. We did that without having to know about the build folder structure1 et al.; until now.

Build Folder Structure

Below is the project and build folder structure. There are two things that SBT is interested in your project - build.sbt and project/ 2.

More ...

Article hero image

How I SBT - II

Previously, I showed you how to write a SBT build definition without knowing much at all. Neither did I talk about simple things like directory structure nor about advanced things like scope or axis, yet you could pretty easily write a SBT build definition for a library and setup publishing. All by writing Scala code (DSL for SBT).

Today, we are going to talk about Settings and Tasks.

More ...

Article hero image

How I SBT - I

Contrary to the unpopular opinions that it is hard and clumsy, SBT, the de facto build tool for Scala, is one of the best. Ease comes with familiarity. Unfortunately, there aren’t many beginner-friendly guides for specific scenarios. A lot of troubleshooting information is hidden in the forests of issues and public forums. This is despite the fact that SBT has excellent support for inspecting your project definition. The official documentation is like the encyclopedia that is too much to digest.

Article hero image

Tagged Types & Implicit Resolution

Last time, I wrote about different ways of declaring implicits, which is a prelude to this post. Knowledge of different ways of declaring implicits is good for general understanding on the subject, and also for this post.

This post discusses an intriguing case - a gotcha, with implicit resolution of instances related to tagged types. Interestingly, newtypes are safer in that regard.

Cross-JDK Compilation in SBT

Recently, I had to cross-compile a bunch of Scala library repositories for JDK 11 and JDK 17. I was hoping SBT would natively support specifying the related configuration in build.sbt similar to crossScalaVersions. I came across some references to plugins that seemed to do the job. But I couldn’t find anything in their documentation that proved they supported compiling for different JDK versions. They only seemed1 to provide better management and configuration options for cross compiling different Scala versions. More ...

Article hero image

Declaring Implicits

While implicits are easy to use, declaring them properly requires careful consideration. Because there are a few different ways you can declare implicits viz. extension methods, parameter values, type converters and dynamic instances. Each one has a specific purpose. For instance, dynamic instances enable recursive implicit resolution. Understanding the different ways of declaring implicits is critical in choosing the right one for the given scenario. It is also invaluable in troubleshooting subtle bugs and unexpected behavior related to implicit resolution.