Search in sources :

Example 6 with SourceInclusionScanner

use of org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner in project antlr4 by antlr.

the class Antlr4Mojo method getImportFiles.

private Set<File> getImportFiles(File sourceDirectory) throws InclusionScanException {
    if (!libDirectory.exists())
        return Collections.emptySet();
    Set<String> includes = new HashSet<String>();
    includes.add("*.g4");
    includes.add("*.tokens");
    SourceInclusionScanner scan = new SimpleSourceInclusionScanner(includes, Collections.<String>emptySet());
    scan.addSourceMapping(new SuffixMapping("G4", "g4"));
    return scan.getIncludedSources(libDirectory, null);
}
Also used : SourceInclusionScanner(org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner) SimpleSourceInclusionScanner(org.codehaus.plexus.compiler.util.scan.SimpleSourceInclusionScanner) SuffixMapping(org.codehaus.plexus.compiler.util.scan.mapping.SuffixMapping) SimpleSourceInclusionScanner(org.codehaus.plexus.compiler.util.scan.SimpleSourceInclusionScanner) HashSet(java.util.HashSet)

Example 7 with SourceInclusionScanner

use of org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner in project jangaroo-tools by CoreMedia.

the class MavenPluginHelper method computeStaleSources.

public List<File> computeStaleSources(List<File> compileSourceRoots, Set<String> includes, Set<String> excludes, File outputDirectory, String inputFileSuffix, String outputFileSuffix, int staleMillis) throws MojoExecutionException {
    SourceInclusionScanner scanner = createSourceInclusionScanner(includes, excludes, inputFileSuffix, staleMillis);
    scanner.addSourceMapping(new SuffixMapping(inputFileSuffix, outputFileSuffix));
    log.debug("Searching for");
    Set<File> staleSources = new LinkedHashSet<File>();
    for (File rootFile : compileSourceRoots) {
        if (!rootFile.isDirectory()) {
            continue;
        }
        try {
            log.debug("scanner.getIncludedSources(" + rootFile + ", " + outputDirectory + ")");
            // noinspection unchecked
            staleSources.addAll(scanner.getIncludedSources(rootFile, outputDirectory));
        } catch (InclusionScanException e) {
            throw new MojoExecutionException("Error scanning source root: \'" + rootFile.getAbsolutePath() + "\' " + "for stale files to recompile.", e);
        }
    }
    return Collections.unmodifiableList(new ArrayList<File>(staleSources));
}
Also used : LinkedHashSet(java.util.LinkedHashSet) InclusionScanException(org.codehaus.plexus.compiler.util.scan.InclusionScanException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) SimpleSourceInclusionScanner(org.codehaus.plexus.compiler.util.scan.SimpleSourceInclusionScanner) SourceInclusionScanner(org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner) SuffixMapping(org.codehaus.plexus.compiler.util.scan.mapping.SuffixMapping) File(java.io.File)

Aggregations

SourceInclusionScanner (org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner)7 SimpleSourceInclusionScanner (org.codehaus.plexus.compiler.util.scan.SimpleSourceInclusionScanner)6 SuffixMapping (org.codehaus.plexus.compiler.util.scan.mapping.SuffixMapping)3 File (java.io.File)2 HashSet (java.util.HashSet)2 LinkedHashSet (java.util.LinkedHashSet)2 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)2 InclusionScanException (org.codehaus.plexus.compiler.util.scan.InclusionScanException)2 SourceMapping (org.codehaus.plexus.compiler.util.scan.mapping.SourceMapping)2 StaleSourceScanner (org.codehaus.plexus.compiler.util.scan.StaleSourceScanner)1 SingleTargetSourceMapping (org.codehaus.plexus.compiler.util.scan.mapping.SingleTargetSourceMapping)1