How to combine continuous sbt testing with eclipse scala ide?

I am editing an Eclipse Scala IDE and my tests are run on a separate screen using ~ test in sbt . My tests are written using specs2 .

This gives me double compilations, and sometimes Eclipse still builds until sbt starts kicking.

To solve this problem, I turned off auto build, but also removes wonderful warnings and compiler errors in Eclipse.

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

Edit

I think the best way (or maybe the only way) is to have sbt run tests without compiling them. I tried the test:run command, but this 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 can I use ~ test:run while Eclipse compiles the files?

+4
source share
2 answers

With current versions of sbteclipse, you can use the following setting:

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

The documentation can be found here: Using sbteclipse

0
source

Lack of double compilation and still having all warnings in Eclipse is not possible from Eclipse.

But you can configure Eclipse to not step on sbt fingers. It should not use the same output folder for compilation.

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

enter image description here

This way, the Scala IDE will not touch the class files created by sbt.

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

+3
source

All Articles