[Scons-users] Scala-Support

Greg Ward greg at gerg.ca
Mon Sep 3 17:17:33 EDT 2012

On 24 August 2012, Russel Winder said:

> SCons support for Java is a bit of a "curate's egg", For trivial Java

> projects, SCons is fine, but then so is Gradle, Maven or even Ant and

> Make. However for anything even a bit tricky SCons has a problem, it's

> model of how to manage build products is at odds with the way that the

> Java compilers work. My experience of SCala is that the processes are

> directly analogous. At various times this has been raised as an issue

> but I have never managed to get myself in a position to be able to focus

> on it. Currently Greg Ward is having a go at improving what there is,

> and is I believe having some success.

I have come to the unfortunate conclusion that SCons just can't handle
Java in the general case, at least not without major refactoring.
Refactoring SCons is presumably very hard because of 1) backwards
compatibility concerns and 2) convoluted code.

For "Java", read "tools that produce unpredictable outputs". There's
nothing special about javac here, it's just a very well-known,
prominent example of a tool with unpredictable outputs.

What is really needed is the ability to construct a "rough draft" of
the dependency graph, and then use compiler output to see what really
happened and feed that back into the graph for the next run. I banged
my head against doing that with SCons for a while, and eventually gave
up. The SCons code is just too hard to follow for me. ;-(

The *other* thing that's hard about Java, which AFAIK *no one* has
solved, is incremental compilation. You can't understand the
dependencies between .java source files without parsing them
completely and understanding the type system, at which point you've
written 30% of a Java compiler. Better just to run the compiler and
analyze the byte code... which gets us back to feeding compiler output
back into the DAG. Really not compatible with SCons' design, as near
as I could tell.

Oh yeah, the other other thing that makes Java and SCons hard to
combine is that Java programmers think nothing of creating new source
files. But since SCons scales badly with size of its graph (roughly,
number of files), build performance suffers. This starts to bite once
you get into tens of thousands of source files.

Greg Ward http://www.gerg.ca/

More information about the Scons-users mailing list