Infinitest not refreshing in IntelliJ IDEA (15) on gradle project - scala

The Infinitest plugin under IntelliJ IDEA 15 is not re-running my tests when I change a source file. I wonder if it is because my project is a gradle project. Is there a way to make it refresh automatically?
(It is also Scala code, but I'm using the JUnit test runner, and Infinitest officially supports scala, so I wouldn't think that Scala is the barrier here.)
With a module named "practice", I first added the facet to "practice", changed one of the source files in there, but nothing happened in Infinitest. Tried Ctrl+S, still nothing. Sometimes when I manually recompile the module with Ctrl+F9 then it will refresh.
I also tried adding the facet to "practice_main" and "practice_test" instead of just "practice". I'm not sure which one I'm supposed to add it to in Module Settings.

Related

IntelliJ doesn't recognize properly SBT plugin test projects under 'sbt-test'

While everything in SBT is correct and work properly, all sub-projects in sbt-test are not recognized by IntelliJ. (leading to red hell inside files)
I tried to add them as module from existing source, but it led to an error (plugin version property isn't available from tested plugin project).
If by chance someone has already configured this, could you explain the procedure to follow?

Scala Intellij breakpoints ignored

I am doing the Scala introductory course from Coursera.
Within Intellij, I am trying to debug but breakpoints are ignored.
Unlike in this question: Can't debug a Scala application in IntelliJ + sbt-idea-plugin, I am not getting any error.
Do I need to install something or set some Intellij configurations?
Someone recently walked me through debugging in InteliJ using scala/scalatest. I am running InteliJ Idea 2017.2 with the latest scala language plugin installed, no SBT plugin installed (as far as I can tell this is just part of the scala plugin now). Hopefully this helps some other people out:
Set breakpoints by clicking next to the line number you want to test.
Assuming you are using ScalaTest to set up some conditions and run your program, you can right-click on one of your test classes, and then select Debug '[classname]' from the dropdown. This should pop open the debug pane on the bottom.
When you use InteliJ to run the debugging directly (not attaching through sbt etc) I was actually able to get this to work. I have not had success with any of the answers to related questions that discuss attaching to a running sbt process (with scalatest at least).
There are a lot of useful things that intelij debug gives you with scalatest at this point. Say there is one test that is failing and you want to dig into why. On the debug window, click the console tab, and you will see a list of your tests ordered by suite w/ red marks next to the ones that failed. You can right-click on a single test and select debug from the dropdown to only debug that one test. It's pretty useful.
Hopefully that helps some other people! I also hit a few gotchas I should outline:
Sometimes I need to re-load the sbt project (click the circular arrow thing under the sbt project tab on the left). It takes a while but it cleans up some random errors about classes not being found, and even unrelated sounding things like One or more requested classes are not Suites.
I sometimes get errors about shaded classes not found, especially when using docker through sbt (for example to spin up a db node in my tests). To get around that I first deleted the cached compiled jar (rm -r $HOME/.ivy2/cache/com.spotify/ for example to get rid of the cached compiled code that was causing problems) then I reloaded the project as in step-1.
If all else fails, make sure that the project is properly imported. You might need to delete the .idea folder in your folder and re-import the sbt project. This trashes your settings and all, but it's worked for me as a last resort in the past.

Scala IDE 4.0.0 thinks there's errors in an out-of-the-box Play Framework 2.3.7 program

I've created a Play Framework program via Typesafe Activator (so it follows the template exactly).
I used sbteclipse-plugin version 3.0.0 to create an Eclipse project and imported that into Scala IDE 4.0.0. These are all the latest versions at the time of writing.
The Scala IDE definitely seems to support the Play Framework. It has syntax highlighting for the custom formats, including the routing file and templates. Yet, it doesn't seem to be able to find the views from the controllers. In particular, the call to views.html.index triggers an error: "object index is not a member of package views.html".
I tried enabling refreshing using native hooks or pooling as detailed here, but it had no affect.
I should note that while the code has been compiled in the command line (with activator ~run), it hasn't been compiled in Scala IDE, since I don't know how to (it doesn't seem to be documented anywhere).
What can I do to get rid of these false errors?
EDIT: After running activator clean ~run, I have another error: The project cannot be built until build path errors are resolved. There's no further details on what these build path errors are.
Update: Just upgrade to sbteclipse version 5.1.0 and everything should work out of the box. Also make sure you follow the Play documentation on how to set up Eclipse/ScalaIDE.
This is a known bug in sbteclipse, which probably will be fixed soon.
For now, you can add the following line to your build.sbt:
EclipseKeys.createSrc := EclipseCreateSrc.All
Kill the SBT console and run sbt eclipse again. That should add the following line to the .classpath file within your project folder as a workaround:
<classpathentry kind="src" path="target/scala-2.11/twirl/main"/>
Refresh your Eclipse project to pick up the change.
I had the same issue, also with Scala IDE 4.0.0 . I followed mkurz instuctions and they worked like a charm. But instead of changing the .classpath file in the project folder manually I used Eclipse interface:
In the top menu of the main window, click on Project and then on Properties.
In the Properties window, click on Java Build Path option (options list is on the left)
In the Source tab, click on Add Folder... button.
In the Source Folder Selection window, choose the target/scala-2.11/twirl/main folder, so it is included in the compilation path. Click Ok button.
Click Ok in the Properties window.
Now the project should compile just fine :) . With that I was able to finish the play setup example in Scala IDE website
I tried #mkurz solution first, but also ran into the same error as #matt. I became frustrated that I could not generate the eclipse project without having to go to the Eclipse project properties to manually fix the build errors. After some investigation, I discovered the solution that removed all errors entirely. Add this your build.sbt:
unmanagedSourceDirectories in Compile <+= twirlCompileTemplates.target
Or if that does not work for you, you could also use:
unmanagedSourceDirectories in Compile <+= target.zipWith(scalaBinaryVersion) { (b,v) => b / s"scala-$v/twirl/main" }
Good bye, build errors!
I got the same error message.
Are you using java8 as jre in eclipse?
After switching back from java8 to java7, everything worked fine again.
If, after following Mkurz' instructions (adding EclipseKeys.CreateSrc... ), your problems are not solved, click on Project -> Properties -> Java Build Path. Look at the source folders tab.
You may find a duplicate file folder named .../src_managed/main (Thanks Matt). If so, close the project. Remove ONE of the two ../src_managed/main entries from the .classpath file (located in the base of the activator/SBT project directory). Reopen and clean the project and you should be good to go.
For me, it turned out that installed JRE in the Scala IDE was openjdk, changed it to Oracle Java 8 and it worked.

Can anyone help me fix this m2e-jdt/jdt bug?

Introduction
I have spend a lot of time to fix this bug
In our application we have a lot of generated code by cxf and jaxb which produces tons of warnings. We use the maven-build-helper plugin to add this code to our projects automatically.
By adding this enhancement, eclipse JDT enabled the possibility to set the javac -nowarn flag for specific source folders. Unluckily, by updating the maven project the flag gets lost. There are a few threads on SO where users got bugged by bug.
What I have tried so far
So i came up with a clever solution, javac has a nowarn flag. I set it to my maven-compiler-plugin and specified the directory. My maven build was fine, but my eclipse build wasn't. My research told me, that eclipse jdt does only use the maven-compiler-plugin source and target version. So my next step was to try to configure the EclipseCompiler, but this is not possible, because there is no possibility to add custom compiler Arguments in eclipse JDT.
Next Step. Inside of the .classpath file, eclipse JDT adds an ignore_optional_problems attribute for each ignored path. By updating the maven project inside of eclipse, this entry gets lost. So i started to write a maven "ignore-source-folder" plugin which should add the missing attribute. To run the plugin each time eclipse starts a build, i also created a m2e connector to refresh the .classpath file and everything should be fine.
By testing my plugin with my connector i realized, it works, but only 70% of the repetitions.
What happened?
Every time eclipse m2e/Jdt starts a new build, all classpath entries will be removed and populated again. When my maven plugin gets triggered by eclipse, a race condition starts.
So I started to analyze the code of jdt and m2e jdt. The ignore_optional_problems flag gets only once set manually inside of the patch which was provided to JDT and isn't stored somewhere else. By triggering a new build via m2e-jdt this information gets lost.
How to fix this problem
To fix this problem, some element has to be added or extended in jdt which contains all ignored folders. If a new build gets triggered and the classpath file gets newly generated by m2e-jdt this element should be checked for ignored paths. ClasspathEntryDescriptor seems to be a good place for it.
My problem
I checked out jdt and m2e jdt, but i have tons of errors inside of my IDE and i have no idea how to start. And even if I fix the code, I have no idea how to build and test it. I think my effort will be to high and we talk about 20 or 30 simple lines of code.
I am afraid if I add my results to the filed bug at eclipse, no one will care about it.
So, is there any developer able and willing to help me for this tiny job?
You need to "fix" the M2E's JDT project configurator. Probably somewhere in the m2e-core project. So, your change should obtain some kind of configuration flag from the project pom and create corresponding classpath entries for JDT.

How Can I Make and Run GWTTestCase Based Tests with Intellij 12?

I've tried multiple times over a few months now to do this, but I haven't had any luck. I've found Google's documentation about how to setup GWTTestCase tests via the command line and Eclipse, but nothing about how to do it with IntelliJ. When I try to excite GWTTestCase tests in IntelliJ like a normal J-unit test, I get a bunch of errors. I assume that the Google Eclipse plugin is probably doing some sort of magic to make the tests work in Eclipse, so I'm not even sure if what I want to do is possible.
GWTTestCases are especial junit tests, because they have to execute some extra stuff like the gwt compiler. This is done automatically, but the compiler needs to know where your .java files are (main and tests). So previously to run the test you have to add the src, test folders (if you use ant) or src/main/java, src/test/java (if your project is a maven one) to the class-path of your launcher.
If you are using the native GWT support in intellij (it was previously called GWT Studio plugin), it should add those folders to the classpath. You can find more info in this page, although it is a bit outdated.