FELIX-509: Add excludes configuration
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@634659 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
index f3e3938..9642f1b 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/SCRDescriptorMojo.java
@@ -79,6 +79,14 @@
private boolean generateAccessors;
/**
+ * The comma separated list of tokens to exclude when processing sources.
+ * All entries should be relative to the project directory
+ *
+ * @parameter alias="excludes"
+ */
+ private String sourceExcludes;
+
+ /**
* @see org.apache.maven.plugin.AbstractMojo#execute()
*/
public void execute() throws MojoExecutionException, MojoFailureException {
@@ -88,7 +96,8 @@
boolean hasFailures = false;
JavaClassDescriptorManager jManager = new JavaClassDescriptorManager(this.getLog(),
- this.project);
+ this.project,
+ this.sourceExcludes);
// iterate through all source classes and check for component tag
final JavaClassDescription[] javaSources = jManager.getSourceDescriptions();
Arrays.sort(javaSources, new JavaClassDescriptionInheritanceComparator());
diff --git a/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java
index da8105a..8dee35f 100644
--- a/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java
+++ b/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java
@@ -74,8 +74,9 @@
* @throws MojoFailureException
* @throws MojoExecutionException
*/
- public JavaClassDescriptorManager(final Log log,
- final MavenProject project)
+ public JavaClassDescriptorManager(final Log log,
+ final MavenProject project,
+ final String excludes)
throws MojoFailureException, MojoExecutionException {
this.log = log;
this.project = project;
@@ -91,7 +92,31 @@
this.log.debug("Adding source tree " + tree);
builder.addSourceTree(new File(tree));
}
- this.sources = builder.getSources();
+ // FELIX-509: check for excludes
+ if ( excludes != null ) {
+ final List sourcesList = new ArrayList(Arrays.asList(builder.getSources()));
+ final File projectDir = project.getBasedir();
+ final StringTokenizer st = new StringTokenizer(excludes, ",");
+ while ( st.hasMoreTokens() ) {
+ final String excludeEntry = st.nextToken();
+ this.log.debug("Processing configured exclude " + excludeEntry);
+ String exclude = projectDir.getAbsolutePath() + File.separatorChar + excludeEntry;
+ if ( File.separatorChar != '/' ) {
+ exclude = exclude.replace('/', File.separatorChar);
+ }
+ final Iterator iter = sourcesList.iterator();
+ while ( iter.hasNext() ) {
+ JavaSource current = (JavaSource)iter.next();
+ if ( current.getFile().getAbsolutePath().startsWith(exclude)) {
+ this.log.debug("Excluding source " + current.getFile());
+ iter.remove();
+ }
+ }
+ }
+ this.sources = (JavaSource[]) sourcesList.toArray(new JavaSource[sourcesList.size()]);
+ } else {
+ this.sources = builder.getSources();
+ }
// and now scan artifacts
final List components = new ArrayList();