Skip to content

Commit 8627496

Browse files
committed
Merge branch '3.5.x' into 4.0.x
Closes gh-49706
2 parents 1e5fd25 + e65732e commit 8627496

4 files changed

Lines changed: 18 additions & 2 deletions

File tree

module/spring-boot-flyway/src/main/java/org/springframework/boot/flyway/autoconfigure/FlywayAutoConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ static class FlywayAutoConfigurationRuntimeHints implements RuntimeHintsRegistra
480480

481481
@Override
482482
public void registerHints(RuntimeHints hints, @Nullable ClassLoader classLoader) {
483-
hints.resources().registerPattern("db/migration/*");
483+
hints.resources().registerPattern("db/migration/**");
484484
}
485485

486486
}

module/spring-boot-flyway/src/main/java/org/springframework/boot/flyway/autoconfigure/NativeImageResourceProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ private void initialize() {
147147

148148
private Resource[] getResources(PathMatchingResourcePatternResolver resolver, Location location, Resource root) {
149149
try {
150-
return resolver.getResources(root.getURI() + "/*");
150+
return resolver.getResources(root.getURI() + "/**/*");
151151
}
152152
catch (IOException ex) {
153153
throw new UncheckedIOException("Failed to list resources for " + location.getDescriptor(), ex);

module/spring-boot-flyway/src/test/java/org/springframework/boot/flyway/autoconfigure/FlywayAutoConfigurationTests.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,8 @@ void shouldRegisterResourceHints() {
896896
new FlywayAutoConfigurationRuntimeHints().registerHints(runtimeHints, getClass().getClassLoader());
897897
assertThat(RuntimeHintsPredicates.resource().forResource("db/migration/")).accepts(runtimeHints);
898898
assertThat(RuntimeHintsPredicates.resource().forResource("db/migration/V1__init.sql")).accepts(runtimeHints);
899+
assertThat(RuntimeHintsPredicates.resource().forResource("db/migration/nested/V2__users.sql"))
900+
.accepts(runtimeHints);
899901
}
900902

901903
@Test

module/spring-boot-flyway/src/test/java/org/springframework/boot/flyway/autoconfigure/NativeImageResourceProviderCustomizerTests.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.junit.jupiter.api.Test;
2626

2727
import org.springframework.boot.testsupport.classpath.resources.WithResource;
28+
import org.springframework.boot.testsupport.classpath.resources.WithResources;
2829

2930
import static org.assertj.core.api.Assertions.assertThat;
3031

@@ -56,6 +57,19 @@ void nativeImageResourceProviderShouldFindMigrations() {
5657
assertThat(migrations).containsExactly(migration);
5758
}
5859

60+
@Test
61+
@WithResources({ @WithResource(name = "db/migration/V1__init.sql"),
62+
@WithResource(name = "db/migration/nested/V2__users.sql") })
63+
void nativeImageResourceProviderShouldFindNestedMigrations() {
64+
FluentConfiguration configuration = new FluentConfiguration();
65+
this.customizer.customize(configuration);
66+
ResourceProvider resourceProvider = configuration.getResourceProvider();
67+
Collection<LoadableResource> migrations = resourceProvider.getResources("V", new String[] { ".sql" });
68+
LoadableResource v1 = resourceProvider.getResource("V1__init.sql");
69+
LoadableResource v2 = resourceProvider.getResource("nested/V2__users.sql");
70+
assertThat(migrations).containsExactly(v1, v2);
71+
}
72+
5973
@Test
6074
void shouldBackOffOnCustomResourceProvider() {
6175
FluentConfiguration configuration = new FluentConfiguration();

0 commit comments

Comments
 (0)