我发现在命令行上使用 maven 编译 scala 源的唯一方法mvn
是在scala-maven-plugin
.
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<args>
<arg>-deprecation</arg>
<arg>-unchecked</arg>
</args>
<jvmArgs>
<jvmArg>-Xms128m</jvmArg>
<jvmArg>-Xmx1024m</jvmArg>
</jvmArgs>
</configuration>
</plugin>
但是,Eclipse 不喜欢这些执行并给出以下错误。
生命周期配置未涵盖插件执行:net.alchim31.maven:scala-maven-plugin:3.0.1:compile(执行:默认,阶段:编译)
生命周期配置未涵盖插件执行:net.alchim31.maven:scala-maven-plugin:3.0.1:testCompile(执行:默认,阶段:测试编译)
Eclipse 建议将目标永久标记为忽略,但这意味着我的 pom.xml 中添加了很多丑陋的垃圾。我的意思是,XML 已经很难看。有没有更好的方法来配置我的项目以编译源代码mvn
?以下是 Eclipse 添加的内容。
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
net.alchim31.maven
</groupId>
<artifactId>
scala-maven-plugin
</artifactId>
<versionRange>
[3.0.1,)
</versionRange>
<goals>
<goal>testCompile</goal>
<goal>compile</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>