Fix #361: Generate Quarkus properties during camel export#380
Fix #361: Generate Quarkus properties during camel export#380JiriOndrusek wants to merge 1 commit into
Conversation
Translate forage properties to Quarkus-native equivalents in application.properties during `camel export --runtime=quarkus`. Property translation runs as a side effect in getDependencies(RuntimeType), which is the only PluginExporter hook called after application.properties is written that receives the runtime type. The build directory is derived from CommandLineHelper.CAMEL_JBANG_WORK_DIR (mirrors ExportBaseCommand.BUILD_DIR which is protected and not accessible from plugins).
📝 WalkthroughWalkthroughThis PR implements export-time translation of forage properties to Quarkus-native format. It adds an interface hook, wires up module descriptor discovery via ServiceLoader, builds a translator that scans and converts properties, integrates into the export plugin, and provides comprehensive tests for the translation and rewriting flows. ChangesExport-time property translation for Quarkus export
Sequence DiagramsequenceDiagram
participant User as camel export --runtime=quarkus
participant ForagePlugin
participant QuarkusPropertyTranslator
participant ServiceLoader
participant ModuleDescriptor
participant AppProperties as application.properties
User->>ForagePlugin: getDependencies(Quarkus)
ForagePlugin->>QuarkusPropertyTranslator: translate(buildDir)
QuarkusPropertyTranslator->>QuarkusPropertyTranslator: scanForageProperties()
QuarkusPropertyTranslator->>ServiceLoader: load ForageModuleDescriptors
ServiceLoader-->>QuarkusPropertyTranslator: [Agent, JDBC, JMS, CXF, RabbitMQ]
loop for each module type
QuarkusPropertyTranslator->>QuarkusPropertyTranslator: groupByPrefix()
loop for each named prefix
QuarkusPropertyTranslator->>ModuleDescriptor: translatePropertiesForExport(prefix, config)
ModuleDescriptor-->>QuarkusPropertyTranslator: quarkus.* properties
end
end
QuarkusPropertyTranslator-->>ForagePlugin: TranslationResult
ForagePlugin->>ForagePlugin: rewriteApplicationProperties(result)
ForagePlugin->>AppProperties: remove forage.*, append quarkus.* entries
AppProperties-->>User: exported with native Quarkus properties
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tooling/camel-jbang-plugin-forage/src/test/java/io/kaoto/forage/plugin/QuarkusPropertyTranslatorTest.java (1)
129-135: ⚡ Quick winMake named-instance prefix assertion strict.
This assertion allows unexpected extra groups to slip through. Prefer exact membership to catch regressions in prefix grouping.
✅ Suggested test tightening
assertThat(result.groups()) .extracting(QuarkusPropertyTranslator.TranslationGroup::prefix) - .contains("ds1", "ds2"); + .containsExactlyInAnyOrder("ds1", "ds2");🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tooling/camel-jbang-plugin-forage/src/test/java/io/kaoto/forage/plugin/QuarkusPropertyTranslatorTest.java` around lines 129 - 135, The test currently asserts prefixes with .extracting(QuarkusPropertyTranslator.TranslationGroup::prefix).contains("ds1", "ds2") which allows extra unexpected groups; change that assertion to require exact membership by using .containsOnly("ds1", "ds2") (or .containsExactly(...) if order matters) on the extracted prefixes from result.groups() in QuarkusPropertyTranslatorTest so the test fails when any extra prefix groups are present.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In
`@tooling/camel-jbang-plugin-forage/src/test/java/io/kaoto/forage/plugin/QuarkusPropertyTranslatorTest.java`:
- Around line 129-135: The test currently asserts prefixes with
.extracting(QuarkusPropertyTranslator.TranslationGroup::prefix).contains("ds1",
"ds2") which allows extra unexpected groups; change that assertion to require
exact membership by using .containsOnly("ds1", "ds2") (or .containsExactly(...)
if order matters) on the extracted prefixes from result.groups() in
QuarkusPropertyTranslatorTest so the test fails when any extra prefix groups are
present.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 35a03ae8-a441-46d5-8853-2add5f4ecb10
📒 Files selected for processing (12)
core/forage-core-common/src/main/java/io/kaoto/forage/core/common/ForageModuleDescriptor.javalibrary/ai/agents/forage-agent/src/main/java/io/kaoto/forage/agent/AgentModuleDescriptor.javalibrary/ai/agents/forage-agent/src/main/resources/META-INF/services/io.kaoto.forage.core.common.ForageModuleDescriptorlibrary/cxf/forage-cxf-common/src/main/resources/META-INF/services/io.kaoto.forage.core.common.ForageModuleDescriptorlibrary/jdbc/forage-jdbc-common/src/main/resources/META-INF/services/io.kaoto.forage.core.common.ForageModuleDescriptorlibrary/jms/forage-jms-common/src/main/resources/META-INF/services/io.kaoto.forage.core.common.ForageModuleDescriptorlibrary/messaging/forage-spring-rabbitmq-common/src/main/resources/META-INF/services/io.kaoto.forage.core.common.ForageModuleDescriptortooling/camel-jbang-plugin-forage/pom.xmltooling/camel-jbang-plugin-forage/src/main/java/io/kaoto/forage/plugin/ForagePlugin.javatooling/camel-jbang-plugin-forage/src/main/java/io/kaoto/forage/plugin/QuarkusPropertyTranslator.javatooling/camel-jbang-plugin-forage/src/test/java/io/kaoto/forage/plugin/ForagePluginRewriteTest.javatooling/camel-jbang-plugin-forage/src/test/java/io/kaoto/forage/plugin/QuarkusPropertyTranslatorTest.java
|
nice, does it work with |
I missed that there are |
|
I mean, there are |
you mean that, this works as well |
|
all properties known to forage are translated for the quarkus rubtime) during export and are put into application.properties |
|
@Croway I retested the export, where only were present (no application.properties) The exported project contains only application.properties with content Confirmed, that the use-case is working. |
|
that is great @JiriOndrusek , as we discussed let's keep the merge in hold, and merge it only after the next release (4.18.3) |
fixes #361
During camel export --runtime=quarkus, forage properties are now translated to their Quarkus-native
equivalents directly in application.properties, eliminating the need for runtime translation by the
forage plugin.
How it works
The translation hooks into PluginExporter.getDependencies(RuntimeType) — the only plugin hook called
after application.properties is written that receives the runtime type. For Quarkus exports, it:
properties grouped by module, with comments documenting the original forage properties that were
translated
Transformation examples
Key design decisions
allows overriding to skip runtime-only checks (e.g., AgentModuleDescriptor skips ServiceLoader-based
model provider lookup that would fail at export time)
the caller reloads it after translation to prevent leaking scanned values into subsequent operations
each translated group includes # Translated from: comments documenting the original forage properties
for traceability
Summary by CodeRabbit
New Features
Tests