In case you haven't noticed the SVN commits, there are some major changes going on in trunk towards version 1.3. The biggest new feature in 1.3 is the separation of the compile task from Javac, allowing us to support multiple compilers and obviously multiple languages.

We already did something of this sort by forking the CompileTask to support Scala. Unfortunately, forking makes it hard to roll out changes across all the compilers, test them, and support them in other tasks (test frameworks, packaging, IDEs etc). Separately, I started playing with a few strategies for separating the compiler from CompileTask as part of the 1.3 branch, but trunk kept moving forward with changes and bug fixes, and the 1.3 branch ended out of sync and buggy. So now I'm taking all the ideas fro the old 1.3 branch and merging them into trunk.

So what will this new feature look like?

For starters, I think the most common use case would be picking one language per project. A buildfile can have different projects and mix various languages, but designing for a single language per project makes everything simpler. Having one compile task (and test.compile task) per project makes it easier to configure, package, test and support in IDEs. So the current design is based on a single CompileTask that picks which compiler to use.

CompileTask will make an educated guess based on the project layout. For example, if it finds any /.java/ files in the /src/main/java/ directory, it will use the Javac compiler. If it can't decide, you can always tell it which compiler to use, for example, /compile.using(:scalac)/ will configure it to use the Scala compiler. Without a compiler and source directories, it simply does nothing.

That does mean a few changes that may affect your tasks:
1. Projects that use Javac will compile to /target/classes/ (and /target/test/classes/) but other projects may compile to different target directories, so never hard code the target directory, always use /compile.target/ and /test.compile.target/. 2. Projects that don't compile anything will have no source directories (/compile.sources/ returns an empty array) and no target directory (/compile.target/ returns nil). 3. Because the target directory is different for each compiler, and resources can be used without the compiler, resources are now copied to a separate target directory (/target/resources/ and /target/test/resources/). 4. Not all languages have a classpath, but most languages have compile/runtime dependencies, so what was before /compile.classpath/ is now called /compile.dependencies/; /compile.classpath/ is still supported for backwards compatibility, and /compile.with(...)/ is still the recommended way to add new dependencies. 5. The compiler options (/compile.options/) is no longer specific to the Java compiler.

You can use /compile.compiler/ and /compile.language/ to find out which compiler is used and which language it supports. If you want to see what it takes to write a compiler, check out the code in /lib/java/compilers.rb/.

Assaf

Reply via email to