简体   繁体   中英

Scala Maven Plugin not handling Scala source folder and reporting lifecycle error

I am trying to import a java+Scala project into Eclipse(v4.6.1 Neon). This consist a parent project with scala-maven plugin configured as follows:

 <pluginManagement>
        <plugins>
            <plugin>
                <groupId>net.alchim31.maven</groupId>
                <artifactId>scala-maven-plugin</artifactId>
                <version>3.2.1</version>
                <executions>
                    <execution>
                        <id>scala-compile-first</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>add-source</goal>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>scala-test-compile</id>
                        <phase>process-test-resources</phase>
                        <goals>
                            <goal>testCompile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </pluginManagement>

While importing the project it show an error:

No marketplace entries found to handle scala-maven-plugin:3.2.1:add-source in Eclipse. Please see Help for more information.

While imported to eclipse, there is no source folder created in eclipse for scala(like for java src/main/java and src/main/resources). Also in child projects, it shows this Error.

Plugin execution not covered by lifecycle configuration: net.alchim31.maven:scala-maven-plugin:3.2.2:add-source (execution: scala-compile-first, phase: process-resources) .

Although I am able to build the project from command line.

I also have tried installing Scala IDE Plugin for eclipse, but nothing worked. I dont't want to mark this goal as ignored.

The goal add-source, should be used with "mvn eclipse". But you seem to use m2e/m2eclipse, in this case did you install https://github.com/sonatype/m2eclipse-scala . this plugin setup your eclipse project to use scala + setup of scala folder.

From my personal experience, it's easier to mixe .java and .scala into the same source folder. Easier for IDE, build tools and dev (less directories to navigate into).

Hey PyThon read my answer here . It has the exact pom.xml that you need. It works great.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM