Reputation: 124646
I installed Maven Scala support from http://alchim31.free.fr/m2e-scala/update-site/, and the Scala IDE plugin using the Eclipse Marketplace. I can build the project using the command line with mvn compile
. Eclipse highlights Scala code nicely, and if I import the project it correctly recognizes its Scala Nature. But it doesn't recognize src/main/scala
as source folder, and doesn't build the project.
Here's my pom.xml
:
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.examples.scala</groupId>
<artifactId>scala-examples</artifactId>
<version>1.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.15.2</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.10.3</version>
</dependency>
</dependencies>
</project>
What am I doing wrong? Something wrong with the pom?
As a workaround, I manually set src/main/scala
as source folder (right-click, Build Path | Use as Source Folder). But that's not great, I'd like to find the real solution, so that the project would be correctly setup when doing a clean import as a Maven project.
UPDATE
Simply adding the add-source
goal + update Maven project did the trick:
<goals>
<goal>add-source</goal>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
Upvotes: 3
Views: 3156
Reputation: 2425
Copy-paste snippet for the latest plugin version:
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.1.3</version>
<executions>
<execution>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
Reference: http://scala-ide.org/docs/tutorials/m2eclipse/ + @Dimitri answer
Upvotes: 1
Reputation: 8280
Similar to java-maven-plugin
, there is a addSource
goal that let you defines source and test directories. You can this for example :
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.15.2</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
<execution>
<goals>
<goal>add-source</goal>
<configuration>
<sourceDir>src/main/scala</sourceDir>
<testSourceDir>src/main/test</testSourceDir>
</configuration>
</goals>
</execution>
</executions>
</plugin>
I found the documentation in this link
Upvotes: 3