Skip to content

Commit

Permalink
Issue 42 apply patch
Browse files Browse the repository at this point in the history
  • Loading branch information
bsorrentino committed Aug 26, 2012
1 parent aae8e16 commit 5f82c3d
Showing 1 changed file with 34 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package org.bsc.maven.plugin.processor;

import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -139,7 +140,15 @@ public abstract class AbstractAnnotationProcessorMojo extends AbstractMojo

private static final Lock syncExecutionLock = new ReentrantLock();


/**
* additional source directories for the annotation processors.
* @parameter
*/
private File[] additionalSourceDirectories;

public File[] getAdditionalSourceDirectories() {
return additionalSourceDirectories;
}

protected abstract File getSourceDirectory();
protected abstract File getOutputClassDirectory();
Expand Down Expand Up @@ -241,24 +250,10 @@ private void executeWithExceptionsHandled() throws Exception
// new Debug(project).printDebugInfo();

java.io.File sourceDir = getSourceDirectory();
if( sourceDir==null ) {
getLog().warn( "source directory cannot be read (null returned)! Processor task will be skipped");
return;
}
if( !sourceDir.exists() ) {
getLog().warn( "source directory doesn't exist! Processor task will be skipped");
return;
}
if( !sourceDir.isDirectory() ) {
getLog().warn( "source directory is invalid! Processor task will be skipped");
return;
List<File> files = scanSourceDirectorySources(sourceDir);
for (File additionalSourceDir : getAdditionalSourceDirectories()) {
files.addAll(scanSourceDirectorySources(additionalSourceDir));
}

final String includesString = ( includes==null || includes.length==0) ? "**/*.java" : StringUtils.join(includes, ",");
final String excludesString = ( excludes==null || excludes.length==0) ? null : StringUtils.join(excludes, ",");

List<File> files = FileUtils.getFiles(getSourceDirectory(), includesString, excludesString);

Iterable< ? extends JavaFileObject> compilationUnits1 = null;


Expand Down Expand Up @@ -384,6 +379,27 @@ public void report(Diagnostic< ? extends JavaFileObject> diagnostic)
}

}

private List<File> scanSourceDirectorySources(File sourceDir) throws IOException {
if( sourceDir==null ) {
getLog().warn( "source directory cannot be read (null returned)! Processor task will be skipped");
return null;
}
if( !sourceDir.exists() ) {
getLog().warn( "source directory doesn't exist! Processor task will be skipped");
return null;
}
if( !sourceDir.isDirectory() ) {
getLog().warn( "source directory is invalid! Processor task will be skipped");
return null;
}

final String includesString = ( includes==null || includes.length==0) ? "**/*.java" : StringUtils.join(includes, ",");
final String excludesString = ( excludes==null || excludes.length==0) ? null : StringUtils.join(excludes, ",");

List<File> files = FileUtils.getFiles(sourceDir, includesString, excludesString);
return files;
}

private void addCompilerArguments(List<String> options)
{
Expand Down

0 comments on commit 5f82c3d

Please sign in to comment.