Scala fastScalaCompiler behaviour different from scalac (report as problem not praise :-/ )


(Raymond Barlow) #1

Hi,

I’ve managed to get my scala application to compile via gradle using the scala plugin. I had to move the java classes that were dependent on scala classes into the scala directory, which seems like a restriction the build tools should not impose. But, aside from that, I then decided to switch on the fast scala compiler (scalaCompileOptions.useCompileDaemon = true). When I did this, gradle could no longer compile the java classes in the scala directory that were dependent on scala classes.

Why should this behaviour differ between a normal scalac and an fsc?

/Raymond

$ export GRADLE_OPTS="-Xmx1024m -Xms64m -Xss4m"; gradle clean compileScala
:clean
:compileJava
:compileScala
[ant:javac] /Users/rbarlow/Development/projects/project/src/main/scala/com/project/model/Currency.java:11: cannot find symbol
[ant:javac] symbol
: class Amount
[ant:javac] location: package com.project.module.model
[ant:javac] import com.project.module.model.Amount;

(Peter Niederwieser) #2

I had to move the java classes that were dependent on scala classes into the scala directory, which seems like a restriction the build tools should not impose.

You don’t have to do that. If you want to keep the standard layout and have all Scala and Java sources joint-compiled, you can just do:

sourceSets.main.scala.srcDir "src/main/java"
sourceSets.main.java.srcDirs = []

Now all Java sources will be compiled by the compileScala task.


(Raymond Barlow) #3

Hi Peter,

Thanks, that does indeed fix the location of the java files, which now works nicely with a standard scalac.

Unfortunately, the fast scala compiler still dies with the same problem.

Why, in the previous output, is the ant:java task being invoked at the point that the build fails?

Appreciate your help! And am quite ejoying gradle so far.

/Raymond Barlow


(Peter Niederwieser) #4

Actually I can’t get fsc to work at all with Gradle 1.0-m6. Depending on the Scala version used (tried with 2.8.1 and 2.9.1), I get different errors when Gradle tries to start fsc. Which Gradle and Scala versions do you use?


(Peter Niederwieser) #5

OK, turns out that you need the Scala executable on the OS path for fsc to work. After doing this, I’m running into https://issues.scala-lang.org/browse/SI-5196.


(Raymond Barlow) #6

I’m using 2.9.1.

I do have the scala executables on the system path.

My problem is different. It is purely a compilation one (class A cannot find class B), which surprised me. It’s as if the sourcepath being passed to fsc is different from scalac.