|
42 | 42 | import javax.sql.DataSource; |
43 | 43 | import java.lang.annotation.Annotation; |
44 | 44 | import java.lang.reflect.AnnotatedElement; |
| 45 | +import java.lang.reflect.Constructor; |
45 | 46 | import java.lang.reflect.InvocationTargetException; |
46 | 47 | import java.lang.reflect.Method; |
47 | 48 | import java.sql.SQLException; |
@@ -265,10 +266,21 @@ protected static MigrationResolver createMigrationResolver(Flyway flyway, String |
265 | 266 | Object sqlScriptExecutorFactory = invokeStaticMethod(DatabaseFactory.class, "createSqlScriptExecutorFactory", jdbcConnectionFactory); |
266 | 267 |
|
267 | 268 | 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 | + } |
272 | 284 |
|
273 | 285 | return invokeMethod(flyway, "createMigrationResolver", scanner, scanner, sqlScriptExecutorFactory, sqlScriptFactory); |
274 | 286 | } else if (flywayVersion >= 52) { |
|
0 commit comments