Commit 4b22581
CAMEL-21208: Replace manual string-based code generation with FreeMarker templates (#22200)
* CAMEL-21208: Replace manual string-based code generation with FreeMarker templates in camel-jbang
- Add FreeMarker 2.3.34 dependency to camel-jbang-core
- Create TemplateHelper utility using square bracket syntax ([=var], [#if]...[/#if])
to avoid conflicts with ${...} (Maven) and <...> (XML) in generated content
- Convert all 23 .tmpl template files to .ftl FreeMarker templates
- Refactor 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
- Maintain backward compatibility for catalog-provided templates in ExportSpringBoot
- Remove 4 unreferenced templates (main-docker-*.tmpl, main-jkube-pom.tmpl)
- Keep deprecated bind templates (.tmpl) used by TemplateProvider
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* CAMEL-21208: Fix review findings
- Add backward compat check for old .tmpl catalog template name in ExportSpringBoot
- Remove dead model variables (CamelVersion, QuarkusManagementPort)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* CAMEL-21208: Minor cleanup from review
- Remove unnecessary bare block in Run.generateOpenApi (leftover from try-with-resources)
- Deduplicate model building in Export.copyDockerFiles
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* CAMEL-21208: Add unit test for TemplateHelper
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* CAMEL-21208: Expand TemplateHelper tests to cover all templates
Comprehensive test coverage for all 23 FreeMarker templates:
- FreeMarker-processed templates (processTemplate): code-java, main,
spring-boot-main, Dockerfile21/25, readme, readme.native,
rest-dsl.yaml, run-custom-camel-version, main-pom (with deps,
repos, jib/jkube), spring-boot-pom, quarkus-pom
- Init templates (raw text loading): java, yaml, xml, kamelet
source/sink/action, pipe, integration
Tests verify: license header stripping, placeholder resolution,
conditional rendering, list iteration, Maven ${} passthrough,
Kamelet {{}} passthrough, and missing template error handling.
Also regenerate jbang command docs after rebase.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent c4d3c50 commit 4b22581
51 files changed
Lines changed: 2180 additions & 886 deletions
File tree
- dsl/camel-jbang
- camel-jbang-core
- src
- main
- java/org/apache/camel/dsl/jbang/core
- commands
- common
- resources/templates
- test/java/org/apache/camel/dsl/jbang/core/common
- camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
155 | 162 | | |
156 | 163 | | |
157 | 164 | | |
| |||
Lines changed: 21 additions & 87 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | 25 | | |
| 26 | + | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
34 | | - | |
| 35 | + | |
35 | 36 | | |
36 | 37 | | |
37 | | - | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
300 | 300 | | |
301 | 301 | | |
302 | 302 | | |
303 | | - | |
304 | | - | |
305 | | - | |
306 | | - | |
307 | | - | |
308 | | - | |
309 | | - | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | | - | |
321 | | - | |
322 | | - | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | 303 | | |
370 | 304 | | |
371 | 305 | | |
| |||
378 | 312 | | |
379 | 313 | | |
380 | 314 | | |
381 | | - | |
382 | | - | |
383 | | - | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
384 | 326 | | |
385 | 327 | | |
386 | | - | |
| 328 | + | |
387 | 329 | | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | 330 | | |
396 | 331 | | |
397 | 332 | | |
398 | 333 | | |
399 | 334 | | |
400 | 335 | | |
401 | | - | |
402 | | - | |
403 | | - | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
404 | 340 | | |
405 | | - | |
406 | | - | |
407 | | - | |
| 341 | + | |
408 | 342 | | |
409 | 343 | | |
410 | 344 | | |
Lines changed: 139 additions & 56 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
408 | 408 | | |
409 | 409 | | |
410 | 410 | | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
415 | | - | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
416 | 418 | | |
417 | | - | |
418 | | - | |
419 | | - | |
420 | | - | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | | - | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
429 | 424 | | |
430 | 425 | | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | | - | |
439 | | - | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
444 | | - | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
445 | 474 | | |
446 | | - | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
447 | 543 | | |
448 | 544 | | |
449 | | - | |
450 | | - | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
451 | 549 | | |
452 | 550 | | |
453 | 551 | | |
| |||
489 | 587 | | |
490 | 588 | | |
491 | 589 | | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
492 | 594 | | |
493 | | - | |
494 | | - | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | | - | |
499 | | - | |
500 | | - | |
501 | | - | |
502 | | - | |
503 | | - | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
508 | | - | |
509 | | - | |
510 | | - | |
511 | | - | |
512 | | - | |
513 | | - | |
| 595 | + | |
514 | 596 | | |
515 | | - | |
| 597 | + | |
| 598 | + | |
516 | 599 | | |
517 | 600 | | |
518 | 601 | | |
| |||
0 commit comments