Acceleo 3 and properties

Posté le dans Blog
Since I'm often brought to develop acceleo generators, I often had to design my templates so that they can be easily parameterized by users.
This is important since by doing so, acceleo modules are flexible enough to fit my users needs and (hopefully) I don't have to update modules too often.
Of course, you need to carefully design your templates to achieve this modularity. But for simple needs, simple solutions are the best.
Acceleo natively supports the use of properties files which is an efficient and simple way to parameterize generation module: Properties are generally simple to understand and users can use them easily.
Well, Acceleo 3 is out, and of course properties are still supported. I just wanted to point out something I stumble upon just recently: Properties files are now accessed via the java ResourceBundle mechanism. And consequently, they need to be in the classpath in order to be accessed at runtime.
So, as a module developer, you'll place your default properties files (those you provide with your modules in order to have a sensible default behavior) in a package of your module project.
Well, don't forget to check that this package is exported at runtime, otherwise your properties won't be accessible when you run your generations!


You probably already know how to do it but just in case: open the META-INF/MANIFEST.MF file, and in the Runtime tab just add the package(s) that contain your properties files.
And since you need to do this also for your entry point templates, it may be a good idea to place default properties files in the same package as the entry point template files?
Auteur d'origine: Laurent