Skip to content

Commit 2870d10

Browse files
gnodetclaude
andcommitted
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>
1 parent c52a7ca commit 2870d10

2 files changed

Lines changed: 11 additions & 16 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: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -313,21 +313,18 @@ protected void copyDockerFiles(String buildDir) throws Exception {
313313
Files.createDirectories(docker);
314314
String[] ids = gav.split(":");
315315

316+
Map<String, Object> model = new HashMap<>();
317+
model.put("ArtifactId", ids[1]);
318+
model.put("Version", ids[2]);
319+
model.put("AppJar", ids[1] + "-" + ids[2] + ".jar");
320+
316321
String ftlName = "Dockerfile" + javaVersion + ".ftl";
317322
String context;
318323
try {
319-
Map<String, Object> model = new HashMap<>();
320-
model.put("ArtifactId", ids[1]);
321-
model.put("Version", ids[2]);
322-
model.put("AppJar", ids[1] + "-" + ids[2] + ".jar");
323324
context = TemplateHelper.processTemplate(ftlName, model);
324325
} catch (IOException e) {
325326
// fallback to JDK 21 template
326327
printer().printf("No Dockerfile template for Java %s, falling back to Java 21 template%n", javaVersion);
327-
Map<String, Object> model = new HashMap<>();
328-
model.put("ArtifactId", ids[1]);
329-
model.put("Version", ids[2]);
330-
model.put("AppJar", ids[1] + "-" + ids[2] + ".jar");
331328
context = TemplateHelper.processTemplate("Dockerfile21.ftl", model);
332329
}
333330
Files.writeString(docker.resolve("Dockerfile"), context);

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,15 +1913,13 @@ private void generateOpenApi() throws Exception {
19131913
throw new FileNotFoundException("Cannot find file: " + filePath);
19141914
}
19151915

1916-
{
1917-
Map<String, Object> model = new HashMap<>();
1918-
model.put("Spec", filePath.toString());
1919-
String content = TemplateHelper.processTemplate("rest-dsl.yaml.ftl", model);
1920-
Files.writeString(Paths.get(OPENAPI_GENERATED_FILE), content);
1916+
Map<String, Object> model = new HashMap<>();
1917+
model.put("Spec", filePath.toString());
1918+
String content = TemplateHelper.processTemplate("rest-dsl.yaml.ftl", model);
1919+
Files.writeString(Paths.get(OPENAPI_GENERATED_FILE), content);
19211920

1922-
// we need to include the spec on the classpath
1923-
files.add(openapi);
1924-
}
1921+
// we need to include the spec on the classpath
1922+
files.add(openapi);
19251923
}
19261924

19271925
private boolean knownFile(String file) throws Exception {

0 commit comments

Comments
 (0)