diff --git a/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/IOUtils.java b/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/IOUtils.java index 82dbbe34..308adbca 100644 --- a/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/IOUtils.java +++ b/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/IOUtils.java @@ -440,7 +440,7 @@ private static void getInnerSourceClasses(SourceVisitor visitor, } else { - new File((String) i.next()); + srcDir = new File(dir.toString()); } //Scan all files on directory and add to builder addFileToJavaDocBuilder(visitor, selector, srcDir); diff --git a/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/MakeComponentsMojo.java b/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/MakeComponentsMojo.java index a3e788ba..b2cead31 100644 --- a/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/MakeComponentsMojo.java +++ b/maven2-plugins/myfaces-builder-plugin/src/main/java/org/apache/myfaces/buildtools/maven2/plugin/builder/MakeComponentsMojo.java @@ -197,6 +197,13 @@ public class MakeComponentsMojo extends AbstractBuilderMojo */ private File mainSourceDirectory2; + /** + * Excludes files from the component generation. Must be comma separated. + * + * @parameter + */ + private String[] excludes; + /** * Execute the Mojo. */ @@ -217,7 +224,20 @@ public void execute() throws MojoExecutionException File mdFile = new File(buildDirectory, metadataFile); Model model = IOUtils.loadModel(mdFile); new Flattener(model).flatten(); - + + for(int i = 0; i < excludes.length; i++){ + String str = excludes[i]; + getLog().info("Files to be excluded: "+ str); + if(excludes != null){ + if(str.contains("**")) + { + // must be reglar expression + str = str.replace("**", ".*"); + } + excludes[i] = str; + } + } + Properties cacheInfo = new Properties(); loadCache(cacheInfo); generateComponents(model, cacheInfo, mdFile.lastModified() ); @@ -360,7 +380,10 @@ else if (!outFile.exists()) for (Iterator i = sourceDirs.iterator(); i.hasNext();) { String srcDir = (String) i.next(); - builder.addSourceTree(new File(srcDir)); + File dir = new File(srcDir); + //recusively add files to the builder + // allows control to exclude files + addFilesToBuilder(builder,dir); } //Init velocity @@ -420,6 +443,38 @@ else if (!outFile.exists()) } } } + + public void addFilesToBuilder(JavaDocBuilder builder, File dir) throws IOException + { + File[] directoryListing = dir.listFiles(); + if(directoryListing == null) + { + return; + } + for(int j = 0; j < directoryListing.length; j++) + { + File f = directoryListing[j]; + if(f.isDirectory()){ + addFilesToBuilder(builder, f); + } + else + { + boolean skip = false; + for(int i = 0; i < excludes.length; i++) { + String currentExclude= excludes[i]; + if(currentExclude != null && f.toString().matches(currentExclude)) + { + getLog().info("Excluding source from builder: " + f); + skip = true; + break; + } + } + if(!skip){ + builder.addSource(f); + } + } + } + } public boolean canGenerateComponent(ComponentMeta component) {