From ee79fce4070840f1717a52dd3402a6045ecc0cab Mon Sep 17 00:00:00 2001 From: Vincent Sevel Date: Thu, 15 Aug 2024 08:20:06 +0200 Subject: [PATCH] Codestart support merging application profile yaml files --- .../codestarts/quarkus/project/quarkus/codestart.yml | 2 ++ .../core/strategy/CodestartFileStrategy.java | 8 ++++++++ .../core/strategy/CodestartFileStrategyTest.java | 12 ++++++++++++ 3 files changed, 22 insertions(+) diff --git a/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/project/quarkus/codestart.yml b/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/project/quarkus/codestart.yml index 2822b07c03a85..4ee705f419ba3 100644 --- a/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/project/quarkus/codestart.yml +++ b/independent-projects/tools/base-codestarts/src/main/resources/codestarts/quarkus/project/quarkus/codestart.yml @@ -10,8 +10,10 @@ output-strategy: ".gitignore": append "src/main/resources/META-INF/resources/index.html": content-merge "src/main/resources/application.yml": smart-config-merge + "src/main/resources/application-*.yml": smart-config-merge "src/main/resources/application.properties": forbidden "src/test/resources/application.yml": smart-config-merge + "src/test/resources/application-*.yml": smart-config-merge "src/test/resources/application.properties": forbidden "*.java": smart-package "*.kt": smart-package diff --git a/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/core/strategy/CodestartFileStrategy.java b/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/core/strategy/CodestartFileStrategy.java index 45a6d42602421..d32808ff17cd4 100644 --- a/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/core/strategy/CodestartFileStrategy.java +++ b/independent-projects/tools/codestarts/src/main/java/io/quarkus/devtools/codestarts/core/strategy/CodestartFileStrategy.java @@ -33,6 +33,14 @@ public boolean test(String t) { return true; } } + int index = filter.indexOf("*"); + if (index != -1 && filter.length() > 1) { + String part1 = filter.substring(0, index); + String part2 = filter.substring(index + 1); + if (t.startsWith(part1) && t.endsWith(part2)) { + return true; + } + } return filter.equals(t); } diff --git a/independent-projects/tools/codestarts/src/test/java/io/quarkus/devtools/codestarts/core/strategy/CodestartFileStrategyTest.java b/independent-projects/tools/codestarts/src/test/java/io/quarkus/devtools/codestarts/core/strategy/CodestartFileStrategyTest.java index d92d0c2e58e90..bfcf7db24b5f6 100644 --- a/independent-projects/tools/codestarts/src/test/java/io/quarkus/devtools/codestarts/core/strategy/CodestartFileStrategyTest.java +++ b/independent-projects/tools/codestarts/src/test/java/io/quarkus/devtools/codestarts/core/strategy/CodestartFileStrategyTest.java @@ -30,6 +30,18 @@ void testFilterEnd() { assertThat(strategy.test("")).isFalse(); } + @Test + void testFilterMiddle() { + final CodestartFileStrategy strategy = new CodestartFileStrategy("/foo/bar/my*.txt", + mock(CodestartFileStrategyHandler.class)); + assertThat(strategy.test("/foo/bar/myfile.txt")).isTrue(); + assertThat(strategy.test("/foo/bar/baz/anoter_file")).isFalse(); + assertThat(strategy.test(null)).isFalse(); + assertThat(strategy.test("foo/bar/myfile.txt")).isFalse(); + assertThat(strategy.test("something")).isFalse(); + assertThat(strategy.test("")).isFalse(); + } + @Test void testFilter() { final CodestartFileStrategy strategy = new CodestartFileStrategy("/foo/bar/myfile.txt",