如果你正在使用sbt,你可以使用sbteclipse来生成eclipse项目配置。
Maven如果您正在使用maven,则可以将scala-maven-plugin与m2eclipse-scala结合使用。前者将编译Scala代码,后者将执行ScalaIDE和m2e(maven的eclipse插件)之间的集成。
您必须在pom.xml中添加以下部分:
<build>
<sourceDirectory>src/main/scala</sourceDirectory>
<testSourceDirectory>src/test/scala</testSourceDirectory>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>MANUALLY_REPLACE_WITH_LATEST_VERSION</version>
<configuration>
<args>
<arg>-target:jvm-1.8</arg>
<arg>-deprecation</arg>
<arg>-feature</arg>
<arg>-unchecked</arg>
<arg>-language:implicitConversions</arg>
<arg>-language:postfixOps</arg>
</args>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
您也可以使用scalor-maven-plugin。
您必须在pom.xml中添加以下部分:
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<skip>true</skip>
<skipMain>true</skipMain>
</configuration>
</plugin>
<plugin>
<groupId>com.carrotgarden.maven</groupId>
<artifactId>scalor-maven-plugin_2.12</artifactId>
<version>MANUALLY_REPLACE_WITH_LATEST_VERSION</version>
<configuration>
<zincOptionsScala>
-target:jvm-1.8
-deprecation
-feature
-unchecked
-language:implicitConversions
-language:postfixOps
</zincOptionsScala>
</configuration>
<executions>
<execution>
<goals>
<goal>eclipse-config</goal>
<goal>eclipse-format</goal>
<goal>eclipse-restart</goal>
<goal>eclipse-prescomp</goal>
<!-- <goal>register-main</goal> --> <!-- uncomment if you have some Scala code to compile in src/main/scala -->
<goal>register-test</goal>
<!-- <goal>compile-main</goal> --> <!-- uncomment if you have some Scala code to compile in src/main/scala -->
<goal>compile-test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>