incubator-rat-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1188628 - in /incubator/rat/main/trunk: RELEASE_NOTES.txt apache-rat-core/src/main/java/org/apache/rat/Report.java apache-rat/src/site/apt/index.apt
Date Tue, 25 Oct 2011 12:28:11 GMT
Author: bodewig
Date: Tue Oct 25 12:28:11 2011
New Revision: 1188628

URL: http://svn.apache.org/viewvc?rev=1188628&view=rev
Log:
command-line option to specify a file holding exclude-patterns.  Submitted by Chris Burroughs.
 RAT-99

Modified:
    incubator/rat/main/trunk/RELEASE_NOTES.txt
    incubator/rat/main/trunk/apache-rat-core/src/main/java/org/apache/rat/Report.java
    incubator/rat/main/trunk/apache-rat/src/site/apt/index.apt

Modified: incubator/rat/main/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/incubator/rat/main/trunk/RELEASE_NOTES.txt?rev=1188628&r1=1188627&r2=1188628&view=diff
==============================================================================
--- incubator/rat/main/trunk/RELEASE_NOTES.txt (original)
+++ incubator/rat/main/trunk/RELEASE_NOTES.txt Tue Oct 25 12:28:11 2011
@@ -33,6 +33,8 @@ RAT 0.8
     * RAT-95 When adding licenses RAT will now remove any BOM from the file.
     * RAT-93 --addLicense now supports more .NET specific files like
       MS Visual Studio project and solution files
+    * RAT-99 The command line interface has a new option that
+      specifies a file containing regular expressions for files to exclude
 
 RAT 0.7
 =======

Modified: incubator/rat/main/trunk/apache-rat-core/src/main/java/org/apache/rat/Report.java
URL: http://svn.apache.org/viewvc/incubator/rat/main/trunk/apache-rat-core/src/main/java/org/apache/rat/Report.java?rev=1188628&r1=1188627&r2=1188628&view=diff
==============================================================================
--- incubator/rat/main/trunk/apache-rat-core/src/main/java/org/apache/rat/Report.java (original)
+++ incubator/rat/main/trunk/apache-rat-core/src/main/java/org/apache/rat/Report.java Tue
Oct 25 12:28:11 2011
@@ -29,6 +29,7 @@ import java.io.PipedReader;
 import java.io.PipedWriter;
 import java.io.PrintStream;
 import java.io.Writer;
+import java.util.List;
 
 import javax.xml.transform.TransformerConfigurationException;
 
@@ -40,7 +41,10 @@ import org.apache.commons.cli.OptionGrou
 import org.apache.commons.cli.Options;
 import org.apache.commons.cli.ParseException;
 import org.apache.commons.cli.PosixParser;
+import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.filefilter.NotFileFilter;
+import org.apache.commons.io.filefilter.RegexFileFilter;
+import org.apache.commons.io.filefilter.OrFileFilter;
 import org.apache.commons.io.filefilter.WildcardFileFilter;
 import org.apache.rat.api.RatException;
 import org.apache.rat.report.IReportable;
@@ -55,6 +59,7 @@ import org.apache.rat.walker.DirectoryWa
 
 public class Report {
     private static final char EXCLUDE_CLI = 'e';
+    private static final char EXCLUDE_FILE_CLI = 'E';
     private static final char STYLESHEET_CLI = 's';
 
     //@SuppressWarnings("unchecked")
@@ -95,7 +100,18 @@ public class Report {
                     report.setInputFileFilter(filter);
                 }
             }
-
+            else if (cl.hasOption(EXCLUDE_FILE_CLI)) {
+                String excludeFileName = cl.getOptionValue(EXCLUDE_FILE_CLI);
+                if (excludeFileName != null) {
+                    List excludes = FileUtils.readLines(new File(excludeFileName));
+                    final OrFileFilter orFilter = new OrFileFilter();
+                    for (int i=0; i< excludes.size(); i++) {
+                        orFilter.addFileFilter(new RegexFileFilter((String)excludes.get(i)));
+                    }
+                    final FilenameFilter filter = new NotFileFilter(orFilter);
+                    report.setInputFileFilter(filter);
+                }
+            }
             if (cl.hasOption('x')) {
                 report.report(System.out, configuration);
             } else {
@@ -164,12 +180,21 @@ public class Report {
                             .withArgName("expression")
                             .withLongOpt("exclude")
                             .hasArgs()
-                            .withDescription("Excludes files matching <expression>.
" +
+                            .withDescription("Excludes files matching wildcard <expression>.
" +
                                     "Note that --dir is required when using this parameter.
" +
                                     "Allows multiple arguments.")
                             .create(EXCLUDE_CLI);
         opts.addOption(exclude);
 
+        final Option excludeFile = OptionBuilder
+                            .withArgName("fileName")
+                            .withLongOpt("exclude-file")
+                            .hasArgs()
+                            .withDescription("Excludes files matching regular expression
in <file> " +
+                                    "Note that --dir is required when using this parameter.
" )
+                            .create(EXCLUDE_FILE_CLI);
+        opts.addOption(excludeFile);
+
         Option dir = new Option(
                 "d",
                 "dir",

Modified: incubator/rat/main/trunk/apache-rat/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/incubator/rat/main/trunk/apache-rat/src/site/apt/index.apt?rev=1188628&r1=1188627&r2=1188628&view=diff
==============================================================================
--- incubator/rat/main/trunk/apache-rat/src/site/apt/index.apt (original)
+++ incubator/rat/main/trunk/apache-rat/src/site/apt/index.apt Tue Oct 25 12:28:11 2011
@@ -56,3 +56,16 @@ java -jar apache-rat-VERSION.jar --addLi
  source files. If you prefer to see which files will be
  changed and how then remove the "--force" option.
 
+* Using multiple excludes from a file
+
+It is common to use the RAT with the maven or ant plugins and specify
+a series of files to exclude (such as a README or version control
+files).  If you are using the RAT application instead of a plugin you
+can specify a series of regex excludes in a file and specify that with
+the -E option.
+
++------------------------------------------+
+java -jar apache-rat-VERSION.jar -E
+ -E /path/to/project/.rat-excludes
+ -d /path/to/project
++------------------------------------------+



Mime
View raw message