Search in sources :

Example 1 with SpringJdbcMigration

use of org.flywaydb.core.api.migration.spring.SpringJdbcMigration in project flyway by flyway.

the class SpringJdbcMigrationResolver method resolveMigrations.

@Override
public Collection<ResolvedMigration> resolveMigrations() {
    List<ResolvedMigration> migrations = new ArrayList<ResolvedMigration>();
    if (!location.isClassPath()) {
        return migrations;
    }
    try {
        Class<?>[] classes = scanner.scanForClasses(location, SpringJdbcMigration.class);
        for (Class<?> clazz : classes) {
            SpringJdbcMigration springJdbcMigration = ClassUtils.instantiate(clazz.getName(), scanner.getClassLoader());
            ConfigurationInjectionUtils.injectFlywayConfiguration(springJdbcMigration, configuration);
            ResolvedMigrationImpl migrationInfo = extractMigrationInfo(springJdbcMigration);
            migrationInfo.setPhysicalLocation(ClassUtils.getLocationOnDisk(clazz));
            migrationInfo.setExecutor(new SpringJdbcMigrationExecutor(springJdbcMigration));
            migrations.add(migrationInfo);
        }
    } catch (Exception e) {
        throw new FlywayException("Unable to resolve Spring Jdbc Java migrations in location: " + location, e);
    }
    Collections.sort(migrations, new ResolvedMigrationComparator());
    return migrations;
}
Also used : FlywayException(org.flywaydb.core.api.FlywayException) ResolvedMigrationComparator(org.flywaydb.core.internal.resolver.ResolvedMigrationComparator) ArrayList(java.util.ArrayList) ResolvedMigration(org.flywaydb.core.api.resolver.ResolvedMigration) SpringJdbcMigration(org.flywaydb.core.api.migration.spring.SpringJdbcMigration) ResolvedMigrationImpl(org.flywaydb.core.internal.resolver.ResolvedMigrationImpl) FlywayException(org.flywaydb.core.api.FlywayException)

Aggregations

ArrayList (java.util.ArrayList)1 FlywayException (org.flywaydb.core.api.FlywayException)1 SpringJdbcMigration (org.flywaydb.core.api.migration.spring.SpringJdbcMigration)1 ResolvedMigration (org.flywaydb.core.api.resolver.ResolvedMigration)1 ResolvedMigrationComparator (org.flywaydb.core.internal.resolver.ResolvedMigrationComparator)1 ResolvedMigrationImpl (org.flywaydb.core.internal.resolver.ResolvedMigrationImpl)1