【问题标题】:Avoid Eclipse ignore garbage in Scala Maven project避免 Eclipse 在 Scala Maven 项目中忽略垃圾
【发布时间】:2012-12-09 08:01:51
【问题描述】:

我发现 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 不喜欢这些执行并给出以下错误。

生命周期配置未涵盖插件执行: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>

【问题讨论】:

    标签: eclipse scala maven


    【解决方案1】:

    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。

    干杯,

    史蒂芬

    【讨论】:

    • 我之前在使用 m2e-scala 时遇到过问题,但我会再试一次。
    • @Stephane Landelle 你知道如何在 Eclipse 中安装它吗?
    • 只需将alchim31.free.fr/m2e-scala/update-site 添加到更新站点(关于> 安装新软件> 添加)。选择所有内容(甚至 m2e,如果您还没有安装它)并确保选中“联系所有人...”
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-07
    • 2017-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多