To increase support for the Scala language in a common Java project built using MAVEN. Enables it to compile both the Java and Scala language files. In fact, a very simple thing, just need to in the Pom.xml file in the build section of the plugins, increase the support for Scala-maven-plugin, just fine. Specifically, add the following statement:
<plugin> <!--see Http://da Vidb.github.com/scala-maven-plugin-<groupId>net.alchim31.maven</groupId> <ARTIFACTID&G t;scala-maven-plugin</artifactid> <version>3.2.2</version> <executions> < ;execution> <goals> <goal>compile</goal> <goal>testcompile </goal> </goals> <configuration> <args> <arg& Gt;-dependencyfile</arg> <arg>${project.build.directory}/.scala_dependencies</arg> </args> </configuration> </execution> </executions> <c onfiguration> <scalaVersion>2.11.8</scalaVersion> </configuration> </PLUGIN&G t;
Note:
1. If there is no build and plugins part of your MAVEN project Pom.xml, please add it yourself.
2. Scalaversion please change to your own installed version.
3. Create the Src/main/scala directory and put the Scala language files in this directory.
After that, you can compile the files in the Src/main/scala and Src/main/java directories at the same time as long as you execute MVN clean compile.
Executes the generated class file, as you would any Java-generated class file, using MVN Exec:java-dexec.mainclass=[your_class_name]
Maven Java Project Add Scala language support