Search in sources :

Example 1 with ResolvedMigrationComparator

use of org.flywaydb.core.internal.resolver.ResolvedMigrationComparator in project flyway by flyway.

the class JdbcMigrationResolver method resolveMigrations.

@Override
public List<ResolvedMigration> resolveMigrations() {
    List<ResolvedMigration> migrations = new ArrayList<ResolvedMigration>();
    if (!location.isClassPath()) {
        return migrations;
    }
    try {
        Class<?>[] classes = scanner.scanForClasses(location, JdbcMigration.class);
        for (Class<?> clazz : classes) {
            JdbcMigration jdbcMigration = ClassUtils.instantiate(clazz.getName(), scanner.getClassLoader());
            ConfigurationInjectionUtils.injectFlywayConfiguration(jdbcMigration, configuration);
            ResolvedMigrationImpl migrationInfo = extractMigrationInfo(jdbcMigration);
            migrationInfo.setPhysicalLocation(ClassUtils.getLocationOnDisk(clazz));
            migrationInfo.setExecutor(new JdbcMigrationExecutor(jdbcMigration));
            migrations.add(migrationInfo);
        }
    } catch (Exception e) {
        throw new FlywayException("Unable to resolve Jdbc Java migrations in location: " + location + " (" + e.getMessage() + ")", 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) JdbcMigration(org.flywaydb.core.api.migration.jdbc.JdbcMigration) ResolvedMigrationImpl(org.flywaydb.core.internal.resolver.ResolvedMigrationImpl) FlywayException(org.flywaydb.core.api.FlywayException)

Example 2 with ResolvedMigrationComparator

use of org.flywaydb.core.internal.resolver.ResolvedMigrationComparator 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)

Example 3 with ResolvedMigrationComparator

use of org.flywaydb.core.internal.resolver.ResolvedMigrationComparator in project registry by hortonworks.

the class ShellMigrationResolver method resolveMigrations.

public List<ResolvedMigration> resolveMigrations() {
    List<ResolvedMigration> migrations = new ArrayList<ResolvedMigration>();
    Resource[] resources = scanner.scanForResources(location, shellMigrationPrefix, shellMigrationSuffix);
    for (Resource resource : resources) {
        ResolvedMigrationImpl resolvedMigration = extractMigrationInfo(resource);
        resolvedMigration.setPhysicalLocation(resource.getLocationOnDisk());
        resolvedMigration.setExecutor(new ShellMigrationExecutor(resource));
        migrations.add(resolvedMigration);
    }
    Collections.sort(migrations, new ResolvedMigrationComparator());
    return migrations;
}
Also used : ResolvedMigrationComparator(org.flywaydb.core.internal.resolver.ResolvedMigrationComparator) ArrayList(java.util.ArrayList) Resource(org.flywaydb.core.internal.util.scanner.Resource) ResolvedMigration(org.flywaydb.core.api.resolver.ResolvedMigration) ResolvedMigrationImpl(org.flywaydb.core.internal.resolver.ResolvedMigrationImpl)

Example 4 with ResolvedMigrationComparator

use of org.flywaydb.core.internal.resolver.ResolvedMigrationComparator in project flyway by flyway.

the class ScanningJavaMigrationResolver method resolveMigrations.

@Override
public List<ResolvedMigration> resolveMigrations(Context context) {
    List<ResolvedMigration> migrations = new ArrayList<>();
    for (Class<?> clazz : classProvider.getClasses()) {
        JavaMigration javaMigration = ClassUtils.instantiate(clazz.getName(), configuration.getClassLoader());
        migrations.add(new ResolvedJavaMigration(javaMigration));
    }
    Collections.sort(migrations, new ResolvedMigrationComparator());
    return migrations;
}
Also used : ResolvedMigrationComparator(org.flywaydb.core.internal.resolver.ResolvedMigrationComparator) ArrayList(java.util.ArrayList) ResolvedMigration(org.flywaydb.core.api.resolver.ResolvedMigration) JavaMigration(org.flywaydb.core.api.migration.JavaMigration)

Example 5 with ResolvedMigrationComparator

use of org.flywaydb.core.internal.resolver.ResolvedMigrationComparator in project flyway by flyway.

the class FixedJavaMigrationResolver method resolveMigrations.

@Override
public List<ResolvedMigration> resolveMigrations(Context context) {
    List<ResolvedMigration> migrations = new ArrayList<>();
    for (JavaMigration javaMigration : javaMigrations) {
        migrations.add(new ResolvedJavaMigration(javaMigration));
    }
    Collections.sort(migrations, new ResolvedMigrationComparator());
    return migrations;
}
Also used : ResolvedMigrationComparator(org.flywaydb.core.internal.resolver.ResolvedMigrationComparator) ArrayList(java.util.ArrayList) ResolvedMigration(org.flywaydb.core.api.resolver.ResolvedMigration) JavaMigration(org.flywaydb.core.api.migration.JavaMigration)

Aggregations

ArrayList (java.util.ArrayList)8 ResolvedMigration (org.flywaydb.core.api.resolver.ResolvedMigration)8 ResolvedMigrationComparator (org.flywaydb.core.internal.resolver.ResolvedMigrationComparator)8 ResolvedMigrationImpl (org.flywaydb.core.internal.resolver.ResolvedMigrationImpl)4 FlywayException (org.flywaydb.core.api.FlywayException)2 JavaMigration (org.flywaydb.core.api.migration.JavaMigration)2 JdbcMigration (org.flywaydb.core.api.migration.jdbc.JdbcMigration)1 SpringJdbcMigration (org.flywaydb.core.api.migration.spring.SpringJdbcMigration)1 Resource (org.flywaydb.core.internal.util.scanner.Resource)1