plc4x-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christofer Dutz <>
Subject Re: [DISCUSS] Which template engine to use for the code-generator
Date Thu, 28 Feb 2019 14:37:27 GMT
Hi all,

so I just pushed a first very raw version of the plugin.

The configuration currently looks like this:


The above config references both templates and dfdl schema locally, but it is my intention
to support classpath paths in there too.
The package name is needed as the templates are language dependent and not protocol dependent
and the protocols don't know about packages.
In the end, a user would add a "runtime" dependency to the module for a "template" project
and a "protocol" module.

For example we would have:
- JavaTemplates 
- CppTemplates
- PythonTemplates
- CsTemplates

And protocol modules for every supported protocol:

- S7Protocol
- ADSProtocol
- ModbusProtocol
- EtherNetIPProtocol

And with this we could generate:

- plc4j-s7-driver (package: "", JavaTemplates, S7Protocol)
- plc4j-modbus-driver (package: "", JavaTemplates, S7Protocol)
- plc4cpp-s7-driver (package: "org.apache.plc4x.cpp.s7", CppTemplates, S7Protocol)
I guess you get the point ...

Right now the plugin can accept a number of templates and a dfdl schema file. The plugin parses
this and for every root complexType it executes each of the templates.
If the template wants to output something, the first line of the generated output will contain
the file-name and directory structure for the output. 
After that comes the real content of the file.

Still have to work on the loading of resources from the classpath as this requires adding
more modules (the template modules) so I'm currently concentrating on how to generate code
Here I'll probably work on some helpers for common things I come across during my template

Just wanted to keep you guys updated ... 


Am 28.02.19, 10:15 schrieb "Julian Feinauer" <>:

    Hi Chris,
    I used and like both.
    But I have the impression that Freemarker is a bit more widespread for code generation
(is e.g. used in Apache Drill) in contrast to velcotiy which is often used for websites (my
    So I agree and also prefer freemarker for us.
    Von: Christofer Dutz <>
    Gesendet: Donnerstag, 28. Februar 2019 09:11:26
    Betreff: [DISCUSS] Which template engine to use for the code-generator
    Hi all,
    so yesterday I did the first commit for a new maven plugin (And yes it’s intentionally
not part of the main build).
    So today I will start with the code generation part … the thing is that we will be using
a templating system to define the templates for a given output format.
    Right now we could coose:
      *   Apache Velocity (
      *   Apache Freemarker (
    Usually the choice for an Apache project would have been Velocity as this was the Apache
project, but as recently Freemarker also is an Apache project, I would prefer the later.
    In my day job I have had the need to use Tempating engines multiple times and whenever
I used Freemarker, things were a lot simpler.
    So if there are now objections, I would start using Freemarker.

View raw message