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

com.github.bingoohuang.blackcat.maven.scan.InstrumentSourceScanner Maven / Gradle / Ivy

package com.github.bingoohuang.blackcat.maven.scan;

import org.codehaus.plexus.compiler.util.scan.AbstractSourceInclusionScanner;
import org.codehaus.plexus.compiler.util.scan.InclusionScanException;

import java.io.File;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

public class InstrumentSourceScanner extends AbstractSourceInclusionScanner {
    private final Set sourceIncludes;
    private final Set sourceExcludes;

    public InstrumentSourceScanner() {
        this(Collections.singleton("**/*"), Collections.emptySet());
    }

    public InstrumentSourceScanner(Set sourceIncludes, Set sourceExcludes) {
        this.sourceIncludes = sourceIncludes;
        this.sourceExcludes = sourceExcludes;
    }

    @Override
    public Set getIncludedSources(File sourceDir, File targetDir) throws InclusionScanException {
        String[] potentialIncludes = scanForSources(sourceDir, sourceIncludes, sourceExcludes);
        Set matchingSources = new HashSet(potentialIncludes != null ? potentialIncludes.length : 0);
        if (potentialIncludes != null) {
            for (String potentialSource : potentialIncludes) {
                matchingSources.add(new File(sourceDir, potentialSource));
            }
        }
        return matchingSources;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy