Using the Scala plugin

We can also use Gradle to work with Scala source files. We can have a Scala-only project or both Java and Scala source files in our project. We must apply the Scala plugin to enable the Scala support for our build. The plugin adds new tasks to compile the Scala source files. With the compileScala task, we compile our main Scala source files. The source files must be in the src/main/scala directory. The compileTestScala task compiles all Scala source code files that are in the src/test/scala directory. The plugin also adds a compile<SourceSet>Scala task for custom-defined source sets in our build.

The compile tasks support both Java and Scala source files with joint compilation. We can place our Java source files in say the ...

Get Gradle Effective Implementations Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.