Circe JSON: Use JsonObject instead of cursors

September 11, 2024

I’m using the Circe JSON library at work. I am not a fan of it. I recommend to stay away from it. Luckily I rarely have to touch JSON parsing code paths.

What makes my blood boil the most with Circe is small ad-hoc JSON parsing, where I need to extra some values from JSON, without going to create boiler plate class for it. [1]

My expectation for something like that I get a Map, maybe an extended map with some convenience functions. However, the Circe documentation guides you towards their cursor API for that. That API is (censored/insert swearwords/rant here).

Turning JSON complicated
Figure 1. Turning JSON complicated
Continue reading →

Mill Build for Java Devs

August 5, 2024
Note
Update March 2025. This post was originally written for Mill 0.11. I’ve updated the examples to work with Mill 0.12.9, but didn’t incorporate all improvements since then.

Mill has its origin in the Scala world. However, it is well suited to build Java projects. Recently the official Mill documentation gained a growing Java section with many examples. So, I’m keeping this post short, as the official documentation has more information than I can cover.

Continue reading →

Build Questions answered by Mill builds

July 22, 2024
Note
Update March 2025. This post was originally written for Mill 0.11. I’ve updated the examples to work with Mill 0.12.9, but didn’t incorporate all improvements since then.

I’ve started this series with a list of questions you will encounter in non trivial builds. I claimed that Mill had great at answering most of these questions, but left the actual answers open. Well, after showing Mill for a bit, it is time to answer them.

Continue reading →

Mill Basic Building Blocks

July 15, 2024
Note
Update March 2025. This post was originally written for Mill 0.11. I’ve updated the examples to work with Mill 0.12.9, but didn’t incorporate all improvements since then.

Lets explore the Mill building blocks. We start with a hello world:

import mill._
import javalib._

def buildGreetings = Task{
  val greeting = "Hello Mill!"
  val outFile = Task.dest / "greeting.txt" // Note, we use T.dest as our output directory
  os.write(outFile, greeting)
  println(s"File is in $outFile")
  PathRef(outFile)
}

Then we build it:

$ ./mill buildGreetings
...
[1/1] buildGreetings
File is in /home/roman/dev/private-dev/mill-demo/out/buildGreetings.dest/greeting.txt
$ cat /home/roman/dev/private-dev/mill-demo/out/buildGreetings.dest/greeting.txt
Hello Mill!

That works. Note that we used T.dest to give each target its own directory to write to disk without trampling over other targets. The location in the 'out' directory is always the task names with a .dest suffix.

Continue reading →

Whirlwind Tour of Mill Build

June 10, 2024
Note
Update March 2025. I wrote this post for Mill 0.11. I’ve updated the examples to work with Mill 0.12.9, but didn’t incorporate all improvements since then.

Lets start a whirlwind tour. Last time we stopped at a basic Java app. Yes, Mill does of course support building Scala projects as well, but Mill works well for other builds as well.

Continue reading →