use of org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner in project antlr4 by tunnelvisionlabs.
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);
}
use of org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner in project maven-plugins by apache.
the class AbstractCompilerMojo method getCompileSources.
/**
* @return all source files for the compiler
*/
private Set<File> getCompileSources(Compiler compiler, CompilerConfiguration compilerConfiguration) throws MojoExecutionException, CompilerException {
String inputFileEnding = compiler.getInputFileEnding(compilerConfiguration);
if (StringUtils.isEmpty(inputFileEnding)) {
// see MCOMPILER-199 GroovyEclipseCompiler doesn't set inputFileEnding
// so we can presume it's all files from the source directory
inputFileEnding = ".*";
}
SourceInclusionScanner scanner = getSourceInclusionScanner(inputFileEnding);
SourceMapping mapping = getSourceMapping(compilerConfiguration, compiler);
scanner.addSourceMapping(mapping);
Set<File> compileSources = new HashSet<File>();
for (String sourceRoot : getCompileSourceRoots()) {
File rootFile = new File(sourceRoot);
if (!rootFile.isDirectory() || rootFile.getAbsoluteFile().equals(compilerConfiguration.getGeneratedSourcesDirectory())) {
continue;
}
try {
compileSources.addAll(scanner.getIncludedSources(rootFile, null));
} catch (InclusionScanException e) {
throw new MojoExecutionException("Error scanning source root: \'" + sourceRoot + "\' for stale files to recompile.", e);
}
}
return compileSources;
}
use of org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner in project maven-plugins by apache.
the class CompilerMojo method getSourceInclusionScanner.
protected SourceInclusionScanner getSourceInclusionScanner(String inputFileEnding) {
SourceInclusionScanner scanner;
// it's not defined if we get the ending with or without the dot '.'
String defaultIncludePattern = "**/*" + (inputFileEnding.startsWith(".") ? "" : ".") + inputFileEnding;
if (includes.isEmpty() && excludes.isEmpty()) {
includes = Collections.singleton(defaultIncludePattern);
scanner = new SimpleSourceInclusionScanner(includes, Collections.<String>emptySet());
} else {
if (includes.isEmpty()) {
includes.add(defaultIncludePattern);
}
scanner = new SimpleSourceInclusionScanner(includes, excludes);
}
return scanner;
}
use of org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner in project maven-plugins by apache.
the class TestCompilerMojo method getSourceInclusionScanner.
protected SourceInclusionScanner getSourceInclusionScanner(String inputFileEnding) {
SourceInclusionScanner scanner;
// it's not defined if we get the ending with or without the dot '.'
String defaultIncludePattern = "**/*" + (inputFileEnding.startsWith(".") ? "" : ".") + inputFileEnding;
if (testIncludes.isEmpty() && testExcludes.isEmpty()) {
testIncludes = Collections.singleton(defaultIncludePattern);
scanner = new SimpleSourceInclusionScanner(testIncludes, Collections.<String>emptySet());
} else {
if (testIncludes.isEmpty()) {
testIncludes.add(defaultIncludePattern);
}
scanner = new SimpleSourceInclusionScanner(testIncludes, testExcludes);
}
return scanner;
}
use of org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner in project antlr4 by antlr.
the class Antlr4Mojo method getGrammarFiles.
private Set<File> getGrammarFiles(File sourceDirectory) throws InclusionScanException {
// Which files under the source set should we be looking for as grammar files
SourceMapping mapping = new SuffixMapping("g4", Collections.<String>emptySet());
// What are the sets of includes (defaulted or otherwise).
Set<String> includes = getIncludesPatterns();
// Now, to the excludes, we need to add the imports directory
// as this is autoscanned for imported grammars and so is auto-excluded from the
// set of grammar fields we should be analyzing.
excludes.add("imports/**");
SourceInclusionScanner scan = new SimpleSourceInclusionScanner(includes, excludes);
scan.addSourceMapping(mapping);
return scan.getIncludedSources(sourceDirectory, null);
}
Aggregations