Search in sources :

Example 1 with CompilerOutputStyle

use of org.codehaus.plexus.compiler.CompilerOutputStyle in project maven-plugins by apache.

the class AbstractCompilerMojo method computeStaleSources.

private Set<File> computeStaleSources(CompilerConfiguration compilerConfiguration, Compiler compiler, SourceInclusionScanner scanner) throws MojoExecutionException, CompilerException {
    SourceMapping mapping = getSourceMapping(compilerConfiguration, compiler);
    File outputDirectory;
    CompilerOutputStyle outputStyle = compiler.getCompilerOutputStyle();
    if (outputStyle == CompilerOutputStyle.ONE_OUTPUT_FILE_FOR_ALL_INPUT_FILES) {
        outputDirectory = buildDirectory;
    } else {
        outputDirectory = getOutputDirectory();
    }
    scanner.addSourceMapping(mapping);
    Set<File> staleSources = new HashSet<File>();
    for (String sourceRoot : getCompileSourceRoots()) {
        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) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) CompilerOutputStyle(org.codehaus.plexus.compiler.CompilerOutputStyle) 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) LinkedHashSet(java.util.LinkedHashSet)

Example 2 with CompilerOutputStyle

use of org.codehaus.plexus.compiler.CompilerOutputStyle 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 3 with CompilerOutputStyle

use of org.codehaus.plexus.compiler.CompilerOutputStyle 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

MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)3 CompilerOutputStyle (org.codehaus.plexus.compiler.CompilerOutputStyle)3 SingleTargetSourceMapping (org.codehaus.plexus.compiler.util.scan.mapping.SingleTargetSourceMapping)3 SourceMapping (org.codehaus.plexus.compiler.util.scan.mapping.SourceMapping)3 File (java.io.File)2 HashSet (java.util.HashSet)2 InclusionScanException (org.codehaus.plexus.compiler.util.scan.InclusionScanException)2 SuffixMapping (org.codehaus.plexus.compiler.util.scan.mapping.SuffixMapping)2 Iterator (java.util.Iterator)1 LinkedHashSet (java.util.LinkedHashSet)1