This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 4ce08fcab44 CAMEL-22288: camel-jbang: run/export to support using a
directory as file name so you do not have to cd into the dir to do this (#18827)
4ce08fcab44 is described below
commit 4ce08fcab440652d8a23091b0c0fdb34ead22125
Author: Claus Ibsen <[email protected]>
AuthorDate: Tue Aug 5 17:29:00 2025 +0200
CAMEL-22288: camel-jbang: run/export to support using a directory as file
name so you do not have to cd into the dir to do this (#18827)
---
.../dsl/jbang/core/commands/DependencyList.java | 24 ++++----
.../camel/dsl/jbang/core/commands/Export.java | 32 +++++++----
.../dsl/jbang/core/commands/ExportBaseCommand.java | 11 ++--
.../dsl/jbang/core/commands/ExportCamelMain.java | 2 +-
.../dsl/jbang/core/commands/ExportQuarkus.java | 2 +-
.../dsl/jbang/core/commands/ExportSpringBoot.java | 2 +-
.../apache/camel/dsl/jbang/core/commands/Run.java | 44 ++++++++------
.../camel/dsl/jbang/core/commands/RunHelper.java | 6 +-
.../dsl/jbang/core/commands/SBOMGenerator.java | 20 +++++--
.../camel/dsl/jbang/core/commands/ExportTest.java | 36 ++++++++++++
.../test/resources/myapp/application.properties | 18 ++++++
.../src/test/resources/myapp/hello.yaml | 28 +++++++++
.../core/commands/kubernetes/KubernetesExport.java | 23 ++++++--
.../core/commands/kubernetes/KubernetesRun.java | 67 +++++++++++++++-------
.../commands/kubernetes/KubernetesCommandTest.java | 2 +-
.../commands/kubernetes/KubernetesExportTest.java | 27 ++++++++-
.../kubernetes/KubernetesRunCustomTest.java | 12 ++--
.../commands/kubernetes/KubernetesRunTest.java | 18 +++---
.../test/resources/myapp/application.properties | 18 ++++++
.../src/test/resources/myapp/route.yaml | 23 ++++++++
20 files changed, 319 insertions(+), 96 deletions(-)
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/DependencyList.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/DependencyList.java
index 65b18993899..8890851e6ae 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/DependencyList.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/DependencyList.java
@@ -37,6 +37,7 @@ import org.apache.camel.dsl.jbang.core.common.RuntimeType;
import org.apache.camel.dsl.jbang.core.common.XmlHelper;
import org.apache.camel.tooling.maven.MavenGav;
import org.apache.camel.util.CamelCaseOrderedProperties;
+import org.apache.camel.util.FileUtil;
import picocli.CommandLine;
@CommandLine.Command(name = "list",
@@ -66,12 +67,15 @@ public class DependencyList extends Export {
return 1;
}
- // automatic detect maven/gradle based projects and use that
- if (files.isEmpty()) {
- if (Files.exists(Paths.get("pom.xml"))) {
- files.add("pom.xml");
- } else if (Files.exists(Paths.get("build.gradle"))) {
- files.add("build.gradle");
+ exportBaseDir = Path.of(".");
+
+ // special if user type: camel run . or camel run dirName
+ if (files != null && files.size() == 1) {
+ String name = FileUtil.stripTrailingSeparator(files.get(0));
+ Path first = Path.of(name);
+ if (Files.isDirectory(first)) {
+ exportBaseDir = first;
+ RunHelper.dirToFiles(name, files);
}
}
@@ -218,7 +222,7 @@ public class DependencyList extends Export {
protected Integer doExport() throws Exception {
// read runtime and gav from properties if not configured
- Path profile = Paths.get("application.properties");
+ Path profile = exportBaseDir.resolve("application.properties");
if (Files.exists(profile)) {
Properties prop = new CamelCaseOrderedProperties();
try (InputStream is = Files.newInputStream(profile)) {
@@ -255,13 +259,13 @@ public class DependencyList extends Export {
// turn off noise
switch (runtime) {
case springBoot -> {
- return export(new ExportSpringBoot(getMain()));
+ return export(exportBaseDir, new ExportSpringBoot(getMain()));
}
case quarkus -> {
- return export(new ExportQuarkus(getMain()));
+ return export(exportBaseDir, new ExportQuarkus(getMain()));
}
case main -> {
- return export(new ExportCamelMain(getMain()));
+ return export(exportBaseDir, new ExportCamelMain(getMain()));
}
default -> {
printer().printErr("Unknown runtime: " + runtime);
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Export.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Export.java
index 4e3d7e0b14e..7ce7e16bf99 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Export.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Export.java
@@ -60,11 +60,23 @@ public class Export extends ExportBaseCommand {
}
protected Integer doExport() throws Exception {
+ Path baseDir = exportBaseDir != null ? exportBaseDir : Path.of(".");
+
+ // special if user type: camel run . or camel run dirName
+ if (files != null && files.size() == 1) {
+ String name = FileUtil.stripTrailingSeparator(files.get(0));
+ Path first = Path.of(name);
+ if (Files.isDirectory(first)) {
+ baseDir = first;
+ RunHelper.dirToFiles(name, files);
+ }
+ }
+
// application.properties
- doLoadAndInitProfileProperties(Paths.get("application.properties"));
+
doLoadAndInitProfileProperties(baseDir.resolve("application.properties"));
if (profile != null) {
// override from profile specific configuration
- doLoadAndInitProfileProperties(Paths.get("application-" + profile
+ ".properties"));
+ doLoadAndInitProfileProperties(baseDir.resolve("application-" +
profile + ".properties"));
}
if (runtime == null) {
@@ -90,13 +102,13 @@ public class Export extends ExportBaseCommand {
switch (runtime) {
case springBoot -> {
- return export(new ExportSpringBoot(getMain()));
+ return export(baseDir, new ExportSpringBoot(getMain()));
}
case quarkus -> {
- return export(new ExportQuarkus(getMain()));
+ return export(baseDir, new ExportQuarkus(getMain()));
}
case main -> {
- return export(new ExportCamelMain(getMain()));
+ return export(baseDir, new ExportCamelMain(getMain()));
}
default -> {
printer().printErr("Unknown runtime: " + runtime);
@@ -163,8 +175,9 @@ public class Export extends ExportBaseCommand {
}
}
- protected Integer export(ExportBaseCommand cmd) throws Exception {
+ protected Integer export(Path exportBaseDir, ExportBaseCommand cmd) throws
Exception {
// copy properties from this to cmd
+ cmd.exportBaseDir = exportBaseDir;
cmd.files = this.files;
cmd.repositories = this.repositories;
cmd.dependencies = this.dependencies;
@@ -226,12 +239,7 @@ public class Export extends ExportBaseCommand {
}
}
- // special if user type: camel export .
- if (files.size() == 1 && ".".equals(files.get(0))) {
- RunHelper.dotToFiles(files);
- }
-
- if (!files.isEmpty()) {
+ if (files != null && !files.isEmpty()) {
return FileUtil.onlyName(SourceScheme.onlyName(files.get(0)));
}
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java
index cb5a4bd40f0..190447f657d 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportBaseCommand.java
@@ -91,8 +91,8 @@ public abstract class ExportBaseCommand extends CamelCommand {
private static final Set<String> EXCLUDED_GROUP_IDS =
Set.of("org.fusesource.jansi", "org.apache.logging.log4j");
+ protected Path exportBaseDir;
private MavenDownloader downloader;
-
private Printer quietPrinter;
@CommandLine.Parameters(description = "The Camel file(s) to export. If no
files is specified then what was last run will be exported.",
@@ -357,6 +357,7 @@ public abstract class ExportBaseCommand extends
CamelCommand {
protected Integer runSilently(boolean ignoreLoadingError, boolean
lazyBean, boolean verbose) throws Exception {
Run run = new Run(getMain());
// need to declare the profile to use for run
+ run.exportBaseDir = exportBaseDir;
run.dependencies = dependencies;
run.files = files;
run.name = name;
@@ -1116,7 +1117,7 @@ public abstract class ExportBaseCommand extends
CamelCommand {
return dependency;
}
- protected static MavenGav parseMavenGav(String dep) {
+ protected MavenGav parseMavenGav(String dep) {
MavenGav gav;
if (dep.startsWith("lib:") && dep.endsWith(".jar")) {
// lib:commons-lang3-3.12.0.jar
@@ -1145,8 +1146,8 @@ public abstract class ExportBaseCommand extends
CamelCommand {
return gav;
}
- private static MavenGav parseLocalJar(String dep) {
- Path path = Paths.get(dep + ".jar");
+ private MavenGav parseLocalJar(String dep) {
+ Path path = exportBaseDir.resolve(dep + ".jar");
if (!Files.isRegularFile(path) || !Files.exists(path)) {
return null;
}
@@ -1219,7 +1220,7 @@ public abstract class ExportBaseCommand extends
CamelCommand {
protected void copyApplicationPropertiesFiles(Path srcResourcesDir) throws
Exception {
try {
- Files.list(Paths.get("."))
+ Files.list(exportBaseDir)
.filter(p -> Files.isRegularFile(p))
.filter(p -> {
String fileName = p.getFileName().toString();
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportCamelMain.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportCamelMain.java
index cc1e7a8ae82..aef37eb4085 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportCamelMain.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportCamelMain.java
@@ -76,7 +76,7 @@ class ExportCamelMain extends Export {
printer().println("Exporting as Camel Main project to: " + exportDir);
- Path profile = Path.of("application.properties");
+ Path profile = exportBaseDir.resolve("application.properties");
// use a temporary work dir
Path buildDir = Path.of(BUILD_DIR);
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportQuarkus.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportQuarkus.java
index 8629174a251..1565b2f5b36 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportQuarkus.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportQuarkus.java
@@ -62,7 +62,7 @@ class ExportQuarkus extends Export {
return 1;
}
- Path profile = Path.of("application.properties");
+ Path profile = exportBaseDir.resolve("application.properties");
// the settings file has information what to export
Path settings =
CommandLineHelper.getWorkDir().resolve(Run.RUN_SETTINGS_FILE);
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportSpringBoot.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportSpringBoot.java
index 6dbc75a1b58..a2886873409 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportSpringBoot.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportSpringBoot.java
@@ -63,7 +63,7 @@ class ExportSpringBoot extends Export {
return 1;
}
- Path profile = Path.of("application.properties");
+ Path profile = exportBaseDir.resolve("application.properties");
// the settings file has information what to export
Path settings =
CommandLineHelper.getWorkDir().resolve(Run.RUN_SETTINGS_FILE);
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
index 44ddd81e435..ea5c63e702c 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/Run.java
@@ -111,6 +111,7 @@ public class Run extends CamelCommand {
"^\\s*public class\\s+([a-zA-Z0-9]*)[\\s+|;].*$",
Pattern.MULTILINE);
public boolean exportRun;
+ protected Path exportBaseDir;
boolean scriptRun;
boolean transformRun;
boolean transformMessageRun;
@@ -429,10 +430,10 @@ public class Run extends CamelCommand {
}
}
- private Properties loadProfileProperties(Path source) throws Exception {
+ private Properties loadProfilePropertiesFile(Path file) throws Exception {
Properties prop = new CamelCaseOrderedProperties();
- if (Files.exists(source)) {
- try (InputStream is = Files.newInputStream(source)) {
+ if (Files.exists(file)) {
+ try (InputStream is = Files.newInputStream(file)) {
prop.load(is);
}
}
@@ -463,9 +464,16 @@ public class Run extends CamelCommand {
return 1;
}
- // special if user type: camel run .
- if (sourceDir == null && (files != null && files.size() == 1 &&
".".equals(files.get(0)))) {
- RunHelper.dotToFiles(files);
+ Path baseDir = exportBaseDir != null ? exportBaseDir : Path.of(".");
+
+ // special if user type: camel run . or camel run dirName
+ if (sourceDir == null && files != null && files.size() == 1) {
+ String name = FileUtil.stripTrailingSeparator(files.get(0));
+ Path first = Path.of(name);
+ if (Files.isDirectory(first)) {
+ baseDir = first;
+ RunHelper.dirToFiles(name, files);
+ }
}
if (!exportRun) {
@@ -486,8 +494,8 @@ public class Run extends CamelCommand {
}
}
- Properties profileProperties = !empty ? loadProfileProperties() : null;
- configureLogging();
+ Properties profileProperties = !empty ? loadProfileProperties(baseDir)
: null;
+ configureLogging(baseDir);
if (openapi != null) {
generateOpenApi();
}
@@ -719,21 +727,21 @@ public class Run extends CamelCommand {
// if we only run pom.xml/build.gradle then auto discover from the
Maven/Gradle based project
if (files.size() == 1 && (files.get(0).endsWith("pom.xml") ||
files.get(0).endsWith("build.gradle"))) {
- Path projectDescriptorPath =
Path.of(files.get(0)).toAbsolutePath();
+ Path projectDir = Path.of(files.get(0)).toAbsolutePath();
// use a better name when running
if (name == null || "CamelJBang".equals(name)) {
- name = RunHelper.mavenArtifactId(projectDescriptorPath);
+ name = RunHelper.mavenArtifactId(projectDir);
}
// find source files
- files =
RunHelper.scanMavenOrGradleProject(projectDescriptorPath.getParent());
+ files = RunHelper.scanMavenOrGradleProject(projectDir.getParent());
// include extra dependencies from pom.xml
- var pomDependencies =
RunHelper.scanMavenDependenciesFromPom(projectDescriptorPath);
+ var pomDependencies =
RunHelper.scanMavenDependenciesFromPom(projectDir);
addDependencies(pomDependencies.toArray(new String[0]));
}
if (profile != null) {
// need to include profile application properties if exists
- String name = "application-" + profile + ".properties";
+ String name = baseDir + "/application-" + profile + ".properties";
if (Files.exists(Paths.get(name)) && !files.contains(name)) {
files.add(name);
}
@@ -1274,7 +1282,7 @@ public class Run extends CamelCommand {
}
}
- private Properties loadProfileProperties() throws Exception {
+ private Properties loadProfileProperties(Path baseDir) throws Exception {
Properties answer = null;
if (transformMessageRun) {
@@ -1287,7 +1295,7 @@ public class Run extends CamelCommand {
if (sourceDir != null) {
profilePropertiesPath =
Paths.get(sourceDir).resolve("application.properties");
} else {
- profilePropertiesPath = Paths.get("application.properties");
+ profilePropertiesPath = baseDir.resolve("application.properties");
}
// based application-profile.properties
answer = doLoadAndInitProfileProperties(profilePropertiesPath);
@@ -1318,7 +1326,7 @@ public class Run extends CamelCommand {
private Properties doLoadAndInitProfileProperties(Path
profilePropertiesPath) throws Exception {
Properties answer = null;
if (Files.exists(profilePropertiesPath)) {
- answer = this.loadProfileProperties((Path) profilePropertiesPath);
+ answer = loadProfilePropertiesFile(profilePropertiesPath);
// logging level/color may be configured in the properties file
loggingLevel = answer.getProperty("loggingLevel", loggingLevel);
loggingColor
@@ -1765,10 +1773,10 @@ public class Run extends CamelCommand {
return main;
}
- private void configureLogging() throws Exception {
+ private void configureLogging(Path baseDir) throws Exception {
if (logging) {
// allow to configure individual logging levels in
application.properties
- Properties prop = loadProfileProperties();
+ Properties prop = loadProfileProperties(baseDir);
if (prop != null) {
for (Object obj : prop.keySet()) {
String key = obj.toString();
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/RunHelper.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/RunHelper.java
index d9ccd971fd6..0cdc018b483 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/RunHelper.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/RunHelper.java
@@ -285,10 +285,10 @@ public final class RunHelper {
/**
* When using camel run . or camel export . then dot should include all
the files in the current folder.
*/
- public static void dotToFiles(List<String> files) {
+ public static void dirToFiles(String dir, List<String> files) {
files.clear();
try {
- Files.list(Paths.get("."))
+ Files.list(Paths.get(dir))
.filter(p -> {
try {
return Files.isRegularFile(p) &&
!Files.isHidden(p);
@@ -296,7 +296,7 @@ public final class RunHelper {
return false;
}
})
- .forEach(p -> files.add(p.getFileName().toString()));
+ .forEach(f -> files.add(dir + "/" + f.getFileName()));
} catch (IOException e) {
// Ignore
}
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/SBOMGenerator.java
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/SBOMGenerator.java
index 77ac173e05b..7087333b9ec 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/SBOMGenerator.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/SBOMGenerator.java
@@ -78,6 +78,18 @@ public class SBOMGenerator extends Export {
@Override
protected Integer export() throws Exception {
+ exportBaseDir = Path.of(".");
+
+ // special if user type: camel run . or camel run dirName
+ if (files != null && files.size() == 1) {
+ String name = FileUtil.stripTrailingSeparator(files.get(0));
+ Path first = Path.of(name);
+ if (Files.isDirectory(first)) {
+ exportBaseDir = first;
+ RunHelper.dirToFiles(name, files);
+ }
+ }
+
Integer answer = doExport();
if (answer == 0) {
Path buildDir = Paths.get(EXPORT_DIR);
@@ -149,7 +161,7 @@ public class SBOMGenerator extends Export {
protected Integer doExport() throws Exception {
// read runtime and gav from properties if not configured
- Path profile = Paths.get("application.properties");
+ Path profile = exportBaseDir.resolve("application.properties");
if (Files.exists(profile)) {
Properties prop = new CamelCaseOrderedProperties();
RuntimeUtil.loadProperties(prop, profile);
@@ -181,13 +193,13 @@ public class SBOMGenerator extends Export {
switch (runtime) {
case springBoot -> {
- return export(new ExportSpringBoot(getMain()));
+ return export(exportBaseDir, new ExportSpringBoot(getMain()));
}
case quarkus -> {
- return export(new ExportQuarkus(getMain()));
+ return export(exportBaseDir, new ExportQuarkus(getMain()));
}
case main -> {
- return export(new ExportCamelMain(getMain()));
+ return export(exportBaseDir, new ExportCamelMain(getMain()));
}
default -> {
printer().printErr("Unknown runtime: " + runtime);
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExportTest.java
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExportTest.java
index 65275127193..3e0b782c09c 100644
---
a/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExportTest.java
+++
b/dsl/camel-jbang/camel-jbang-core/src/test/java/org/apache/camel/dsl/jbang/core/commands/ExportTest.java
@@ -654,4 +654,40 @@ class ExportTest {
}
}
+ @ParameterizedTest
+ @MethodSource("runtimeProvider")
+ public void shouldExportFromDir(RuntimeType rt) throws Exception {
+ LOG.info("shouldExportFromDir {}", rt);
+ Export command = new Export(new CamelJBangMain());
+ CommandLine.populateCommand(command, "--gav=examples:route:1.0.0",
"--dir=" + workingDir,
+ "--runtime=%s".formatted(rt.runtime()),
"src/test/resources/myapp");
+ int exit = command.doCall();
+
+ Assertions.assertEquals(0, exit);
+ Model model = readMavenModel();
+ Assertions.assertEquals("examples", model.getGroupId());
+ Assertions.assertEquals("route", model.getArtifactId());
+ Assertions.assertEquals("1.0.0", model.getVersion());
+
+ File f =
workingDir.toPath().resolve("src/main/resources/application.properties").toFile();
+ Assertions.assertTrue(f.isFile());
+ Assertions.assertTrue(f.exists());
+ f =
workingDir.toPath().resolve("src/main/resources/camel/hello.yaml").toFile();
+ Assertions.assertTrue(f.isFile());
+ Assertions.assertTrue(f.exists());
+
+ if (rt == RuntimeType.main) {
+ Assertions.assertTrue(
+ containsDependency(model.getDependencies(),
"org.apache.camel", "camel-timer", null));
+ } else if (rt == RuntimeType.springBoot) {
+ Assertions.assertTrue(
+ containsDependency(model.getDependencies(),
"org.apache.camel.springboot",
+ "camel-timer-starter", null));
+ } else if (rt == RuntimeType.quarkus) {
+ Assertions.assertTrue(
+ containsDependency(model.getDependencies(),
"org.apache.camel.quarkus",
+ "camel-quarkus-timer", null));
+ }
+ }
+
}
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/test/resources/myapp/application.properties
b/dsl/camel-jbang/camel-jbang-core/src/test/resources/myapp/application.properties
new file mode 100644
index 00000000000..571461af637
--- /dev/null
+++
b/dsl/camel-jbang/camel-jbang-core/src/test/resources/myapp/application.properties
@@ -0,0 +1,18 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+camel.main.name = MySuperApp
diff --git
a/dsl/camel-jbang/camel-jbang-core/src/test/resources/myapp/hello.yaml
b/dsl/camel-jbang/camel-jbang-core/src/test/resources/myapp/hello.yaml
new file mode 100644
index 00000000000..d3b7b551a7f
--- /dev/null
+++ b/dsl/camel-jbang/camel-jbang-core/src/test/resources/myapp/hello.yaml
@@ -0,0 +1,28 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# camel-k: language=yaml
+
+# Write your routes here, for example:
+- from:
+ uri: "timer:yaml"
+ parameters:
+ period: "1000"
+ steps:
+ - setBody:
+ constant: "Hello Camel from yaml"
+ - log: "${body}"
diff --git
a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesExport.java
b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesExport.java
index c4efc83526e..da5929c95ef 100644
---
a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesExport.java
+++
b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesExport.java
@@ -37,6 +37,7 @@ import org.apache.camel.dsl.jbang.core.commands.Export;
import org.apache.camel.dsl.jbang.core.commands.ExportBaseCommand;
import org.apache.camel.dsl.jbang.core.commands.ExportHelper;
import org.apache.camel.dsl.jbang.core.commands.Run;
+import org.apache.camel.dsl.jbang.core.commands.RunHelper;
import org.apache.camel.dsl.jbang.core.commands.kubernetes.traits.TraitCatalog;
import org.apache.camel.dsl.jbang.core.commands.kubernetes.traits.TraitContext;
import org.apache.camel.dsl.jbang.core.commands.kubernetes.traits.TraitHelper;
@@ -48,6 +49,7 @@ import org.apache.camel.dsl.jbang.core.common.RuntimeUtil;
import org.apache.camel.dsl.jbang.core.common.Source;
import org.apache.camel.dsl.jbang.core.common.SourceHelper;
import org.apache.camel.util.CamelCaseOrderedProperties;
+import org.apache.camel.util.FileUtil;
import org.apache.camel.util.StringHelper;
import picocli.CommandLine;
import picocli.CommandLine.Command;
@@ -135,7 +137,7 @@ public class KubernetesExport extends Export {
public KubernetesExport(CamelJBangMain main, String[] files) {
super(main);
- this.files = Arrays.asList(files);
+ this.files.addAll(Arrays.asList(files));
}
public KubernetesExport(CamelJBangMain main, ExportConfigurer configurer) {
@@ -144,6 +146,7 @@ public class KubernetesExport extends Export {
runtime = configurer.runtime;
quarkusVersion = configurer.quarkusVersion;
+ exportBaseDir = configurer.exportBaseDir;
files = configurer.files;
name = configurer.name;
gav = configurer.gav;
@@ -189,6 +192,16 @@ public class KubernetesExport extends Export {
runtime = RuntimeType.quarkus;
}
+ // special if user type: camel run . or camel run dirName
+ if (files != null && files.size() == 1) {
+ String name = FileUtil.stripTrailingSeparator(files.get(0));
+ Path first = Path.of(name);
+ if (Files.isDirectory(first)) {
+ exportBaseDir = first;
+ RunHelper.dirToFiles(name, files);
+ }
+ }
+
printer().println("Exporting application ...");
if (!buildTool.equals("maven")) {
@@ -275,7 +288,8 @@ public class KubernetesExport extends Export {
var applicationProfileProperties = new String[0];
if (this.profile != null) {
// override from profile specific configuration
- applicationProfileProperties =
extractPropertiesTraits(Paths.get("application-" + profile + ".properties"));
+ applicationProfileProperties
+ =
extractPropertiesTraits(exportBaseDir.resolve("application-" + profile +
".properties"));
}
Traits traitsSpec = getTraitSpec(applicationProfileProperties,
applicationProperties);
@@ -395,7 +409,7 @@ public class KubernetesExport extends Export {
return 0;
}
- protected Integer export(ExportBaseCommand cmd) throws Exception {
+ protected Integer export(Path exportBaseDir, ExportBaseCommand cmd) throws
Exception {
if (runtime == RuntimeType.quarkus) {
cmd.pomTemplateName = "quarkus-kubernetes-pom.tmpl";
}
@@ -405,7 +419,7 @@ public class KubernetesExport extends Export {
if (runtime == RuntimeType.main) {
cmd.pomTemplateName = "main-kubernetes-pom.tmpl";
}
- return super.export(cmd);
+ return super.export(exportBaseDir, cmd);
}
protected Traits getTraitSpec(String[] applicationProfileProperties,
String[] applicationProperties) {
@@ -588,6 +602,7 @@ public class KubernetesExport extends Export {
* Configurer used to customize internal options for the Export command.
*/
public record ExportConfigurer(RuntimeType runtime,
+ Path exportBaseDir,
String quarkusVersion,
List<String> files,
String name,
diff --git
a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesRun.java
b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesRun.java
index dd726e11269..122b7beef6e 100644
---
a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesRun.java
+++
b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/main/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesRun.java
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.camel.dsl.jbang.core.commands.kubernetes;
import java.io.FileFilter;
@@ -24,8 +23,8 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
+import java.util.Stack;
import java.util.concurrent.TimeUnit;
import io.fabric8.kubernetes.api.model.Pod;
@@ -38,6 +37,7 @@ import io.vertx.core.file.FileSystemOptions;
import org.apache.camel.CamelContext;
import org.apache.camel.dsl.jbang.core.commands.CamelJBangMain;
import org.apache.camel.dsl.jbang.core.commands.CommandHelper;
+import org.apache.camel.dsl.jbang.core.commands.RunHelper;
import org.apache.camel.dsl.jbang.core.commands.kubernetes.traits.BaseTrait;
import org.apache.camel.dsl.jbang.core.commands.kubernetes.traits.TraitHelper;
import org.apache.camel.dsl.jbang.core.commands.kubernetes.traits.model.Traits;
@@ -59,9 +59,11 @@ import static
org.apache.camel.dsl.jbang.core.commands.kubernetes.KubernetesHelp
@CommandLine.Command(name = "run", description = "Run Camel application on
Kubernetes", sortOptions = false)
public class KubernetesRun extends KubernetesBaseCommand {
- @CommandLine.Parameters(description = "The Camel file(s) to run.",
- arity = "0..9", paramLabel = "<files>")
- String[] filePaths;
+ @CommandLine.Parameters(description = "The Camel file(s) to run. If no
files specified then application.properties is used as source for which files
to run.",
+ arity = "0..9", paramLabel = "<files>",
parameterConsumer = FilesConsumer.class)
+ Path[] filePaths; // Defined only for file path completion; the field
never used
+
+ public List<String> files = new ArrayList<>();
@CommandLine.Option(names = { "--service-account" }, description = "The
service account used to run the application.")
String serviceAccount;
@@ -281,30 +283,41 @@ public class KubernetesRun extends KubernetesBaseCommand {
private int devModeReloadCount;
private KubernetesPodLogs reusablePodLogs;
-
private Printer quietPrinter;
public KubernetesRun(CamelJBangMain main) {
this(main, null);
}
- public KubernetesRun(CamelJBangMain main, String[] files) {
+ public KubernetesRun(CamelJBangMain main, List<String> files) {
super(main);
- filePaths = files;
+ if (files != null) {
+ this.files.addAll(files);
+ }
projectNameSuppliers.add(() -> projectNameFromImage(() -> image));
projectNameSuppliers.add(() -> projectNameFromGav(() -> gav));
- projectNameSuppliers.add(() -> projectNameFromFilePath(() ->
firstFilePath()));
+ projectNameSuppliers.add(() ->
projectNameFromFilePath(this::firstFilePath));
}
private String firstFilePath() {
- return filePaths != null && filePaths.length > 0 ? filePaths[0] : null;
+ return !files.isEmpty() ? files.get(0) : null;
}
public Integer doCall() throws Exception {
String projectName = getProjectName();
+ Path baseDir = Path.of(".");
+ if (files.size() == 1) {
+ String name = FileUtil.stripTrailingSeparator(files.get(0));
+ Path first = Path.of(name);
+ if (Files.isDirectory(first)) {
+ baseDir = first;
+ RunHelper.dirToFiles(name, files);
+ }
+ }
+
String workingDir = getIndexedWorkingDir(projectName);
- KubernetesExport export = configureExport(workingDir);
+ KubernetesExport export = configureExport(workingDir, baseDir);
int exit = export.export();
if (exit != 0) {
printer().printErr("Project export failed!");
@@ -361,7 +374,7 @@ public class KubernetesRun extends KubernetesBaseCommand {
}
if (dev) {
- setupDevMode(projectName, workingDir);
+ setupDevMode(projectName, workingDir, baseDir);
}
if (dev || logs) {
@@ -379,12 +392,13 @@ public class KubernetesRun extends KubernetesBaseCommand {
return workingDir;
}
- private KubernetesExport configureExport(String workingDir) {
+ private KubernetesExport configureExport(String workingDir, Path baseDir) {
detectCluster();
KubernetesExport.ExportConfigurer configurer = new
KubernetesExport.ExportConfigurer(
runtime,
+ baseDir,
quarkusVersion,
- List.of(filePaths),
+ files,
name,
gav,
repositories,
@@ -446,7 +460,7 @@ public class KubernetesRun extends KubernetesBaseCommand {
return export;
}
- private void setupDevMode(String projectName, String workingDir) throws
Exception {
+ private void setupDevMode(String projectName, String workingDir, Path
baseDir) throws Exception {
String firstPath = firstFilePath();
String watchDir = ".";
@@ -457,7 +471,7 @@ public class KubernetesRun extends KubernetesBaseCommand {
watchDir = filePath;
}
- filter = pathname -> Arrays.stream(filePaths)
+ filter = pathname -> files.stream()
.map(FileUtil::stripPath)
.anyMatch(name -> name.equals(pathname.getName()));
}
@@ -475,7 +489,7 @@ public class KubernetesRun extends KubernetesBaseCommand {
// Re-export updated project
//
- KubernetesExport export = configureExport(reloadWorkingDir);
+ KubernetesExport export = configureExport(reloadWorkingDir,
baseDir);
int exit = export.export();
if (exit != 0) {
printer().printErr("Project (re)export failed for:
%s".formatted(reloadWorkingDir));
@@ -508,7 +522,7 @@ public class KubernetesRun extends KubernetesBaseCommand {
// Recursively setup --dev mode for updated project
//
Runtime.getRuntime().removeShutdownHook(devModeShutdownTask);
- setupDevMode(projectName, reloadWorkingDir);
+ setupDevMode(projectName, reloadWorkingDir, baseDir);
printer().printf("Project reloaded: %s%n", reloadWorkingDir);
}
@@ -720,7 +734,11 @@ public class KubernetesRun extends KubernetesBaseCommand {
// wait for that process to exit as we run in foreground
int exit = p.waitFor();
if (exit != 0) {
- printer().printErr("Deployment to %s
failed!".formatted(clusterType));
+ String msg = "Deployment to %s failed!";
+ if (!verbose) {
+ msg += " (use --verbose for more details)";
+ }
+ printer().printErr(msg.formatted(clusterType));
return exit;
}
@@ -730,7 +748,7 @@ public class KubernetesRun extends KubernetesBaseCommand {
private void detectCluster() {
if (!disableAuto) {
if (verbose) {
- printer().print("Automatic kubernetes cluster detection... ");
+ printer().print("Automatic Kubernetes cluster detection... ");
}
ClusterType cluster = KubernetesHelper.discoverClusterType();
this.clusterType = cluster.name();
@@ -756,4 +774,13 @@ public class KubernetesRun extends KubernetesBaseCommand {
}
return super.printer();
}
+
+ static class FilesConsumer extends ParameterConsumer<KubernetesRun> {
+ @Override
+ protected void doConsumeParameters(Stack<String> args, KubernetesRun
cmd) {
+ String arg = args.pop();
+ cmd.files.add(arg);
+ }
+ }
+
}
diff --git
a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/test/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesCommandTest.java
b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/test/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesCommandTest.java
index d20df61591f..abc939bfc70 100644
---
a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/test/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesCommandTest.java
+++
b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/test/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesCommandTest.java
@@ -47,7 +47,7 @@ class KubernetesCommandTest extends KubernetesBaseTest {
@Test
public void shouldPrintKubernetesManifest() {
CamelJBangMain.run(createMain(), "kubernetes", "run",
"classpath:route.yaml",
- "--image-group", "camel-test", "--output", "yaml");
+ "--disable-auto=true", "--image-group", "camel-test",
"--output", "yaml");
List<HasMetadata> resources =
kubernetesClient.load(getKubernetesManifestAsStream(printer.getOutput())).items();
Assertions.assertEquals(2, resources.size());
diff --git
a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/test/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesExportTest.java
b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/test/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesExportTest.java
index 5e8b2e3556f..3fef58e3da3 100644
---
a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/test/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesExportTest.java
+++
b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/test/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesExportTest.java
@@ -14,7 +14,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.apache.camel.dsl.jbang.core.commands.kubernetes;
import java.io.FileInputStream;
@@ -127,6 +126,32 @@ class KubernetesExportTest extends
KubernetesExportBaseTest {
Assertions.assertEquals("1.0-SNAPSHOT", model.getVersion());
}
+ @ParameterizedTest
+ @MethodSource("runtimeProvider")
+ public void shouldGenerateProjectFromDir(RuntimeType rt) throws Exception {
+ KubernetesExport command = createCommand(new String[] {
"src/test/resources/myapp" },
+ "--gav=examples:route:1.0.0", "--runtime=" + rt.runtime());
+ int exit = command.doCall();
+ Assertions.assertEquals(0, exit);
+
+ Model model = readMavenModel();
+ Assertions.assertEquals("examples", model.getGroupId());
+ Assertions.assertEquals("route", model.getArtifactId());
+ Assertions.assertEquals("1.0.0", model.getVersion());
+
+ Properties props = model.getProperties();
+ Assertions.assertEquals("examples/route:1.0.0",
props.get("jkube.image.name"));
+ Assertions.assertEquals("examples/route:1.0.0",
props.get("jkube.container-image.name"));
+ Assertions.assertEquals("eclipse-temurin:21",
props.get("jkube.container-image.from"));
+ Assertions.assertEquals("jib", props.get("jkube.build.strategy"));
+ Assertions.assertNull(props.get("jkube.docker.push.registry"));
+ Assertions.assertNull(props.get("jkube.container-image.registry"));
+ Assertions.assertNull(props.get("jkube.container-image.platforms"));
+
+ Properties applicationProperties =
getApplicationProperties(workingDir);
+ Assertions.assertEquals("MySuperApp",
applicationProperties.getProperty("camel.main.name"));
+ }
+
@ParameterizedTest
@MethodSource("runtimeProvider")
public void shouldConfigureContainerImage(RuntimeType rt) throws Exception
{
diff --git
a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/test/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesRunCustomTest.java
b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/test/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesRunCustomTest.java
index 93ee09e34e4..2f99a8331cf 100644
---
a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/test/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesRunCustomTest.java
+++
b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/test/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesRunCustomTest.java
@@ -75,7 +75,7 @@ class KubernetesRunCustomTest {
public void disableAutomaticClusterDetection() throws Exception {
KubernetesHelper.setKubernetesClient(client);
setupServerExpectsOpenshift();
- KubernetesRun command = createCommand(new String[] {
"classpath:route.yaml" },
+ KubernetesRun command = createCommand(List.of("classpath:route.yaml"),
"--image-registry=quay.io", "--image-group=camel-test",
"--output=yaml",
"--disable-auto");
int exit = command.doCall();
@@ -93,7 +93,7 @@ class KubernetesRunCustomTest {
public void detectOpenshiftCluster() throws Exception {
KubernetesHelper.setKubernetesClient(client);
setupServerExpectsOpenshift();
- KubernetesRun command = createCommand(new String[] {
"classpath:route.yaml" },
+ KubernetesRun command = createCommand(List.of("classpath:route.yaml"),
"--image-registry=quay.io", "--image-group=camel-test",
"--output=yaml", "--verbose");
int exit = command.doCall();
@@ -113,7 +113,7 @@ class KubernetesRunCustomTest {
public void detectMinikubeCluster() throws Exception {
KubernetesHelper.setKubernetesClient(client);
setupServerExpectsMinikube();
- KubernetesRun command = createCommand(new String[] {
"classpath:route.yaml" },
+ KubernetesRun command = createCommand(List.of("classpath:route.yaml"),
"--image-registry=quay.io", "--image-group=camel-test",
"--output=yaml");
int exit = command.doCall();
@@ -135,7 +135,7 @@ class KubernetesRunCustomTest {
public void shouldGenerateKnativeService() throws Exception {
KubernetesHelper.setKubernetesClient(client);
setupServerExpectsMinikube();
- KubernetesRun command = createCommand(new String[] {
"classpath:route-service.yaml" },
+ KubernetesRun command =
createCommand(List.of("classpath:route-service.yaml"),
"--trait", "knative-service.enabled=true",
"--image-registry=quay.io", "--image-group=camel-test",
"--output=yaml");
int exit = command.doCall();
@@ -167,7 +167,7 @@ class KubernetesRunCustomTest {
public void shouldGenerateRegularService() throws Exception {
KubernetesHelper.setKubernetesClient(client);
setupServerExpectsMinikube();
- KubernetesRun command = createCommand(new String[] {
"classpath:route-service.yaml" },
+ KubernetesRun command =
createCommand(List.of("classpath:route-service.yaml"),
"--image-registry=quay.io", "--image-group=camel-test",
"--output=yaml");
int exit = command.doCall();
@@ -221,7 +221,7 @@ class KubernetesRunCustomTest {
.always();
}
- private KubernetesRun createCommand(String[] files, String... args) {
+ private KubernetesRun createCommand(List<String> files, String... args) {
var argsArr = Optional.ofNullable(args).orElse(new String[0]);
var argsLst = new ArrayList<>(Arrays.asList(argsArr));
var jbangMain = new CamelJBangMain().withPrinter(printer);
diff --git
a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/test/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesRunTest.java
b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/test/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesRunTest.java
index f854c4d4e0e..2b31948e106 100644
---
a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/test/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesRunTest.java
+++
b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/test/java/org/apache/camel/dsl/jbang/core/commands/kubernetes/KubernetesRunTest.java
@@ -65,8 +65,8 @@ class KubernetesRunTest extends KubernetesBaseTest {
@ParameterizedTest
@MethodSource("runtimeProvider")
public void shouldHandleMissingSourceFile(RuntimeType rt) throws Exception
{
- KubernetesRun command = createCommand(new String[] {
"mickey-mouse.groovy" },
- "--output=yaml", "--runtime=" + rt.runtime());
+ KubernetesRun command = createCommand(List.of("mickey-mouse.groovy"),
+ "--disable-auto=true", "--output=yaml", "--runtime=" +
rt.runtime());
int exit = command.doCall();
Assertions.assertEquals(1, exit);
@@ -77,8 +77,8 @@ class KubernetesRunTest extends KubernetesBaseTest {
@ParameterizedTest
@MethodSource("runtimeProvider")
public void shouldGenerateKubernetesManifest(RuntimeType rt) throws
Exception {
- KubernetesRun command = createCommand(new String[] {
"classpath:route.yaml" },
- "--image-registry=quay.io", "--image-group=camel-test",
"--output=yaml",
+ KubernetesRun command = createCommand(List.of("classpath:route.yaml"),
+ "--disable-auto=true", "--image-registry=quay.io",
"--image-group=camel-test", "--output=yaml",
"--trait", "container.image-pull-policy=IfNotPresent",
"--runtime=" + rt.runtime());
int exit = command.doCall();
@@ -121,8 +121,8 @@ class KubernetesRunTest extends KubernetesBaseTest {
@ParameterizedTest
@MethodSource("runtimeProvider")
public void shouldHandleUnsupportedOutputFormat(RuntimeType rt) throws
Exception {
- KubernetesRun command = createCommand(new String[] {
"classpath:route.yaml" },
- "--output=wrong", "--runtime=" + rt.runtime());
+ KubernetesRun command = createCommand(List.of("classpath:route.yaml"),
+ "--disable-auto=true", "--output=wrong", "--runtime=" +
rt.runtime());
Assertions.assertEquals(1, command.doCall());
Assertions.assertTrue(printer.getOutput().endsWith("ERROR: Unsupported
output format 'wrong' (supported: yaml, json)"));
@@ -131,8 +131,8 @@ class KubernetesRunTest extends KubernetesBaseTest {
@ParameterizedTest
@MethodSource("runtimeProvider")
public void shouldGenerateKubernetesNamespace(RuntimeType rt) throws
Exception {
- KubernetesRun command = createCommand(new String[] {
"classpath:route.yaml" },
- "--image-registry=quay.io", "--image-group=camel-test",
"--output=yaml",
+ KubernetesRun command = createCommand(List.of("classpath:route.yaml"),
+ "--disable-auto=true", "--image-registry=quay.io",
"--image-group=camel-test", "--output=yaml",
"--namespace", "custom",
"--runtime=" + rt.runtime());
int exit = command.doCall();
@@ -161,7 +161,7 @@ class KubernetesRunTest extends KubernetesBaseTest {
Assertions.assertEquals("quay.io/camel-test/route:1.0-SNAPSHOT",
containers.get(0).getImage());
}
- private KubernetesRun createCommand(String[] files, String... args) {
+ private KubernetesRun createCommand(List<String> files, String... args) {
var argsArr = Optional.ofNullable(args).orElse(new String[0]);
var argsLst = new ArrayList<>(Arrays.asList(argsArr));
var jbangMain = new CamelJBangMain().withPrinter(printer);
diff --git
a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/test/resources/myapp/application.properties
b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/test/resources/myapp/application.properties
new file mode 100644
index 00000000000..571461af637
--- /dev/null
+++
b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/test/resources/myapp/application.properties
@@ -0,0 +1,18 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+
+camel.main.name = MySuperApp
diff --git
a/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/test/resources/myapp/route.yaml
b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/test/resources/myapp/route.yaml
new file mode 100644
index 00000000000..184bd121295
--- /dev/null
+++
b/dsl/camel-jbang/camel-jbang-plugin-kubernetes/src/test/resources/myapp/route.yaml
@@ -0,0 +1,23 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+- from:
+ uri: timer:tick
+ steps:
+ - setBody:
+ constant: Hello Camel !!!
+ - to: log:info