gnodet opened a new pull request, #22200:
URL: https://github.com/apache/camel/pull/22200
## Summary
- Add FreeMarker 2.3.34 as a template engine dependency to camel-jbang-core
- Create `TemplateHelper` utility using FreeMarker's square bracket syntax
(`[=var]`, `[#if]...[/#if]`) to avoid conflicts with `${...}` (Maven/Camel
expressions) and `<...>` (XML tags) in generated content
- Convert all 23 `.tmpl` template files to `.ftl` FreeMarker templates with
proper directives for conditionals and loops
- Refactor `ExportCamelMain`, `ExportSpringBoot`, `ExportQuarkus`, `Export`,
`Run`, and `Init` commands to use `TemplateHelper` instead of manual
`StringBuilder`/`replaceAll`/`replaceFirst` code generation
- Extract shared helpers (`buildRepositoryList`, `buildDependencyList`,
`formatBuildProperties`, `mavenGavComparator`) into `ExportBaseCommand` to
eliminate duplication
- Maintain backward compatibility for catalog-provided templates in
`ExportSpringBoot` (legacy regex processing path)
- Remove 4 unreferenced templates (`main-docker-*.tmpl`,
`main-jkube-pom.tmpl`)
- Keep deprecated bind templates (`.tmpl`) used by `TemplateProvider`
## Motivation
The existing code generation approach used raw string manipulation
(`replaceFirst`, `replaceAll`, `StringBuilder.append`) to produce POM files,
Dockerfiles, README files, and source code. This was:
- Error-prone (regex escaping issues, ordering dependencies between
replacements)
- Hard to read and maintain (XML structure buried in Java string
concatenation)
- Difficult to extend (adding new conditional sections required careful
regex surgery)
FreeMarker templates make the generated output structure visible and
maintainable, with proper control flow (`[#if]`, `[#list]`) replacing ad-hoc
string manipulation.
## Test plan
- [x] All 311 camel-jbang-core tests pass
- [x] All 128 camel-jbang-plugin-kubernetes tests pass
- [ ] CI build passes
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]