Zinc is a standalone version of sbt's incremental compiler meant to be run in nailgun.
npx @tessl/cli install tessl/maven-org-pantsbuild--zinc@1.0.0Zinc is a standalone version of sbt's incremental compiler designed to run efficiently in Nailgun server environments. It provides advanced incremental compilation for Scala projects with support for mixed Java/Scala compilation, analysis caching, and comprehensive build system integration.
"org.pantsbuild" % "zinc" % "1.0.12"import org.pantsbuild.zinc.{Main, Compiler, Settings, Inputs, Setup}
import org.pantsbuild.zinc.logging.{Loggers, Reporters}For Java interoperability:
import org.pantsbuild.zinc.Main;
import org.pantsbuild.zinc.Compiler;
import org.pantsbuild.zinc.Settings;import org.pantsbuild.zinc._
import org.pantsbuild.zinc.logging._
import sbt.Level
import java.io.File
// Command-line compilation
val args = Array(
"-scala-home", "/path/to/scala",
"-classpath", "/path/to/dependencies",
"-d", "/path/to/output",
"src/main/scala/Example.scala"
)
Main.run(args, Some(new File(".")))
// Programmatic compilation
val Parsed(settings, _, errors) = Settings.parse(args.toSeq)
if (errors.nonEmpty) throw new RuntimeException(s"Parse errors: ${errors.mkString(", ")}")
val log = Loggers.create(Level.Info, color = true)
val setup = Setup(settings)
val inputs = Inputs(log, settings)
val compiler = Compiler(setup, log)
val reporter = Reporters.create(log, Seq.empty, Seq.empty)
val progress = new SimpleCompileProgress(logPhases = false, printProgress = true, heartbeatSecs = 0)(log)
compiler.compile(inputs, Some(new File(".")), reporter, progress)(log)Zinc is built around several key components:
Main object)Compiler)Settings, Inputs, Setup)AnalysisMap, dependency tracking)Primary command-line interface and programmatic entry points for Zinc compilation.
object Main {
def main(args: Array[String]): Unit
def run(args: Array[String], cwd: Option[File]): Unit
}Core compiler creation, caching, and incremental compilation execution.
object Compiler {
def apply(setup: Setup, log: Logger): Compiler
def getOrCreate(setup: Setup, log: Logger): Compiler
def create(setup: Setup, log: Logger): Compiler
}
class Compiler {
def compile(inputs: Inputs, cwd: Option[File], reporter: xsbti.Reporter,
progress: xsbti.compile.CompileProgress)(log: Logger): Unit
}Comprehensive configuration management including command-line parsing, compilation settings, and input specification.
case class Settings(
help: Boolean,
version: Boolean,
consoleLog: ConsoleOptions,
sources: Seq[File],
classpath: Seq[File],
classesDirectory: File,
scala: ScalaLocation,
scalacOptions: Seq[String],
// ... additional fields
)
object Settings {
def parse(args: Seq[String]): Parsed[Settings]
def normalise(settings: Settings, cwd: Option[File]): Settings
}Incremental compilation analysis, dependency tracking, and caching infrastructure.
case class AnalysisMap(getPCMapping: Map[File, File], definesClassLookup: File => String => Boolean) {
def definesClass(classpathEntry: File): String => Boolean
def getAnalysis(classpathEntry: File): Option[Analysis]
}
object AnalysisMap {
def create(analysisLocations: Map[File, File], log: Logger): AnalysisMap
}Flexible logging framework with filtering, progress reporting, and console output management.
object Loggers {
def create(level: Level.Value, color: Boolean,
out: ConsoleOut = ConsoleOut.systemOut,
captureLog: Option[File] = None): Logger
}
object Reporters {
def create(log: Logger, fileFilters: Seq[Regex], msgFilters: Seq[Regex],
maximumErrors: Int = 100): Reporter
}Comprehensive utility functions for file operations, timing, property management, and debugging.
object Util {
def timing(start: Long): String
def normalise(cwd: Option[File])(file: File): File
def checkWritable(file: File): Boolean
def setProperties(props: Seq[String]): Unit
}