Gradle plugin

The Hydra Gradle plugin smoothly integrates Hydra into Gradle. The Hydra Gradle plugin is built on top of the Scala Gradle plugin, and it is hence trivial to update your build to enable compilation of Scala sources with Hydra.

Note: This documentation assumes you are familiar with the Gradle Scala plugin and it only explains the few changes needed to upgrade your build so that your project is compiled with Hydra instead of vanilla Scala. If you are new to Gradle, start by reading the Gradle Scala documentation to set up your project.


Gradle 4.6 or later (please, contact us if you need support for older Gradle versions).


Hydra is distributed through our public repository. Let's start by adding the Triplequote repository to your build.gradle:

repositories {
  maven {
    url ""

Then, add the Hydra Gradle plugin to the plugins block:

plugins {
  id "com.triplequote.hydra" version "1.1.1"

Note: See here for the latest released version of the Hydra Gradle plugin.

And replace

apply plugin: 'scala'


apply plugin: 'com.triplequote.hydra'

If the build file contains an explicit dependency to zinc, e.g.,

dependencies {
    zinc 'com.typesafe.zinc:zinc:<zinc-version>'

Remove it. The reason is that the Gradle Hydra plugin works only with zinc 0.3.13, and the correct zinc version is automatically set by the plugin.

Finally, set the Hydra and Metrics service versions:

hydra {
  metricsServiceVersion = "1.1.2"
  version = "2.3.11"
  // optional:
  // workers = 4

Check the CHANGELOG for valid Hydra versions.

Note that if you have a multi-module build, the above hydra settings need to be applied to all modules containing Scala sources. The allprojects or subprojects Gradle helpers may prove to be useful, e.g.,

allprojects {
  hydra {

License activation

If you're using Hydra on your developer machine, you need to activate a Hydra license before you can compile with Hydra. Use the hydraActivateLicense task, passing as argument the the actual license number you obtained:

$ gradle hydraActivateLicense --key=XXXXX-...-XXXXX
> Task :hydraActivateLicense
License successfully activated

Compiling with Hydra

Now that Hydra is installed, let's check how it works:

$ gradle compileScala

> Task :compileScala
Starting MetricsService watching /Users/mirco/.triplequote/metrics, pushing to http://localhost:3333.


3 actionable tasks: 3 executed

Congratulations, you have successfully installed Hydra!

Compile-time monitoring!

While compiling your Scala source files, Hydra also collects compilation metrics that help you keep compile time under control. With the help of a modern web-based dashboard, you can track how compilation time evolves on your project, commit after commit. Even more importantly, you can prevent unexpected compile time deteriorations to land in the development branch before hampering everyone's productivity.

In the output above you might have noticed the message

Starting MetricsService watching /Users/mirco/.triplequote/metrics, pushing to http://localhost:3333.

This informs you that Hydra will try to push compilation metrics to a service that is expected to run on localhost (note that Hydra will work just fine also if you decide not to install the dashboard).

To set-up the dashboard please read the installation instruction.

Dashboard Deck

Know your memory requirements

Hydra has slightly higher memory requirements than regular Scala, so make sure you keep an eye on the JVM behavior. If compiling your codebase using Hydra doesn't deliver the desired speed up, adjust the memory settings as shown in the next section.

Adjust compilation memory settings

To adjust memory settings, configure the scalaCompileOptions.forkOptions property as needed, e.g.,

tasks.withType(ScalaCompile) {
    scalaCompileOptions.forkOptions.with {
        memoryMaximumSize = '4g'

Please, refer to the Gradle Scala plugin documentation for further configuration tips.

Garbage collection overhead above 50%:

If while compiling you see a message like the following reported

Garbage collection overhead above 50%: ...

it's a clear indication that the compilation process requires more memory. Adjusting the compilation memory settings will make the message disappear.

In the event that Hydra performance is still limited after increasing memory, it's likely that there is a compilation bottleneck in the project preventing optimal parallelization. For pinpointing the bottleneck you might find the section about Tuning Parallelism useful. Of course, we are happy to help, so please don't hesitate to get in touch!