Search in sources :

Example 1 with FileSystemScanner

use of org.flywaydb.core.internal.util.scanner.filesystem.FileSystemScanner in project che by eclipse.

the class ResourcesFinder method findResources.

/**
     * Finds script resources in configured {@link FlywayConfiguration#getLocations()}.
     *
     * @param configuration
     *         flyway configuration to find scripts
     * @return found scripts or an empty list if nothing found
     * @throws IOException
     *         when any io error occurs during scripts look up
     */
Map<Location, List<Resource>> findResources(FlywayConfiguration configuration) throws IOException {
    final String prefix = configuration.getSqlMigrationPrefix();
    final String suffix = configuration.getSqlMigrationSuffix();
    final ClassPathScanner cpScanner = new ClassPathScanner(configuration.getClassLoader());
    final FileSystemScanner fsScanner = new FileSystemScanner();
    final Map<Location, List<Resource>> resources = new HashMap<>();
    for (String rawLocation : configuration.getLocations()) {
        final Location location = new Location(rawLocation);
        if (location.isClassPath()) {
            resources.put(location, newArrayList(cpScanner.scanForResources(location, prefix, suffix)));
        } else {
            resources.put(location, newArrayList(fsScanner.scanForResources(location, prefix, suffix)));
        }
    }
    return resources;
}
Also used : HashMap(java.util.HashMap) ClassPathScanner(org.flywaydb.core.internal.util.scanner.classpath.ClassPathScanner) List(java.util.List) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) FileSystemScanner(org.flywaydb.core.internal.util.scanner.filesystem.FileSystemScanner) Location(org.flywaydb.core.internal.util.Location)

Aggregations

Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Location (org.flywaydb.core.internal.util.Location)1 ClassPathScanner (org.flywaydb.core.internal.util.scanner.classpath.ClassPathScanner)1 FileSystemScanner (org.flywaydb.core.internal.util.scanner.filesystem.FileSystemScanner)1