Avoid Eclipse ignore garbage in Scala Maven project

eclipse, maven, scala

Solution

m2e requires you install specific m2e plugins. The one for scala-maven-plugin is m2e-scala: https://github.com/sonatype/m2eclipse-scala

Remove the pluginManagement that disables scala-maven-plugin, and install m2e-scala http://alchim31.free.fr/m2e-scala/update-site

BTW, latest scala-maven-plugin is 3.1.0, not 3.0.1.

Cheers,

Stéphane

Problem

the only way I've found to have maven compile scala sources on the command line using `mvn` is to add the executions explicitly in the `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> ``` However, Eclipse does not like these executions and gives the following errors. 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 suggests permanently marking the goals as ignored, but this means a lot of ugly garbage is added to my pom. I mean, XML is already hard to look at. Is there a better way to configure my project to compile the sources with `mvn`? Following is what Eclipse adds. ``` <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> ```

Original source