IntelliJ + Maven + Java + Scala = Problems
Hello, I am a very long term IntelliJ user, I have used IntelliJ for many years enjoying Maven with Java and Groovy.
I now have a large Maven project, most of which is Java, with new code being written in Scala
Unfortunately, I am finding IntelliJ pretty unusable for Scala. Hopefully this is a simple issue with setup
Can anyone offer a config that is known to work well?
I am using 13.0.2 IU133-696
My Scala plugin is 0.30.378
Here are my issues. All these problems seem related-- IntelliJ is mixed up somehow.
1) If I change my Java and recompile, the Scala compiler does not see the change
2) The Scala compiler produces error messages, but the code does not turn red at that location
3) Scala code fails to compile because of missing methods in Java, but when I click on the method in Scala, it takes me to the right Java
I have tried both the Scala Server, and the IntelliJ compiler and both behave the same
I would like to just import my Maven project, I don't want to move to SBT. The rest of my company is very Maven centric. Here is my Maven Scala plugin
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<version>2.15.2</version>
<executions>
<execution>
<id>scala-compile</id>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
<configuration>
<args>
<arg>-make:transitive</arg>
<arg>-dependencyfile</arg>
<arg>${project.build.directory}/.scala_dependencies</arg>
<arg>-Xprint:typer</arg>
<arg>-deprecation</arg>
</args>
</configuration>
</execution>
</executions>
</plugin>
Please sign in to leave a comment.
Here's some new info...
It might be a problem with my Maven Scala plugin. If found a newer one, and things seem somewhat happier
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>3.1.6</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<!--scalaVersion>${scala.version}</scalaVersion-->
</configuration>
</plugin>
Things seem snappier, however, I am still observing 1, 2, and 3
Here is an example these sorts of problems
I am importing some Java
import com.babelcentral.recognizer.util.distribution.GaussianDistribution
The code in the editor is not colored. However, when I compile I get errors like this...
object babelcentral is not a member of package com
import com.babelcentral.recognizer.util.distribution.GaussianDistribution
^
not found: type GaussianDistribution
goodDist: Map[Long, GaussianDistribution],
^
Furthermore, when I click on GaussianDistribution, IntelliJ takes me to the Java code
Hi, Peter,
Most probably changing some configurations will help.
First of all please check that you are using IntelliJ IDEA incremental compiler (go IDE Settings -> Scala -> Incremental compilation by). Then check that you are in Mixed mode on the same page. Additionally please check you Scala facets. Every module containing Scala files should have Scala facet, which is properly configured (Project Settings-> Modules -> Scala node under Scala module node). It also should contains Mixed compile order.
Most probably it can fix 1 and 3.
As for 2 it's simple to fix. Press on [_] sign in right bottom corner, it will enable error highligthing in Scala files.
Best regards,
Alexander Podkhalyuzin.
Recently I had some problems with idea 13.0.2 and latest scala, try idea 13.0.1 (download.jetbrains.com/idea/ideaIU-13.0.1.zip) + scala plugin 0.26.361
We are using java/scala/maven in 40+ module project more or less without issues, mixing java and scala a lot.
What kind of problems do you have in 13.0.2?
Best regards,
Alexander Podkhalyuzin.
http://youtrack.jetbrains.com/issue/SCL-6600
and
http://youtrack.jetbrains.com/issue/SCL-6582
On linux.
One of my colleagues had on windows, but after weekend issue has gone. I can retest if that was some our env issue.
Please try it with 0.31.497. I'll upload it in an hour (or you can download it here; http://confluence.jetbrains.com/display/SCA/Scala+Plugin+Nightly+Builds+for+Cardea).
Best regards,
Alexander Podkhlayuzin.
Thank you Alexander,
Clicking on the [_] did indeed fix my 3)
I had wondered what is was ;-)
Changing to the IntelliJ compiler got rid of the the compile errors. Does this mean that the Scala Server has trouble with Maven? Is this just a temporary bug, or should I avoid the Server? What is the advantage of using the Server?
Also did you upload 0.31.497? Should I upgrade my Scala plugin?
Thanks again
P
I updated 0.30.380. It contains fix of IDEA hangings.
If you are able to reproduce bug with IDEA SBT compiler (with some sample project), it would be great if you share it with us (http://youtrack.jetbrains.com/issues/SCL).
We still don't know, which approach is better for compilation (for now I would say IntelliJ IDEA based is better, but SBT based will be probably better in future, it depends on SBT team). That's why it would be good to fix.
You need compiler server in case if you want to start compiler in warm JVM, for every make it can save to you up to 5 seconds, but it requires a lot of memory all the time.
Best regards,
Alexander Podkhalyuzin.
Hi All,
I am new to intellij as I was using Eclipse, I am also facing problem with scala / Spark code not showing errors in editor or in code, I saw previous comment to click on [_] (at right bottom), but I can't fint it there.
I am using Intellij 2017.3.3 (Ultimate edition).
Thanks,
Abhishek
Update..
Now I am able to see [_] but still not able to see error in editor if I type anything wrong there.