Incremental Compilation for Stratego


This feature has become very unstable in recent releases (2.5.10 and later) and will be replaced by a better tested rewrite.


This feature is fairly new, please open issues when your build fails or your program has different behaviour under this build setting.

The Stratego compiler is usually the slowest part in the build of a Spoofax project. To improve on the development experience, we have added an incremental compilation option for Stratego. This can be opted into by editing the metaborg.yaml file:

  - org.metaborg:org.metaborg.meta.lang.stratego:${metaborgVersion}
    build: incremental
    format: jar

Your file most likely said nothing of the build, meaning it was on the batch setting. The format was probably on ctree. If that is the case you will also need to find the provider setting in your ESV files, likely in editor/Main.esv. Find the ctree provider setting, it should now be:

provider: target/metaborg/stratego.jar

Note that a clean build using this setting is necessary at first. It will likely take significantly longer than a clean build using the ctree format. All subsequent builds should be faster.

As of Spoofax 2.5.7, there are no known limitations to the incremental compilation setting.


Eclipse specific “strategy is undefined” issue: If your project was generated by a Spoofax 2.5.11 or older, the project build path may not be up to date any more. This will result in errors where the compiled strategies are not found. These errors may look like so:

Caused by: org.metaborg.core.MetaborgException: Invoking Stratego strategy editor-outline failed, strategy is undefined

This error would show up once you open an editor for your language once you’ve built your language with the jar format instead of the ctree format. The solution to the problem is to add the src-gen/java directory to the build path in Eclipse. You can do this in the Package Explorer by right-clicking the src-gen/java directory, selecting “Build Path”, then selecting “Use as Source Folder”. Then clean, rebuild, and strategies should resolve again.