Maven Java Project Add Scala language support

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.