gpt4 book ai didi

eclipse - 避免 Eclipse 忽略 Scala Maven 项目中的垃圾

转载 作者:行者123 更新时间:2023-12-02 16:49:18 25 4
gpt4 key购买 nike

我发现maven使用mvn在命令行上编译scala源的唯一方法是在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 不喜欢这些执行并给出以下错误。

Plugin execution not covered by lifecycle configuration: net.alchim31.maven:scala-maven-plugin:3.0.1:compile (execution: default, phase: compile)

Plugin execution not covered by lifecycle configuration: net.alchim31.maven:scala-maven-plugin:3.0.1:testCompile (execution: default, phase: test-compile)

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>

最佳答案

m2e 要求您安装特定的 m2e 插件。scala-maven-plugin 的插件是 m2e-scala:https://github.com/sonatype/m2eclipse-scala

删除禁用scala-maven-plugin的pluginManagement,并安装m2e-scala http://alchim31.free.fr/m2e-scala/update-site

顺便说一句,最新的 scala-maven-plugin 是 3.1.0,而不是 3.0.1。

干杯,

斯蒂芬

关于eclipse - 避免 Eclipse 忽略 Scala Maven 项目中的垃圾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13995236/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com