This is an automated email from the ASF dual-hosted git repository. squakez pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel.git
commit bb55a709a473ca27dcb3779062dc9f9cde659277 Author: Pasquale Congiusti <[email protected]> AuthorDate: Wed Nov 25 16:31:32 2026 +0100 chore(core): expandWildcards utility --- .../dsl/jbang/core/commands/ExportBaseCommand.java | 3 +- .../dsl/jbang/core/commands/ExportCommandBase.java | 11 ++- .../apache/camel/dsl/jbang/core/commands/Run.java | 45 ++------- .../camel/dsl/jbang/core/commands/ExportTest.java | 30 ++++++ .../camel/dsl/jbang/run/common/ExportHelper.java | 58 +++++++++++ .../dsl/jbang/run/export/ProjectExporter.java | 21 +--- .../dsl/jbang/run/common/ExportHelperTest.java | 109 +++++++++++++++++++++ .../dsl/jbang/run/export/ProjectExporterTest.java | 46 ++++++++- 8 files changed, 265 insertions(+), 58 deletions(-) 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 a50e69d44d70..4dbe792a6763 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 @@ -396,7 +396,8 @@ public abstract class ExportBaseCommand extends CamelCommand { protected ExportRequest toRequest() { ExportRequest request = new ExportRequest(); request.baseDir = this.exportBaseDir; - request.files = this.files; + // a copy: the preparation completes the files, and the list of the command may be of a fixed size + request.files = this.files != null ? new ArrayList<>(this.files) : null; request.dependencies = this.dependencies; request.runtime = this.runtime; request.name = this.name; diff --git a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportCommandBase.java b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportCommandBase.java index 346462a45500..1e20d10ef4cb 100644 --- a/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportCommandBase.java +++ b/dsl/camel-jbang/camel-jbang-core/src/main/java/org/apache/camel/dsl/jbang/core/commands/ExportCommandBase.java @@ -16,8 +16,10 @@ */ package org.apache.camel.dsl.jbang.core.commands; +import java.io.FileNotFoundException; import java.nio.file.Path; +import org.apache.camel.dsl.jbang.core.common.CliExitCode; import org.apache.camel.dsl.jbang.run.export.ExportRequest; import org.apache.camel.dsl.jbang.run.export.ProjectExporter; @@ -43,7 +45,14 @@ public abstract class ExportCommandBase extends ExportBaseCommand { protected Integer doExport() throws Exception { ExportRequest request = toRequest(); ProjectExporter exporter = new ProjectExporter(exportContext()); - Path baseDir = exporter.prepare(request); + Path baseDir; + try { + baseDir = exporter.prepare(request); + } catch (FileNotFoundException ex) { + // as ProjectExporter.export: the plain message on stderr, and exit 66 + printer().printErr(ex.getMessage()); + return CliExitCode.FILE_NOT_FOUND; + } applySystemProperties(request); // the options from application.properties, the profile and the system properties fromRequest(request); 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 e11450f318f3..2b32d1f25d24 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 @@ -20,18 +20,17 @@ import java.awt.Toolkit; import java.awt.datatransfer.Clipboard; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.UnsupportedFlavorException; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.nio.file.InvalidPathException; import java.nio.file.Path; -import java.nio.file.PathMatcher; import java.nio.file.Paths; import java.util.*; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.util.stream.Stream; import org.aesh.command.CommandDefinition; import org.aesh.command.CommandLifecycle; @@ -423,43 +422,13 @@ public class Run extends CamelCommand implements CommandLifecycle { * with code 66. */ void expandWildcards() { - if (files == null || files.isEmpty()) { - return; - } - List<String> answer = new ArrayList<>(); - for (String file : files) { - // a local file, not file: (a resource pattern) nor a remote one; a single letter is a drive on Windows - String scheme = getScheme(file); - boolean local = scheme == null || scheme.length() == 1; - String name = FileUtil.stripPath(file); - String dir = FileUtil.onlyPath(file); - boolean wildcard = local && (name.contains("*") || name.contains("?")) - && (dir == null || !dir.contains("*") && !dir.contains("?")); - if (!wildcard) { - answer.add(file); - continue; - } - Path folder = Paths.get(dir != null ? dir : "."); - List<String> matches = new ArrayList<>(); - if (Files.isDirectory(folder)) { - PathMatcher matcher = folder.getFileSystem().getPathMatcher("glob:" + name); - try (Stream<Path> list = Files.list(folder)) { - list.map(Path::getFileName) - .filter(p -> matcher.matches(p) && (name.startsWith(".") || !p.toString().startsWith("."))) - .map(p -> dir != null ? dir + "/" + p : p.toString()) - .sorted() - .forEach(matches::add); - } catch (IOException e) { - throw CliException.failure("Cannot list the files of " + folder + ": " + e.getMessage()); - } - } - if (matches.isEmpty()) { - throw CliException.fileNotFound("No file matches: " + file); - } - answer.addAll(matches); + try { + ExportHelper.expandWildcards(files); + } catch (FileNotFoundException e) { + throw CliException.fileNotFound(e.getMessage()); + } catch (IOException e) { + throw CliException.failure(e.getMessage()); } - files.clear(); - files.addAll(answer); } /** 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 6514d375c85e..d269fb39865a 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 @@ -24,6 +24,7 @@ import java.util.ArrayList; import java.util.List; import java.util.stream.Stream; +import org.apache.camel.dsl.jbang.core.common.CliExitCode; import org.apache.camel.dsl.jbang.core.common.CommandLineTestHelper; import org.apache.camel.dsl.jbang.run.common.RuntimeType; import org.apache.camel.util.FileUtil; @@ -43,6 +44,35 @@ class ExportTest extends ExportBaseTestSupport { private static final Logger LOG = LoggerFactory.getLogger(ExportTest.class); + @Test + void shouldFailWithFileNotFoundWhenWildcardMatchesNothing() throws Exception { + Path empty = Files.createDirectories(workingDir.toPath().resolve("empty")); + // a fixed-size list, as the CLI never expands a wildcard that matches nothing + Export command = exportWithPrinter(List.of(empty + "/*")); + + assertThat(command.doCall()).isEqualTo(CliExitCode.FILE_NOT_FOUND); + assertThat(printer.getStderr()).contains("No file matches: " + empty + "/*"); + assertThat(printer.getStderr()).doesNotContain("File not found"); + } + + @Test + void shouldFailWithFileNotFoundOnEmptyDirectory() throws Exception { + Path empty = Files.createDirectories(workingDir.toPath().resolve("empty")); + Export command = exportWithPrinter(List.of(empty.toString())); + + assertThat(command.doCall()).isEqualTo(CliExitCode.FILE_NOT_FOUND); + assertThat(printer.getStderr()).contains("No files found in directory: " + empty); + assertThat(printer.getStderr()).doesNotContain("File not found"); + } + + private Export exportWithPrinter(List<String> files) { + Export command = new CamelJBangMain().withPrinter(printer).command(new Export()); + CommandLineTestHelper.parse(command, "--gav=examples:route:1.0.0", "--dir=" + workingDir, "--quiet", + "--runtime=main"); + command.files = files; + return command; + } + @ParameterizedTest @MethodSource("runtimeProvider") public void shouldGenerateProject(RuntimeType rt) throws Exception { diff --git a/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/common/ExportHelper.java b/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/common/ExportHelper.java index 7d8aeb59ba99..fb4cdf42445d 100644 --- a/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/common/ExportHelper.java +++ b/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/common/ExportHelper.java @@ -17,10 +17,12 @@ package org.apache.camel.dsl.jbang.run.common; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; +import java.nio.file.PathMatcher; import java.nio.file.Paths; import java.nio.file.StandardCopyOption; import java.util.ArrayList; @@ -114,6 +116,62 @@ public final class ExportHelper { } } + /** + * Expands a local file name with a wildcard, such as {@code *} or {@code routes/*.yaml}, to the files it matches, + * as a Unix shell does with {@code camel run *}. A shell that does not, such as the Windows command prompt, or a + * quoted {@code '*'}, passes the wildcard on (CAMEL-26930). As in a shell, a hidden file matches only a wildcard + * that starts with a dot, and the matches are sorted. A wildcard in a folder name, a remote file, a {@code file:} + * resource pattern and a file without wildcard are left as given. The list is only modified when a wildcard was + * expanded, so a fixed-size list is fine when it has none. + * + * @param files the files, which are completed in-place + * @throws FileNotFoundException when a wildcard matches nothing + * @throws IOException when the folder of a wildcard cannot be listed + */ + public static void expandWildcards(List<String> files) throws IOException { + if (files == null || files.isEmpty()) { + return; + } + boolean expandedAny = false; + List<String> answer = new ArrayList<>(); + for (String file : files) { + // a local file, not file: (a resource pattern) nor a remote one; a single letter is a drive on Windows + int pos = file.indexOf(':'); + boolean local = pos < 2; + String name = FileUtil.stripPath(file); + String dir = FileUtil.onlyPath(file); + boolean wildcard = local && (name.contains("*") || name.contains("?")) + && (dir == null || !dir.contains("*") && !dir.contains("?")); + if (!wildcard) { + answer.add(file); + continue; + } + Path folder = Paths.get(dir != null ? dir : "."); + List<String> matches = new ArrayList<>(); + if (Files.isDirectory(folder)) { + PathMatcher matcher = folder.getFileSystem().getPathMatcher("glob:" + name); + try (Stream<Path> list = Files.list(folder)) { + list.map(Path::getFileName) + .filter(p -> matcher.matches(p) && (name.startsWith(".") || !p.toString().startsWith("."))) + .map(p -> dir != null ? dir + "/" + p : p.toString()) + .sorted() + .forEach(matches::add); + } catch (IOException e) { + throw new IOException("Cannot list the files of " + folder + ": " + e.getMessage(), e); + } + } + if (matches.isEmpty()) { + throw new FileNotFoundException("No file matches: " + file); + } + answer.addAll(matches); + expandedAny = true; + } + if (expandedAny) { + files.clear(); + files.addAll(answer); + } + } + /** * The line of a property in a properties file that is written in ISO-8859-1, escaped so the file is read back with * the same key and value (see {@link java.util.Properties#load(java.io.InputStream)}): a backslash, a tab, a new diff --git a/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/ProjectExporter.java b/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/ProjectExporter.java index abff0a117dc8..65c002a65eb9 100644 --- a/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/ProjectExporter.java +++ b/dsl/camel-jbang/camel-jbang-run/src/main/java/org/apache/camel/dsl/jbang/run/export/ProjectExporter.java @@ -17,13 +17,11 @@ package org.apache.camel.dsl.jbang.run.export; import java.io.FileNotFoundException; -import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; import java.util.Properties; -import java.util.stream.Stream; import org.apache.camel.dsl.jbang.run.RunPipeline; import org.apache.camel.dsl.jbang.run.common.CamelJBangConstants; @@ -130,6 +128,9 @@ public class ProjectExporter { public Path prepare(ExportRequest request) throws Exception { Path baseDir = request.baseDir != null ? request.baseDir : Path.of("."); + // expand wildcards before the project name is taken from the first file (otherwise the artifactId becomes *) + ExportHelper.expandWildcards(request.files); + // special if user type: camel run . or camel run dirName if (request.files != null && request.files.size() == 1) { String name = FileUtil.stripTrailingSeparator(request.files.get(0)); @@ -190,6 +191,7 @@ public class ProjectExporter { } try { + ExportHelper.expandWildcards(request.files); verifyExportFiles(request.files); } catch (FileNotFoundException ex) { // as camel run: on stderr, and exit 66; it was on stdout, with exit 1 (CAMEL-26931) @@ -266,7 +268,7 @@ public class ProjectExporter { return context.getPrinter(); } - private static void verifyExportFiles(List<String> files) throws IOException { + private static void verifyExportFiles(List<String> files) throws FileNotFoundException { for (var fn : files) { if (fn.indexOf(':') < 0 || fn.startsWith("file:")) { if (fn.startsWith("file:")) { @@ -275,26 +277,13 @@ public class ProjectExporter { fn = fn.substring(2); } } - if (fn.endsWith("/*")) { - fn = fn.substring(0, fn.length() - 2); - } if (!Files.exists(Paths.get(fn))) { throw new FileNotFoundException("Path does not exist: " + fn); } - Path path = Paths.get(fn); - if (Files.isDirectory(path) && isEmptyDirectory(path)) { - throw new FileNotFoundException("No files found in directory: " + fn); - } } } } - private static boolean isEmptyDirectory(Path dir) throws IOException { - try (Stream<Path> entries = Files.list(dir)) { - return entries.findAny().isEmpty(); - } - } - private static void doLoadAndInitProfileProperties(ExportRequest request, Path path) throws Exception { if (Files.exists(path)) { Properties props = new CamelCaseOrderedProperties(); diff --git a/dsl/camel-jbang/camel-jbang-run/src/test/java/org/apache/camel/dsl/jbang/run/common/ExportHelperTest.java b/dsl/camel-jbang/camel-jbang-run/src/test/java/org/apache/camel/dsl/jbang/run/common/ExportHelperTest.java index 1419296103d2..64e2bd849181 100644 --- a/dsl/camel-jbang/camel-jbang-run/src/test/java/org/apache/camel/dsl/jbang/run/common/ExportHelperTest.java +++ b/dsl/camel-jbang/camel-jbang-run/src/test/java/org/apache/camel/dsl/jbang/run/common/ExportHelperTest.java @@ -17,6 +17,8 @@ package org.apache.camel.dsl.jbang.run.common; import java.io.ByteArrayInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; import java.io.InputStream; import java.nio.charset.StandardCharsets; import java.nio.file.Files; @@ -29,9 +31,13 @@ import java.util.Properties; import org.apache.camel.tooling.maven.MavenGav; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.io.TempDir; +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + public class ExportHelperTest { @Test @@ -282,4 +288,107 @@ public class ExportHelperTest { ExportHelper.propertyLine("url", properties.get("url"))); Assertions.assertEquals("euro=5 \\u20ac", ExportHelper.propertyLine("euro", "5 €")); } + + @Test + void expandWildcardsLeavesNonWildcardEntriesUntouched(@TempDir Path dir) throws Exception { + Path file = Files.writeString(dir.resolve("route.camel.yaml"), ""); + List<String> files = new ArrayList<>(List.of(file.toString())); + ExportHelper.expandWildcards(files); + assertThat(files).containsExactly(file.toString()); + } + + @Test + void expandWildcardsExpandsStarToMatchingFiles(@TempDir Path dir) throws Exception { + Path a = Files.writeString(dir.resolve("a.camel.yaml"), ""); + Path b = Files.writeString(dir.resolve("b.camel.yaml"), ""); + List<String> files = new ArrayList<>(List.of(dir + "/*")); + ExportHelper.expandWildcards(files); + assertThat(files).containsExactly(a.toString(), b.toString()); + } + + @Test + void expandWildcardsExpandsGlobPatternToMatchingFiles(@TempDir Path dir) throws Exception { + Path yaml = Files.writeString(dir.resolve("route.camel.yaml"), ""); + Files.writeString(dir.resolve("app.properties"), ""); + List<String> files = new ArrayList<>(List.of(dir + "/*.yaml")); + ExportHelper.expandWildcards(files); + assertThat(files).containsExactly(yaml.toString()); + } + + @Test + void expandWildcardsDoesNotMatchHiddenFiles(@TempDir Path dir) throws Exception { + Files.writeString(dir.resolve(".DS_Store"), ""); + List<String> files = new ArrayList<>(List.of(dir + "/*")); + assertThatThrownBy(() -> ExportHelper.expandWildcards(files)) + .isInstanceOf(FileNotFoundException.class) + .hasMessageContaining("No file matches"); + } + + @Test + void expandWildcardsFailsWhenNothingMatches(@TempDir Path dir) throws Exception { + List<String> files = new ArrayList<>(List.of(dir + "/*.yaml")); + assertThatThrownBy(() -> ExportHelper.expandWildcards(files)) + .isInstanceOf(FileNotFoundException.class) + .hasMessageContaining("No file matches"); + } + + @Test + void expandWildcardsKeepsAFixedSizeListWithoutWildcard(@TempDir Path dir) throws Exception { + Path file = Files.writeString(dir.resolve("route.camel.yaml"), ""); + List<String> files = List.of(file.toString(), "classpath:route.yaml"); + ExportHelper.expandWildcards(files); + assertThat(files).containsExactly(file.toString(), "classpath:route.yaml"); + } + + @Test + void expandWildcardsExpandsQuestionMark(@TempDir Path dir) throws Exception { + Path a = Files.writeString(dir.resolve("a1.yaml"), ""); + Files.writeString(dir.resolve("a22.yaml"), ""); + List<String> files = new ArrayList<>(List.of(dir + "/a?.yaml")); + ExportHelper.expandWildcards(files); + assertThat(files).containsExactly(dir + "/" + a.getFileName()); + } + + @Test + void expandWildcardsMatchesHiddenFilesWithADotPattern(@TempDir Path dir) throws Exception { + Files.writeString(dir.resolve("route.yaml"), ""); + Files.writeString(dir.resolve(".hidden.yaml"), ""); + List<String> files = new ArrayList<>(List.of(dir + "/.*.yaml")); + ExportHelper.expandWildcards(files); + assertThat(files).containsExactly(dir + "/.hidden.yaml"); + } + + @Test + void expandWildcardsLeavesRemoteFileResourceAndFolderWildcardAsGiven(@TempDir Path dir) throws Exception { + List<String> given = List.of("github:apache:camel-kamelets-examples:jbang/*", "file:" + dir + "/*", + "classpath:routes/*.yaml", dir + "/*/route.yaml"); + List<String> files = new ArrayList<>(given); + ExportHelper.expandWildcards(files); + assertThat(files).containsExactlyElementsOf(given); + } + + @Test + void expandWildcardsFailsWhenTheFolderDoesNotExist(@TempDir Path dir) { + List<String> files = new ArrayList<>(List.of(dir + "/missing/*")); + assertThatThrownBy(() -> ExportHelper.expandWildcards(files)) + .isInstanceOf(FileNotFoundException.class) + .hasMessageContaining("No file matches"); + } + + @Test + void expandWildcardsReportsAnUnreadableFolder(@TempDir Path dir) throws Exception { + Path locked = Files.createDirectories(dir.resolve("locked")); + Files.writeString(locked.resolve("route.yaml"), ""); + Assumptions.assumeTrue(locked.toFile().setReadable(false) && !Files.isReadable(locked), + "the permissions of the folder cannot be revoked (such as for root)"); + try { + List<String> files = new ArrayList<>(List.of(locked + "/*.yaml")); + assertThatThrownBy(() -> ExportHelper.expandWildcards(files)) + .isInstanceOf(IOException.class) + .isNotInstanceOf(FileNotFoundException.class) + .hasMessageContaining("Cannot list the files of"); + } finally { + locked.toFile().setReadable(true); + } + } } diff --git a/dsl/camel-jbang/camel-jbang-run/src/test/java/org/apache/camel/dsl/jbang/run/export/ProjectExporterTest.java b/dsl/camel-jbang/camel-jbang-run/src/test/java/org/apache/camel/dsl/jbang/run/export/ProjectExporterTest.java index 8f62181750aa..b22a152bd27b 100644 --- a/dsl/camel-jbang/camel-jbang-run/src/test/java/org/apache/camel/dsl/jbang/run/export/ProjectExporterTest.java +++ b/dsl/camel-jbang/camel-jbang-run/src/test/java/org/apache/camel/dsl/jbang/run/export/ProjectExporterTest.java @@ -746,7 +746,8 @@ class ProjectExporterTest { } @Test - void failsOnEmptyDirectory() throws Exception { + void failsWhenWildcardMatchesNothing() throws Exception { + // the shell passes the literal xyz/* when nothing matched: expandWildcards fails with "No file matches" Path empty = Files.createDirectories(dir.resolve("empty")); ExportRequest request = new ExportRequest(); request.files.add(empty + "/*"); @@ -757,11 +758,52 @@ class ProjectExporterTest { .export(request); assertThat(exit).isEqualTo(RunPipeline.FILE_NOT_FOUND); - assertThat(printer.getStderr()).contains("No files found in directory"); + assertThat(printer.getStderr()).contains("No file matches"); + assertThat(printer.getStdout()).isEmpty(); + assertThat(resolved).isEmpty(); + } + + @Test + void failsWhenWildcardMatchesOnlyHiddenFiles() throws Exception { + // a directory with only hidden files (e.g. .DS_Store): the wildcard xyz/* does not match them + Path xyz = Files.createDirectories(dir.resolve("xyz")); + Files.writeString(xyz.resolve(".DS_Store"), ""); + ExportRequest request = new ExportRequest(); + request.files.add(xyz + "/*"); + request.runtime = RuntimeType.main; + + StringPrinter printer = new StringPrinter(); + int exit = new ProjectExporter(new ExportContext().withPrinter(printer).withDependencyResolver(resolver)) + .export(request); + + assertThat(exit).isEqualTo(RunPipeline.FILE_NOT_FOUND); + assertThat(printer.getStderr()).contains("No file matches"); assertThat(printer.getStdout()).isEmpty(); assertThat(resolved).isEmpty(); } + @Test + void expandsWildcardToMatchingFiles() throws Exception { + // a quoted 'routes/*.yaml' on Windows CMD, or when the shell passes the literal: the files are found and exported + Path routes = Files.createDirectories(dir.resolve("routes")); + Path route = writeRoute(routes, "hello", "hello"); + ExportRequest request = new ExportRequest(); + request.files.add(routes + "/*.yaml"); + request.runtime = RuntimeType.main; + request.exportDir = dir.resolve("export").toString(); + request.workDir = dir.resolve("export-work"); + request.mavenWrapper = false; + request.quiet = true; + + StringPrinter printer = new StringPrinter(); + int exit = new ProjectExporter(new ExportContext().withPrinter(printer).withDependencyResolver(resolver)) + .export(request); + + assertThat(exit).as(printer.getOutput()).isZero(); + assertThat(request.files).containsExactly(route.toString()); + assertThat(dir.resolve("export/src/main/resources/camel/hello.camel.yaml")).hasSameTextualContentAs(route); + } + @Test void failsOnEmptyDirectoryWithoutWildcard() throws Exception { Path empty = Files.createDirectories(dir.resolve("empty"));
