Question

I edit in the Eclipse Scala IDE and I have my tests running on a separate screen using ~ test in sbt. My tests are written using specs2.

This gives me double compiles, and sometimes Eclipse is still building while sbt starts to kick in.

To solve this I have turned off automatic building, but that also removes the nice compiler warnings and errors within Eclipse.

Is there a way to have both without double compile times?

Edit

I guess the best way (or maybe the only way) is to have sbt run tests without compiling them. I tried the test:run command, but that gives me the following error:

java.lang.RuntimeException: No main class detected.
    at scala.sys.package$.error(package.scala:27)
    at sbt.Defaults$$anonfun$runTask$1$$anonfun$apply$27$$anonfun$13.apply(Defaults.scala:519)
    at sbt.Defaults$$anonfun$runTask$1$$anonfun$apply$27$$anonfun$13.apply(Defaults.scala:519)
    at scala.Option.getOrElse(Option.scala:108)
    at sbt.Defaults$$anonfun$runTask$1$$anonfun$apply$27.apply(Defaults.scala:519)
    at sbt.Defaults$$anonfun$runTask$1$$anonfun$apply$27.apply(Defaults.scala:518)
    at sbt.Scoped$$anonfun$hf5$1.apply(Structure.scala:581)
    at sbt.Scoped$$anonfun$hf5$1.apply(Structure.scala:581)
    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:49)
    at sbt.Scoped$Reduced$$anonfun$combine$1$$anonfun$apply$12.apply(Structure.scala:311)
    at sbt.Scoped$Reduced$$anonfun$combine$1$$anonfun$apply$12.apply(Structure.scala:311)
    at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:41)
    at sbt.std.Transform$$anon$5.work(System.scala:71)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:232)

How could I use ~ test:run while Eclipse is compiling the files?

Was it helpful?

Solution 2

With current sbteclipse versions you can use the following setting:

EclipseKeys.eclipseOutput := Some(".target")

The documentation can be found here: Using sbteclipse

OTHER TIPS

Not having the double compile, and still having all the warnings in Eclipse is not possible from the Eclipse side.

But you can configure Eclipse to not step on the toes of sbt. It doesn't have to use the same output folder for the compilation.

In the project Properties > Java Build Path > Source, select the Output folder of the test source folder, and change the location to something like target/eclipse/test-classes.

enter image description here

This way, Scala IDE won't touch the class files created by sbt.

You may need to do the same thing for the main source folder.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top