Skip to content

Commit 74dea85

Browse files
authored
Merge pull request #68 from zonkyio/flyway-6.0.3
#67 Fix compatibility with Flyway 6.0.3+
2 parents 2d2b0f8 + 7957341 commit 74dea85

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ ext {
2626

2727
[core: '5.1.4', test: '5.1.0'],
2828
[core: '5.2.4', test: '5.2.4'],
29-
[core: '6.0.2', test: '5.2.4'],
29+
[core: '6.0.2', test: '6.0.0'],
30+
[core: '6.0.7', test: '6.0.0'],
3031

3132
[core: '5.0.7', test: '5.0.0'] // default version
3233
]

embedded-database-spring-test/src/main/java/io/zonky/test/db/flyway/OptimizedFlywayTestExecutionListener.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import javax.sql.DataSource;
4343
import java.lang.annotation.Annotation;
4444
import java.lang.reflect.AnnotatedElement;
45+
import java.lang.reflect.Constructor;
4546
import java.lang.reflect.InvocationTargetException;
4647
import java.lang.reflect.Method;
4748
import java.sql.SQLException;
@@ -265,10 +266,21 @@ protected static MigrationResolver createMigrationResolver(Flyway flyway, String
265266
Object sqlScriptExecutorFactory = invokeStaticMethod(DatabaseFactory.class, "createSqlScriptExecutorFactory", jdbcConnectionFactory);
266267

267268
Class<?> scannerType = ClassUtils.forName("org.flywaydb.core.internal.scanner.Scanner", classLoader);
268-
Object scanner = scannerType.getConstructors()[0].newInstance(
269-
Arrays.asList((Object[]) invokeMethod(configuration, "getLocations")),
270-
invokeMethod(configuration, "getClassLoader"),
271-
invokeMethod(configuration, "getEncoding"));
269+
Constructor<?> scannerConstructor = scannerType.getConstructors()[0];
270+
Object scanner;
271+
272+
if (scannerConstructor.getParameterCount() == 4) {
273+
scanner = scannerConstructor.newInstance(
274+
ClassUtils.forName("org.flywaydb.core.api.migration.JavaMigration", classLoader),
275+
Arrays.asList((Object[]) invokeMethod(configuration, "getLocations")),
276+
invokeMethod(configuration, "getClassLoader"),
277+
invokeMethod(configuration, "getEncoding"));
278+
} else {
279+
scanner = scannerConstructor.newInstance(
280+
Arrays.asList((Object[]) invokeMethod(configuration, "getLocations")),
281+
invokeMethod(configuration, "getClassLoader"),
282+
invokeMethod(configuration, "getEncoding"));
283+
}
272284

273285
return invokeMethod(flyway, "createMigrationResolver", scanner, scanner, sqlScriptExecutorFactory, sqlScriptFactory);
274286
} else if (flywayVersion >= 52) {

0 commit comments

Comments
 (0)