Hi all,
so I just pushed a first very raw version of the plugin.
The configuration currently looks like this:
<plugin>
<groupId>org.apache.plc4x.plugins</groupId>
<artifactId>plc4x-maven-plugin</artifactId>
<configuration>
<package-name>org.apache.plc4x.test</package-name>
<dfdl-schema>${pom.basedir}/src/main/resources/protocol.dfdl.xsd</dfdl-schema>
<templates>
<tempate>${pom.basedir}/src/main/resources/template.ftlh</tempate>
</templates>
</configuration>
</plugin>
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: "org.apache.plc4x.java.s7", JavaTemplates,
S7Protocol)
- plc4j-modbus-driver (package: "org.apache.plc4x.java.modbus", 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 writing.
Just wanted to keep you guys updated ...
Chris
Am 28.02.19, 10:15 schrieb "Julian Feinauer" <[email protected]>:
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 impressions).
So I agree and also prefer freemarker for us.
Julian
________________________________
Von: Christofer Dutz <[email protected]>
Gesendet: Donnerstag, 28. Februar 2019 09:11:26
An: [email protected]
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 (https://velocity.apache.org/)
* Apache Freemarker (https://freemarker.apache.org/)
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.
Chris