oss-review-toolkit / ort

A suite of tools to automate software compliance checks.
https://oss-review-toolkit.org
Apache License 2.0
1.61k stars 310 forks source link

Add a JTE reporter #8842

Open mnonnenmacher opened 4 months ago

mnonnenmacher commented 4 months ago

Add a JTE template reporter as an alternative to the Freemarker template reporter. In constrast to Freemarker, JTE supports Kotlin expressions in templates which would make it easier to call Kotlin code from the templates without having to learn another syntax.

sschuberth commented 2 weeks ago

It would be awesome of this allows us to get rid of the overly complex FreemarkerTemplateProcessor which basically just makes the Kotlin models more accessible from Freemarker.

sschuberth commented 2 weeks ago

make it easier to call Kotlin code from the templates without having to learn another syntax.

But isn't it so that e.g. control structures still require JTE syntax, like @for etc.? Because of that, just to document the idea, I was wondering whether we could instead simply create a Kotlin script reporter that returns a (huge) string which gets expanded / interpolated by standard Kotlin functionality.

mnonnenmacher commented 1 week ago

But isn't it so that e.g. control structures still requite JTE syntax, like @for etc.?

Yes.

Because of that, just do document the idea, I was wondering whether we could instead simply create a Kotlin script reporter that returns a (huge) string which gets expanded / interpolated by standard Kotlin functionality.

This is definitely also an option. It's somehow the opposite approach to template engines. With template engines you write the template in the native output format like Markdown and inject some code here and there, so the "main" syntax of the template file is that of the output format. With the Kotlin script approach the code part becomes easier, but it becomes harder to ensure that the syntax of the output format is followed (expect when a DSL for the format is available).

sschuberth commented 1 week ago

With the Kotlin script approach the code part becomes easier, but it becomes harder to ensure that the syntax of the output format is followed (expect when a DSL for the format is available).

True. Maybe IntelliJ language injections could help here.