Search in sources :

Example 6 with SuffixMapping

use of org.codehaus.plexus.compiler.util.scan.mapping.SuffixMapping in project antlr4 by tunnelvisionlabs.

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);
}
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) SourceMapping(org.codehaus.plexus.compiler.util.scan.mapping.SourceMapping) SimpleSourceInclusionScanner(org.codehaus.plexus.compiler.util.scan.SimpleSourceInclusionScanner)

Example 7 with SuffixMapping

use of org.codehaus.plexus.compiler.util.scan.mapping.SuffixMapping 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 8 with SuffixMapping

use of org.codehaus.plexus.compiler.util.scan.mapping.SuffixMapping in project maven-plugins by apache.

the class AbstractCompilerMojo method getSourceMapping.

private SourceMapping getSourceMapping(CompilerConfiguration compilerConfiguration, Compiler compiler) throws CompilerException, MojoExecutionException {
    CompilerOutputStyle outputStyle = compiler.getCompilerOutputStyle();
    SourceMapping mapping;
    if (outputStyle == CompilerOutputStyle.ONE_OUTPUT_FILE_PER_INPUT_FILE) {
        mapping = new SuffixMapping(compiler.getInputFileEnding(compilerConfiguration), compiler.getOutputFileEnding(compilerConfiguration));
    } else if (outputStyle == CompilerOutputStyle.ONE_OUTPUT_FILE_FOR_ALL_INPUT_FILES) {
        mapping = new SingleTargetSourceMapping(compiler.getInputFileEnding(compilerConfiguration), compiler.getOutputFile(compilerConfiguration));
    } else {
        throw new MojoExecutionException("Unknown compiler output style: '" + outputStyle + "'.");
    }
    return mapping;
}
Also used : SingleTargetSourceMapping(org.codehaus.plexus.compiler.util.scan.mapping.SingleTargetSourceMapping) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) CompilerOutputStyle(org.codehaus.plexus.compiler.CompilerOutputStyle) SuffixMapping(org.codehaus.plexus.compiler.util.scan.mapping.SuffixMapping) SingleTargetSourceMapping(org.codehaus.plexus.compiler.util.scan.mapping.SingleTargetSourceMapping) SourceMapping(org.codehaus.plexus.compiler.util.scan.mapping.SourceMapping)

Example 9 with SuffixMapping

use of org.codehaus.plexus.compiler.util.scan.mapping.SuffixMapping in project tycho by eclipse.

the class AbstractCompilerMojo method computeStaleSources.

private Set<File> computeStaleSources(CompilerConfiguration compilerConfiguration, Compiler compiler, SourceInclusionScanner scanner) throws MojoExecutionException, CompilerException {
    CompilerOutputStyle outputStyle = compiler.getCompilerOutputStyle();
    SourceMapping mapping;
    File outputDirectory;
    if (outputStyle == CompilerOutputStyle.ONE_OUTPUT_FILE_PER_INPUT_FILE) {
        mapping = new SuffixMapping(compiler.getInputFileEnding(compilerConfiguration), compiler.getOutputFileEnding(compilerConfiguration));
        outputDirectory = getOutputDirectory();
    } else if (outputStyle == CompilerOutputStyle.ONE_OUTPUT_FILE_FOR_ALL_INPUT_FILES) {
        mapping = new SingleTargetSourceMapping(compiler.getInputFileEnding(compilerConfiguration), compiler.getOutputFile(compilerConfiguration));
        outputDirectory = buildDirectory;
    } else {
        throw new MojoExecutionException("Unknown compiler output style: '" + outputStyle + "'.");
    }
    scanner.addSourceMapping(mapping);
    Set<File> staleSources = new HashSet<>();
    for (Iterator it = getCompileSourceRoots().iterator(); it.hasNext(); ) {
        String sourceRoot = (String) it.next();
        File rootFile = new File(sourceRoot);
        if (!rootFile.isDirectory()) {
            continue;
        }
        try {
            staleSources.addAll(scanner.getIncludedSources(rootFile, outputDirectory));
        } catch (InclusionScanException e) {
            throw new MojoExecutionException("Error scanning source root: \'" + sourceRoot + "\' " + "for stale files to recompile.", e);
        }
    }
    return staleSources;
}
Also used : InclusionScanException(org.codehaus.plexus.compiler.util.scan.InclusionScanException) SingleTargetSourceMapping(org.codehaus.plexus.compiler.util.scan.mapping.SingleTargetSourceMapping) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) CompilerOutputStyle(org.codehaus.plexus.compiler.CompilerOutputStyle) Iterator(java.util.Iterator) SuffixMapping(org.codehaus.plexus.compiler.util.scan.mapping.SuffixMapping) SingleTargetSourceMapping(org.codehaus.plexus.compiler.util.scan.mapping.SingleTargetSourceMapping) SourceMapping(org.codehaus.plexus.compiler.util.scan.mapping.SourceMapping) File(java.io.File) HashSet(java.util.HashSet)

Aggregations

SuffixMapping (org.codehaus.plexus.compiler.util.scan.mapping.SuffixMapping)9 SourceMapping (org.codehaus.plexus.compiler.util.scan.mapping.SourceMapping)6 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)5 SimpleSourceInclusionScanner (org.codehaus.plexus.compiler.util.scan.SimpleSourceInclusionScanner)5 SourceInclusionScanner (org.codehaus.plexus.compiler.util.scan.SourceInclusionScanner)5 File (java.io.File)4 InclusionScanException (org.codehaus.plexus.compiler.util.scan.InclusionScanException)4 HashSet (java.util.HashSet)3 IOException (java.io.IOException)2 URLClassLoader (java.net.URLClassLoader)2 DependencyResolutionRequiredException (org.apache.maven.artifact.DependencyResolutionRequiredException)2 MojoFailureException (org.apache.maven.plugin.MojoFailureException)2 CompilerOutputStyle (org.codehaus.plexus.compiler.CompilerOutputStyle)2 SingleTargetSourceMapping (org.codehaus.plexus.compiler.util.scan.mapping.SingleTargetSourceMapping)2 ClassWithJavascript (org.stjs.generator.ClassWithJavascript)2 JavascriptFileGenerationException (org.stjs.generator.JavascriptFileGenerationException)2 MultipleFileGenerationException (org.stjs.generator.MultipleFileGenerationException)2 SourceMapGeneratorV3 (com.google.debugging.sourcemap.SourceMapGeneratorV3)1 BufferedOutputStream (java.io.BufferedOutputStream)1 BufferedWriter (java.io.BufferedWriter)1