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
src/main/java directory of our project and the Scala source files in the
src/main/scala directory. The compiler will compile both types of files. To be able to compile the files, we must add dependencies to the Scala library in our build file...