Search in sources :

Example 1 with Scanner

use of org.flywaydb.core.internal.scanner.Scanner in project flyway by flyway.

the class FlywayExecutor method createResourceAndClassProviders.

private Pair<ResourceProvider, ClassProvider<JavaMigration>> createResourceAndClassProviders(boolean scannerRequired) {
    ResourceProvider resourceProvider;
    ClassProvider<JavaMigration> classProvider;
    if (!scannerRequired && configuration.isSkipDefaultResolvers() && configuration.isSkipDefaultCallbacks()) {
        resourceProvider = NoopResourceProvider.INSTANCE;
        // noinspection unchecked
        classProvider = NoopClassProvider.INSTANCE;
    } else {
        if (configuration.getResourceProvider() != null && configuration.getJavaMigrationClassProvider() != null) {
            // don't create the scanner at all in this case
            resourceProvider = configuration.getResourceProvider();
            classProvider = configuration.getJavaMigrationClassProvider();
        } else {
            boolean stream = false;
            Scanner<JavaMigration> scanner = new Scanner<>(JavaMigration.class, Arrays.asList(configuration.getLocations()), configuration.getClassLoader(), configuration.getEncoding(), configuration.isDetectEncoding(), stream, resourceNameCache, locationScannerCache, configuration.isFailOnMissingLocations());
            // set the defaults
            resourceProvider = scanner;
            classProvider = scanner;
            if (configuration.getResourceProvider() != null) {
                resourceProvider = configuration.getResourceProvider();
            }
            if (configuration.getJavaMigrationClassProvider() != null) {
                classProvider = configuration.getJavaMigrationClassProvider();
            }
        }
    }
    return Pair.of(resourceProvider, classProvider);
}
Also used : Scanner(org.flywaydb.core.internal.scanner.Scanner) ResourceProvider(org.flywaydb.core.api.ResourceProvider) NoopResourceProvider(org.flywaydb.core.internal.resource.NoopResourceProvider) JavaMigration(org.flywaydb.core.api.migration.JavaMigration)

Aggregations

ResourceProvider (org.flywaydb.core.api.ResourceProvider)1 JavaMigration (org.flywaydb.core.api.migration.JavaMigration)1 NoopResourceProvider (org.flywaydb.core.internal.resource.NoopResourceProvider)1 Scanner (org.flywaydb.core.internal.scanner.Scanner)1