The Scala plugin
The Scala plugin helps you to build the Scala application. Like any other plugin, the Scala plugin can be applied to the build file by adding the following line:
apply plugin: 'scala'
The Scala plugin also extends the Java plugin and adds a few more tasks such as compileScala
, compileTestScala
, and scaladoc
to work with Scala files. The task names are pretty much all named after their Java equivalent, simply replacing the java
part with scala
. The Scala project's directory structure is also similar to a Java project structure where production code is typically written under src/main/scala
directory and test code is kept under the src/test/scala
directory. Figure 6.3 shows the directory structure of a Scala project. You can also observe from the directory structure that a Scala project can contain a mix of Java and Scala source files. The HelloScala.scala
file has the following content. The output is Hello, Scala...
on the console. This is a very basic code and we will not...