The Hydra Maven plugin smoothly integrates Hydra into Maven. The Hydra Maven plugin is feature-wise identical to the scala-maven-plugin, and it simply adds support for compiling Scala with Hydra.
- Maven 3.0 or above
- Scala 2.12.1 or above/2.11.8 or above
- Oracle Java 1.8
- A recent version of Triplequote Zinc (at least 0.6.13) if you want to use the incremental compiler with an external Zinc server
|Maven plugin||Zinc server|
Both Hydra and the Hydra maven plugin are distributed through our public repository. Let's start by adding the Triplequote repository to your project POMs:
<project> <repositories> <repository> <id>hydra-releases</id> <url>https://repo.triplequote.com/artifactory/libs-release/</url> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>hydra-releases</id> <url>https://repo.triplequote.com/artifactory/libs-release/</url> </pluginRepository> </pluginRepositories> </project>
Finally, add the Maven Hydra plugin in your build. Assuming you are already using the
scala-maven-plugin from DavidB, you only need to change the organization id, the plugin version, and add a few configuration parameters specific to Hydra:
<project> <build> <pluginManagement> <plugins> <plugin> <!--<groupId>net.alchim31.maven</groupId> comment DavidB Scala Maven plugin group id --> <groupId>com.triplequote.maven</groupId> <artifactId>scala-maven-plugin</artifactId> <version>3.2.2-hydra08</version> <!-- you must use this version or newer --> <executions> ... </executions> <configuration> ... <!-- Change hydraEnabled to false if you'd like to fall back to compile with the vanilla Scala compiler --> <hydraEnabled>true</hydraEnabled> <hydraVersion>1.1.1</hydraVersion> <hydraCpus>4</hydraCpus> <hydraMetricsServiceVersion>1.1.0</hydraMetricsServiceVersion> </configuration> </plugin> </plugins> </pluginManagement> </build> </project>
That's all it's needed to compile Scala with Hydra. You should refer to the
scala-maven-plugin documentation for the configuration of the non Hydra specific settings.
After having properly configured the Hydra Maven plugin on your project, type
mvn compile and you should see a similar output when your project's Scala sources are compiled:
[INFO] Compiling 40 Scala sources and 6 Java sources to /Users/mirco/tmp/spark/common/tags/target/scala-2.11/classes... [INFO] Using 4 Hydra worker to compile Scala sources.
Upon each successful compilation, Hydra extracts and pushes relevant metrics from your build to the dashboard service. Metrics are collected and pushed upstream by an external process, the MetricsService. This service is automatically started by Maven when building. Generally the defaults are good enough, but occasionally you might want to tune it:
||The directory where logs and metrics are stored until they are pushed to the dahsboard service|
||The URL where the dashboard service runs|
||Additional options to pass to the Java VM running the metrics service|
Incremental compilation and Zinc server¶
The Maven plugin can track dependencies between sources and recompile all files that may be invalidated due to transitive changes. This is based on Zinc, the same engine that Sbt is using. You can enable incremental builds by adding the
<recompileMode> configuration option. If you want to use the Zinc server (see below), also add
<configuration> ... <hydraCpus>4</hydraCpus> <recompileMode>incremental</recompileMode> <useZincServer>true</useZincServer> </configuration>
The Zinc server is a long-running process for running the Scala compiler outside of the Maven process. The JVM used by the Zinc server will get "hot" over subsequent builds and lead to much better compilation times.
To install the server, please download and unzip the distribution from here.
Note: You need to use the Triplequote version of the server instead of the Typesafe distribution. The version number must be
To start the server, run
$ ../zinc-N.N.NN/bin/zinc -nailed -start Nailgun server running with 0 cached compilers Version = N.N.NN Zinc compiler cache limit = 5 Resident scalac cache limit = 0 Analysis cache limit = 5
To stop the server:
$ zinc -shutdown
You can find more information about it here.