use of org.codehaus.plexus.compiler.util.scan.InclusionScanException 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;
}
use of org.codehaus.plexus.compiler.util.scan.InclusionScanException in project tycho by eclipse.
the class AbstractOsgiCompilerMojo method doCopyResources.
/*
* mimics the behavior of the PDE incremental builder which by default copies all (non-java)
* resource files in source directories into the target folder
*/
private void doCopyResources() throws MojoExecutionException {
if (!copyResources) {
return;
}
for (String sourceRoot : getCompileSourceRoots()) {
// StaleSourceScanner.getIncludedSources throws IllegalStateException
// if directory doesnt't exist
File sourceRootFile = new File(sourceRoot);
if (!sourceRootFile.isDirectory()) {
getLog().warn("Source directory " + sourceRoot + " does not exist");
continue;
}
Set<String> excludes = new HashSet<>();
excludes.addAll(excludeResources);
excludes.addAll(getEclipsePluginProject().getBuildProperties().getBinExcludes());
excludes.add("**/*.java");
StaleSourceScanner scanner = new StaleSourceScanner(0L, MATCH_ALL, excludes);
CopyMapping copyMapping = new CopyMapping();
scanner.addSourceMapping(copyMapping);
try {
scanner.getIncludedSources(sourceRootFile, this.outputJar.getOutputDirectory());
for (CopyMapping.SourceTargetPair sourceTargetPair : copyMapping.getSourceTargetPairs()) {
FileUtils.copyFile(new File(sourceRoot, sourceTargetPair.source), sourceTargetPair.target);
}
} catch (InclusionScanException e) {
throw new MojoExecutionException("Exception while scanning for resource files in " + sourceRoot, e);
} catch (IOException e) {
throw new MojoExecutionException("Exception copying resource files from " + sourceRoot + " to " + this.outputJar.getOutputDirectory(), e);
}
}
}
Aggregations