All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.liquibase.maven.plugins.MavenResourceAccessor Maven / Gradle / Ivy

package org.liquibase.maven.plugins;

import java.io.IOException;
import java.io.InputStream;
import java.util.*;

import liquibase.resource.ClassLoaderResourceAccessor;

/**
 * Extension of {@link liquibase.resource.ClassLoaderResourceAccessor} for Maven which will use a default or user specified {@link ClassLoader} to load files/resources.
 */
public class MavenResourceAccessor extends ClassLoaderResourceAccessor {

    public MavenResourceAccessor() {
        this(MavenResourceAccessor.class.getClassLoader());
    }

    public MavenResourceAccessor(ClassLoader classLoader) {
        super(classLoader);
    }

    @Override
    public Set getResourcesAsStream(String path) throws IOException {
        return super.getResourcesAsStream(path.replaceFirst("^target/classes/", ""));
    }

    @Override
    public Set list(String relativeTo, String path, boolean includeFiles, boolean includeDirectories, boolean recursive) throws IOException {
        Set contents = super.list(relativeTo, path, includeFiles, includeDirectories, recursive);
        if (contents == null || contents.size() == 0) {
            contents = super.list(relativeTo, path.replaceFirst("^target/classes/", ""), includeFiles, includeDirectories, recursive);
        }
        return contents;

    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy