FSC recompiles every time

FSC recompiles my .scala files every time, even if there is no need - I can compile it twice without editing anything between attempts and recompiling them! For example, I have 2 files

Hello.scala

class Hello{
  print("hello")
}

And Tokens.scala:

abstract class Token(val str: String, val start: Int, val end: Int)
  {override def toString = getClass.getSimpleName + "(" + "[" + start + "-" + end + "]" + str + ")"}
class InputToken(str: String, start: Int, end: Int)
        extends Token(str, start, end)
 class ParsedToken(str: String, start: Int, end: Int, val invisible: Boolean)
        extends Token(str, start, end)

When I ask ant to compile the project from scratch, I see the following output:

ant compile
init:
    [mkdir] Created dir: D:\projects\Test\build\classes
    [mkdir] Created dir: D:\projects\Test\build\test\classes

compile:
      [fsc] Base directory is `D:\projects\Test`
      [fsc] Compiling source files: somepackage\Hello.scala, somepackage\Tokens.scala to D:\projects\Test\build\classes

BUILD SUCCESSFUL

Than I do not edit anything and ask ant to compile again:

ant compile
init:
    [mkdir] Created dir: D:\projects\Test\build\classes
    [mkdir] Created dir: D:\projects\Test\build\test\classes

compile:
      [fsc] Base directory is `D:\projects\Test`
      [fsc] Compiling source files: somepackage\Tokens.scala to D:\projects\Test\build\classes

BUILD SUCCESSFUL

As you can see, fsc acts smart in the case of Hello.scala (without recompiling) and acts dumb in the case of Tokens.scala. I suggest that the problem is somehow related to inheritance, but that’s all.

So what's wrong?

+3
source share
2 answers

, , , , .

, fsc , . ant, fsc, Hello.scala out, . Tokens.scala, Tokens , Tokens.class Tokens.scala.

, Scala. Scala Java , - JVM trait , , .

ant, , Scala 2.8. blogtrader.net Caoyuan, Scala Netbeans. Scala , :

<scalac srcdir="${src.dir}"
        destdir="${build.classes.dir}"
        classpathref="build.classpath"
        force="yes"
        addparams="-make:transitive -dependencyfile ${build.dir}/.scala_dependencies"
        >
    <src path="${basedir}/src1"/> 
    <!--include name="compile/**/*.scala"/-->
    <!--exclude name="forget/**/*.scala"/-->
</scalac>

ant , ant , , . Scala , , , , .

init, , Scala , . :

<path id="build.classpath">
    <pathelement location="${scala-library.jar}"/>
    <pathelement location="${scala-compiler.jar}"/>
    <pathelement location="${build.classes.dir}"/>
</path>

. Caoyuan.

+4

Tokens.scala , , . , Tokens.class. , , fsc , , , , , Simple Build Tool, source- > classfile .scala

, , class Tokens.

scala / , , , java / , .

+5

Source: https://habr.com/ru/post/1766754/


All Articles