FlattenCode — an sbt plugin for competitive programming in Scala

I maintain a Scala project for competitive programming where my classes are organized by topic or challenge type. The core of each problem lives in a single manageable file, with separate test files and data visualizers alongside.

The problem: platforms like CodinGame, HackerRank or LeetCode expect a single file. Copying and reorganizing manually breaks the workflow.

FlattenCode is a small sbt plugin that handles this automatically — it reads your main file, resolves local dependencies by following package declarations and imports (direct, grouped, wildcard), and produces a single clean file ready to paste. External imports (scala.*, java.*) are preserved. Package declarations are removed.

bash

sbt flattenCode       # single run
sbt ~flattenCode      # watch mode — regenerates on save

Tidy, clean, automatic, simple and comfortable.

Source and installation instructions: https://github.com/ccerdadiaz/scala-flatten-code-plugin

Feedback welcome.

3 Likes