Skip to content

Commit fc1a22f

Browse files
gnodetclaude
andcommitted
CAMEL-21960: camel-jbang - Auto-detect application.properties in run and export
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0a5416e commit fc1a22f

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

  • dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands

dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Export.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,21 @@ protected Integer doExport() throws Exception {
9595
}
9696
}
9797

98+
// auto-detect application.properties and include it
99+
{
100+
String name = baseDir.resolve("application.properties").toString();
101+
if (Files.exists(Paths.get(name)) && !files.contains(name)) {
102+
files.add(name);
103+
}
104+
}
105+
if (profile != null) {
106+
// need to include profile application properties if exists
107+
String name = baseDir.resolve("application-" + profile + ".properties").toString();
108+
if (Files.exists(Paths.get(name)) && !files.contains(name)) {
109+
files.add(name);
110+
}
111+
}
112+
98113
// application.properties
99114
doLoadAndInitProfileProperties(baseDir.resolve("application.properties"));
100115
if (profile != null) {

dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,13 @@ private int run() throws Exception {
728728
addDependencies(pomDependencies.toArray(new String[0]));
729729
}
730730

731+
// auto-detect application.properties and include it
732+
if (!empty && sourceDir == null) {
733+
String appProps = baseDir.resolve("application.properties").toString();
734+
if (Files.exists(Paths.get(appProps)) && !files.contains(appProps)) {
735+
files.add(appProps);
736+
}
737+
}
731738
if (profile != null) {
732739
// need to include profile application properties if exists
733740
String name = baseDir + "/application-" + profile + ".properties";

0 commit comments

Comments
 (0)