AFC - Abacus Formula Compiler for Java

IDE Setup

AFC is split into a number of components. Ideally, each is managed in its own IDE project. Then, internally, each component’s source is again split into a number of source paths covering areas like API (intf), implementation (impl), tests (test), and again into java, resources, etc. Each component’s lib folder is split into areas likewise.

This keeps the project well organized, but it makes IDE setup a bit of bore. If you are using Eclipse or IDEA, then the project definitions are already there, but still need to be opened or imported.

Before you setup the IDE, you have to run an initial build so the generated sources are in place.

Rebuild Sources

Run ant -q build to rebuild all the generated Java sources and source paths. Make sure that ant runs on the same version of the JDK as you configure for the projects in your IDE. This is because some of the generated sources differ by JDK version and are put into separate folders (see below).

Eclipse

Sources

Don’t forget to rebuild the generated sources first! (See above.)

Setup

To use Eclipse (as I do), you can simply import the existing projects:

afc
in the root folder (optional; see Subversion above)
afc-runtime
in components/runtime/
afc-compiler
in components/compiler/
afc-decompiler
in components/decompiler/
afc-spreadsheet
in components/spreadsheet/
afc-spreadsheetdt.excel-xls
in components/spreadsheet.excel.xls/

Unfortunately as of Eclipse 3.3 you have to import each project separately using “File → Import”.

Code Style

The default Eclipse projects have a project-specific code style already set.

Version Control

I currently advise against installing the Mercurial plugin. Instead, just use Mercurial from the command line. The command hg addremove -s ? where ? is a percentage of similarity can be used to track renames. First do hg addremove -n -s ? to see if it does the right thing, then drop the -n.

IDEA

Sources

Don’t forget to rebuild the generated sources first! (See above.)

Setup

The project definitions are in place. Since I don’t use IDEA, I cannot tell you how to import/open them.

Other IDEs

Sources

Don’t forget to rebuild the generated sources first! (See above.)

Setup

Ideally, set up each component in its own project. Then you can define project dependencies to make sure you don’t violate .jar boundaries. The components are in components/. Each component has a bunch of source folders in components/.../src/.../. They might also have external jars in components/.../lib/.../ (see the files overview).

Make sure you also add components/compiler/temp/java and components/compiler/temp/java15 to the compiler component’s source path (generated sources).

Set line ending to Unix style (LF only) and character encoding to UTF-8.

Tests

Now make sure that, when running tests for a component, the current folder is set to the component’s folder (components/compiler, for example).

Code Style

Finally, you may want to update Java source code formatter rules for the preferred code style to use with AFC.