maven "rerun with -feature" when compiling scala
Asked Answered
S

2

7

I recently noticed Scala compiler warnings that maven was generating that looked like this:

[WARNING] warning: there were 4 deprecation warning(s); re-run with -deprecation for details

[WARNING] warning: there were 3 feature warning(s); re-run with -feature for details

[WARNING] two warnings found

It was not immediately apparent to me how to follow the warning's instructions so I could get details on how to change my code.

Spermiogenesis answered 18/3, 2014 at 23:46 Comment(0)
S
8

It turns out that these two instructions are coming from the Scala compiler and so what needs to happen under the covers is for scalac to be called with -deprecation or -feature as described here:

http://www.scala-lang.org/files/archive/nightly/docs-2.10.3/manual/html/scalac.html

(actually I never saw the -feature option explained anywhere but I was able to specify it as follows)

I'm using the scala-maven-plugin and compiling with scala:compile described here:

http://davidb.github.io/scala-maven-plugin/compile-mojo.html

The relevant parameter is described here:

http://davidb.github.io/scala-maven-plugin/compile-mojo.html#addScalacArgs

So, two maven commands that I found helpful were:

mvn clean compile -DaddScalacArgs=-deprecation mvn clean compile -DaddScalacArgs=-feature

Spermiogenesis answered 18/3, 2014 at 23:46 Comment(1)
You should probably add these to the pom file as a configuration of the plugin permanently.Doings
I
15

Just to make it clearer from Philip's answer (as specified on the plugin page), add the following to your pom.xml file:

<plugin>
    <groupId>net.alchim31.maven</groupId>
    <artifactId>scala-maven-plugin</artifactId>
    ...
    <configuration>
        <args>
            <arg>-deprecation</arg>
            <arg>-feature</arg>
        </args>
    </configuration>
</plugin>
Infeasible answered 16/9, 2014 at 19:56 Comment(0)
S
8

It turns out that these two instructions are coming from the Scala compiler and so what needs to happen under the covers is for scalac to be called with -deprecation or -feature as described here:

http://www.scala-lang.org/files/archive/nightly/docs-2.10.3/manual/html/scalac.html

(actually I never saw the -feature option explained anywhere but I was able to specify it as follows)

I'm using the scala-maven-plugin and compiling with scala:compile described here:

http://davidb.github.io/scala-maven-plugin/compile-mojo.html

The relevant parameter is described here:

http://davidb.github.io/scala-maven-plugin/compile-mojo.html#addScalacArgs

So, two maven commands that I found helpful were:

mvn clean compile -DaddScalacArgs=-deprecation mvn clean compile -DaddScalacArgs=-feature

Spermiogenesis answered 18/3, 2014 at 23:46 Comment(1)
You should probably add these to the pom file as a configuration of the plugin permanently.Doings

© 2022 - 2024 — McMap. All rights reserved.