Migrating from Stratego 1 to Stratego 2¶
Stratego 2 is somewhat unstable
Stratego 2 is quite new and has a lot of exciting new things going for it. But it is therefore also more unstable, with errors popping up somewhat regularly. Your project build may break or your code may behave in unexpected ways. Of course you can file bug reports.
Stratego 2 is the new version of Stratego that provides access to the incremental compiler and gradual type system that were developed for Stratego. Stratego 2 is accessible separately because it is organised quite differently from Stratego 1 and it provides a clear distinction and documentable upgrade path. This is that documented upgrade path. This How-To will guide you through the changes you need to make in your Spoofax project in order to use Stratego 2.
- Make sure you run the development version of Spoofax. This step will become obsolete in the future but currently Stratego 2 development is moving quickly and fixing bugs every week.
- In your
metaborg.yamlfile:- Add a compile dependency (
dependencies.compile) onorg.metaborg:stratego.lang:${metaborgVersion}(the Stratego 2 language) - Add a source dependency on
org.metaborg:strategolib:${metaborgVersion}(the Stratego 2 version of strategolib, the standard library) - Add a java dependency on
org.metaborg:strategolib:${metaborgVersion}(this is necessary for code generated by the Stratego compiler to find the standard library) - Remove from
language.stratego.argsthe-laandstratego-liblines (2 lines, leave the other-la) - Remove
language.stratego.buildif there, it is now ignored, all compilation will be incremental - Remove
language.stratego.formatif there, it is now ignored, the compilation is always to jar. If the format option you remove isctree, also search your.esvfiles for a lineprovider : target/metaborg/stratego.ctree, likely ineditor/Main.esv, and remove it.
- Add a compile dependency (
- Rename all
.strfiles in your project that are not insrc-gento.str2. Generated Stratego files insrc-genshould already have a.str2version next to the.strversion of the file. - Remove any imports to
libstratego-liborlibstrategolibin those renamed files. - Add the
strategolibimport to all your.str2files outside ofsrc-gen.
Stratego versions
The version numbers of Stratego are a little strange, Stratego and Stratego/XT used to number up to 0.17, then did not receive any more numbered releases even though small bugfixes and changes were released through Spoofax 1 and 2. In the current documentation we now consider this post-0.17 Stratego in Spoofax to be Stratego 1. This is not necessarily a statement of stability and matureness of the language but more to distinguish it from the new Stratego 2 project.
Imports in Stratego 2¶
At this point your project may be buildable again, but perhaps you are still getting errors about unresolved strategies or constructors. Stratego 2 has a stricter import policy than Stratego 1. If you use a strategy, rule or constructor, you must either define that strategy/rule/constructor in the module or import a module that defines it. Imports are no longer transitive for name resolution.
Created: June 3, 2025