You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@creadur.apache.org by po...@apache.org on 2015/05/15 23:19:16 UTC

svn commit: r1679649 - in /creadur/rat/trunk: ./ apache-rat-core/ apache-rat-core/src/main/java/org/apache/rat/ apache-rat-core/src/main/java/org/apache/rat/config/ apache-rat-core/src/main/java/org/apache/rat/document/ apache-rat-core/src/main/java/or...

Author: pottlinger
Date: Fri May 15 21:19:15 2015
New Revision: 1679649

URL: http://svn.apache.org/r1679649
Log:
AT-179: Maven plugin is able to merge approved licenses with adhoc defined ones

* Maven DefaultPolicy was not able merge with default approved licenses but 
  either took all licenses given or the defaults.
* Since maven default is that addDefaultLicenses is enabled, ReportConfiguration
  enables defaults and merges with any given extra licenses.
* Ant task and CLI merges by default as well.  
* Upgraded to latest - mockito 1.10.19
* Extracted AddLicenseHeader configuration options into an enum (similar to ant).
* Resources: Unit tests cannot be run from within IntelliJ since they do not 
  find test resources properly. Added comment and extracted resource directory.
* Defaults: Added default license family names to match default matchers:
** OLD:
 MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_APACHE_LICENSE_VERSION_2_0,
        MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_OASIS_OPEN_LICENSE,
        MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_W3C_SOFTWARE_COPYRIGHT,
        MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_W3C_DOCUMENT_COPYRIGHT,
        MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_MODIFIED_BSD_LICENSE,
        MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_MIT,
        MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_CDDL1,
** NEW:        
MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_ACADEMIC_FREE_LICENSE_VERSION_2_1, //
                    MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_APACHE_LICENSE_VERSION_2_0, //
                    MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_CDDL1, //
                    MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_GPL_VERSION_1, //
                    MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_GPL_VERSION_2, //
                    MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_GPL_VERSION_3, //
                    MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_MIT, //
                    MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_MODIFIED_BSD_LICENSE, //
                    MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_OASIS_OPEN_LICENSE, //
                    MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_W3C_DOCUMENT_COPYRIGHT, //
                    MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_W3C_SOFTWARE_COPYRIGHT


Added:
    creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/config/AddLicenseHeaders.java
    creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/config/ConfigurationUtil.java
    creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/config/ConfigurationUtilTest.java
    creadur/rat/trunk/apache-rat-plugin/src/it/it5_RAT-179/
    creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/util/ConfigurationHelper.java
Modified:
    creadur/rat/trunk/RELEASE_NOTES.txt
    creadur/rat/trunk/apache-rat-core/pom.xml
    creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/Defaults.java
    creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/Report.java
    creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/ReportConfiguration.java
    creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/document/IDocumentAnalyser.java
    creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/license/ILicenseFamily.java
    creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/policy/DefaultPolicy.java
    creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/report/xml/XmlReportFactory.java
    creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/ReportTest.java
    creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/policy/DefaultPolicyTest.java
    creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/test/utils/Resources.java
    creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/AbstractRatMojo.java
    creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/RatCheckMojo.java
    creadur/rat/trunk/apache-rat-plugin/src/test/java/org/apache/rat/mp/RatCheckMojoTest.java
    creadur/rat/trunk/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Report.java
    creadur/rat/trunk/pom.xml

Modified: creadur/rat/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/creadur/rat/trunk/RELEASE_NOTES.txt?rev=1679649&r1=1679648&r2=1679649&view=diff
==============================================================================
--- creadur/rat/trunk/RELEASE_NOTES.txt (original)
+++ creadur/rat/trunk/RELEASE_NOTES.txt Fri May 15 21:19:15 2015
@@ -20,6 +20,7 @@ Rat 0.12 (SNAPSHOT)
     * [RAT-160] - Ignore build.log that is created by maven-invoker-plugin runs. Temporary fix until invoker plugin improves
                   configurability of that file. 
                   (thanks to Christopher Tubbs)
+    * [RAT-179] - Maven plugin and Ant task do not support adding extra approved licenses.
 
    New features
     * [RAT-171] - Maven plugin allows scanning of source code management ignore files. Their contents is added as exclusion to be ignored during RAT runs.

Modified: creadur/rat/trunk/apache-rat-core/pom.xml
URL: http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-core/pom.xml?rev=1679649&r1=1679648&r2=1679649&view=diff
==============================================================================
--- creadur/rat/trunk/apache-rat-core/pom.xml (original)
+++ creadur/rat/trunk/apache-rat-core/pom.xml Fri May 15 21:19:15 2015
@@ -104,7 +104,9 @@
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
+      <scope>test</scope>
     </dependency>
+
     <dependency>
       <groupId>commons-cli</groupId>
       <artifactId>commons-cli</artifactId>

Modified: creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/Defaults.java
URL: http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/Defaults.java?rev=1679649&r1=1679648&r2=1679649&view=diff
==============================================================================
--- creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/Defaults.java (original)
+++ creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/Defaults.java Fri May 15 21:19:15 2015
@@ -15,7 +15,7 @@
  * KIND, either express or implied.  See the License for the    *
  * specific language governing permissions and limitations      *
  * under the License.                                           *
- */ 
+ */
 package org.apache.rat;
 
 import org.apache.rat.analysis.IHeaderMatcher;
@@ -33,6 +33,7 @@ import org.apache.rat.analysis.license.T
 import org.apache.rat.analysis.license.W3CDocLicense;
 import org.apache.rat.analysis.license.W3CLicense;
 import org.apache.rat.analysis.util.HeaderMatcherMultiplexer;
+import org.apache.rat.api.MetaData;
 
 import java.io.InputStream;
 import java.util.Arrays;
@@ -40,16 +41,19 @@ import java.util.Collections;
 import java.util.List;
 
 
-
 /**
  * Utility class that holds constants shared by the CLI tool and the Ant tasks.
  */
 public class Defaults {
-    /** no instances */
-    private Defaults() {}
+    /**
+     * no instances
+     */
+    private Defaults() {
+    }
 
     /**
      * The standard list of licenses to include in the reports.
+     * Needs to match configuration in {@link org.apache.rat.policy.DefaultPolicy}.
      */
     public static final List<IHeaderMatcher> DEFAULT_MATCHERS = Collections.unmodifiableList(
             Arrays.asList(new ApacheSoftwareLicense20(),
@@ -60,12 +64,29 @@ public class Defaults {
                     new W3CLicense(),
                     new W3CDocLicense(),
                     new OASISLicense(),
-                    new JavaDocLicenseNotRequired(),
-                    new GeneratedLicenseNotRequired(),
+                    new JavaDocLicenseNotRequired(), // does not have a MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_... entry
+                    new GeneratedLicenseNotRequired(), // does not have a MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_... entry
                     new DojoLicenseHeader(),
                     new TMF854LicenseHeader(),
                     new CDDL1License()));
-    
+
+    // all classes in license package implementing ILicenseFamily
+    public static final List<String> DEFAULT_LICENSE_FAMILIES = Collections.unmodifiableList(
+            Arrays.asList(
+                    MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_ACADEMIC_FREE_LICENSE_VERSION_2_1, //
+                    MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_APACHE_LICENSE_VERSION_2_0, //
+                    MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_CDDL1, //
+                    MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_GPL_VERSION_1, //
+                    MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_GPL_VERSION_2, //
+                    MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_GPL_VERSION_3, //
+                    MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_MIT, //
+                    MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_MODIFIED_BSD_LICENSE, //
+                    MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_OASIS_OPEN_LICENSE, //
+                    MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_W3C_DOCUMENT_COPYRIGHT, //
+                    MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_W3C_SOFTWARE_COPYRIGHT
+                    //
+            ));
+
     public static final String PLAIN_STYLESHEET = "org/apache/rat/plain-rat.xsl";
     public static final String UNAPPROVED_LICENSES_STYLESHEET = "org/apache/rat/unapproved-licenses.xsl";
 
@@ -73,7 +94,7 @@ public class Defaults {
         InputStream result = Defaults.class.getClassLoader().getResourceAsStream(Defaults.PLAIN_STYLESHEET);
         return result;
     }
-    
+
     public static InputStream getUnapprovedLicensesStyleSheet() {
         InputStream result = Defaults.class.getClassLoader().getResourceAsStream(Defaults.UNAPPROVED_LICENSES_STYLESHEET);
         return result;
@@ -83,7 +104,7 @@ public class Defaults {
         InputStream result = getPlainStyleSheet();
         return result;
     }
-    
+
     public static IHeaderMatcher createDefaultMatcher() {
         return new HeaderMatcherMultiplexer(Defaults.DEFAULT_MATCHERS);
     }

Modified: creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/Report.java
URL: http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/Report.java?rev=1679649&r1=1679648&r2=1679649&view=diff
==============================================================================
--- creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/Report.java (original)
+++ creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/Report.java Fri May 15 21:19:15 2015
@@ -55,6 +55,7 @@ public class Report {
     public static final void main(String args[]) throws Exception {
         final ReportConfiguration configuration = new ReportConfiguration();
         configuration.setHeaderMatcher(Defaults.createDefaultMatcher());
+        configuration.setApproveDefaultLicenses(true);
         Options opts = buildOptions();
 
         PosixParser parser = new PosixParser();
@@ -269,6 +270,7 @@ public class Report {
     public ClaimStatistic report(PrintStream out) throws Exception {
         final ReportConfiguration configuration = new ReportConfiguration();
         configuration.setHeaderMatcher(Defaults.createDefaultMatcher());
+        configuration.setApproveDefaultLicenses(true);
         return report(out, configuration);
     }
 
@@ -325,6 +327,7 @@ public class Report {
     public void styleReport(PrintStream out) throws Exception {
         final ReportConfiguration configuration = new ReportConfiguration();
         configuration.setHeaderMatcher(Defaults.createDefaultMatcher());
+        configuration.setApproveDefaultLicenses(true);
         styleReport(out, configuration);
     }
 

Modified: creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/ReportConfiguration.java
URL: http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/ReportConfiguration.java?rev=1679649&r1=1679648&r2=1679649&view=diff
==============================================================================
--- creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/ReportConfiguration.java (original)
+++ creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/ReportConfiguration.java Fri May 15 21:19:15 2015
@@ -15,12 +15,14 @@
  * KIND, either express or implied.  See the License for the    *
  * specific language governing permissions and limitations      *
  * under the License.                                           *
- */ 
+ */
 package org.apache.rat;
 
 import org.apache.rat.analysis.IHeaderMatcher;
 import org.apache.rat.license.ILicenseFamily;
 
+import java.util.List;
+
 
 /**
  * A configuration object is used by the frontend to invoke the
@@ -33,9 +35,22 @@ public class ReportConfiguration {
     private boolean addingLicenses;
     private boolean addingLicensesForced;
     private String copyrightMessage;
+    private boolean approveDefaultLicenses = true;
+
+    /**
+     * @return whether default licenses shall be approved by default.
+     */
+    public boolean isApproveDefaultLicenses() {
+        return approveDefaultLicenses;
+    }
+
+    public void setApproveDefaultLicenses(boolean approveDefaultLicenses) {
+        this.approveDefaultLicenses = approveDefaultLicenses;
+    }
 
     /**
      * Returns the header matcher.
+     *
      * @return the header matcher.
      */
     public IHeaderMatcher getHeaderMatcher() {
@@ -44,6 +59,7 @@ public class ReportConfiguration {
 
     /**
      * Sets the header matcher.
+     *
      * @param headerMatcher header matcher.
      */
     public void setHeaderMatcher(IHeaderMatcher headerMatcher) {
@@ -52,6 +68,7 @@ public class ReportConfiguration {
 
     /**
      * Returns the set of approved license names.
+     *
      * @return the set of approved license names.
      */
     public ILicenseFamily[] getApprovedLicenseNames() {
@@ -60,6 +77,7 @@ public class ReportConfiguration {
 
     /**
      * Sets the set of approved license names.
+     *
      * @param approvedLicenseNames set of approved license names.
      */
     public void setApprovedLicenseNames(ILicenseFamily[] approvedLicenseNames) {
@@ -67,6 +85,17 @@ public class ReportConfiguration {
     }
 
     /**
+     * Sets the set of approved license names (convenience).
+     *
+     * @param approvedLicenseNames set of approved license names.
+     */
+    public void setApprovedLicenseNames(List<ILicenseFamily> approvedLicenseNames) {
+        if (approvedLicenseNames != null && approvedLicenseNames.size() > 0) {
+            setApprovedLicenseNames(approvedLicenseNames.toArray(new ILicenseFamily[approvedLicenseNames.size()]));
+        }
+    }
+
+    /**
      * @return If Rat is adding license headers: Returns the optional
      * copyright message. This value is ignored, if no
      * license headers are added.
@@ -80,8 +109,9 @@ public class ReportConfiguration {
      * If Rat is adding license headers: Sets the optional
      * copyright message. This value is ignored, if no
      * license headers are added.
-     * @see #setAddingLicenses(boolean)
+     *
      * @param copyrightMessage message to set.
+     * @see #setAddingLicenses(boolean)
      */
     public void setCopyrightMessage(String copyrightMessage) {
         this.copyrightMessage = copyrightMessage;
@@ -101,8 +131,9 @@ public class ReportConfiguration {
      * If Rat is adding license headers: Sets, whether adding
      * license headers is enforced. This value is ignored, if no
      * license headers are added.
-     * @see #isAddingLicenses()
+     *
      * @param addingLicensesForced enable/disable forcibly adding licenses.
+     * @see #isAddingLicenses()
      */
     public void setAddingLicensesForced(boolean addingLicensesForced) {
         this.addingLicensesForced = addingLicensesForced;
@@ -119,12 +150,13 @@ public class ReportConfiguration {
 
     /**
      * Returns, whether Rat should add missing license headers.
+     *
+     * @param addingLicenses enables/disables adding of licenses.
      * @see #setAddingLicensesForced(boolean)
      * @see #setCopyrightMessage(String)
-     * @param addingLicenses enabled/disables adding of licenses.
      */
     public void setAddingLicenses(boolean addingLicenses) {
         this.addingLicenses = addingLicenses;
     }
-    
+
 }

Added: creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/config/AddLicenseHeaders.java
URL: http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/config/AddLicenseHeaders.java?rev=1679649&view=auto
==============================================================================
--- creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/config/AddLicenseHeaders.java (added)
+++ creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/config/AddLicenseHeaders.java Fri May 15 21:19:15 2015
@@ -0,0 +1,32 @@
+package org.apache.rat.config;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * Value of addLicenseHeaders configuration option.
+ *
+ * @author pottlinger
+ * @version 2015-05-11
+ */
+public enum AddLicenseHeaders {
+    TRUE, //
+    FALSE, //
+    FORCED
+}

Added: creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/config/ConfigurationUtil.java
URL: http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/config/ConfigurationUtil.java?rev=1679649&view=auto
==============================================================================
--- creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/config/ConfigurationUtil.java (added)
+++ creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/config/ConfigurationUtil.java Fri May 15 21:19:15 2015
@@ -0,0 +1,44 @@
+package org.apache.rat.config;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.rat.license.ILicenseFamily;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ConfigurationUtil {
+    /**
+     * Extract license names from the given license families.
+     *
+     * @param approvedLicenses list of license family implementations.
+     * @return extracted names of given license families.
+     */
+    public static final List<String> toNames(final ILicenseFamily[] approvedLicenses) {
+        List<String> names = new ArrayList<String>();
+        if (approvedLicenses != null && approvedLicenses.length > 0) {
+            for (ILicenseFamily approvedFamily : approvedLicenses) {
+                names.add(approvedFamily.getFamilyName());
+            }
+        }
+        return names;
+    }
+
+}

Modified: creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/document/IDocumentAnalyser.java
URL: http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/document/IDocumentAnalyser.java?rev=1679649&r1=1679648&r2=1679649&view=diff
==============================================================================
--- creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/document/IDocumentAnalyser.java (original)
+++ creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/document/IDocumentAnalyser.java Fri May 15 21:19:15 2015
@@ -23,5 +23,5 @@ import org.apache.rat.api.Document;
 
 public interface IDocumentAnalyser {
 
-    public void analyse(Document document) throws RatDocumentAnalysisException;
+    void analyse(Document document) throws RatDocumentAnalysisException;
 }

Modified: creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/license/ILicenseFamily.java
URL: http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/license/ILicenseFamily.java?rev=1679649&r1=1679648&r2=1679649&view=diff
==============================================================================
--- creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/license/ILicenseFamily.java (original)
+++ creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/license/ILicenseFamily.java Fri May 15 21:19:15 2015
@@ -20,5 +20,5 @@ package org.apache.rat.license;
 
 
 public interface ILicenseFamily {
-    public String getFamilyName();
+    String getFamilyName();
 }

Modified: creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/policy/DefaultPolicy.java
URL: http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/policy/DefaultPolicy.java?rev=1679649&r1=1679648&r2=1679649&view=diff
==============================================================================
--- creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/policy/DefaultPolicy.java (original)
+++ creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/policy/DefaultPolicy.java Fri May 15 21:19:15 2015
@@ -15,79 +15,73 @@
  * KIND, either express or implied.  See the License for the    *
  * specific language governing permissions and limitations      *
  * under the License.                                           *
- */ 
+ */
 package org.apache.rat.policy;
 
+import org.apache.rat.Defaults;
 import org.apache.rat.api.Document;
 import org.apache.rat.api.MetaData;
-import org.apache.rat.api.MetaData.Datum;
+import org.apache.rat.config.ConfigurationUtil;
 import org.apache.rat.document.IDocumentAnalyser;
 import org.apache.rat.document.RatDocumentAnalysisException;
 import org.apache.rat.license.ILicenseFamily;
 
-import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
 
 public class DefaultPolicy implements IDocumentAnalyser {
-    private static final String[] APPROVED_LICENSES = {
-        MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_APACHE_LICENSE_VERSION_2_0,
-        MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_OASIS_OPEN_LICENSE,
-        MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_W3C_SOFTWARE_COPYRIGHT,
-        MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_W3C_DOCUMENT_COPYRIGHT,
-        MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_MODIFIED_BSD_LICENSE,
-        MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_MIT,
-        MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_CDDL1,
-    };
-    
-    private static final String[] toNames(final ILicenseFamily[] approvedLicenses) {
-        String[] results = null;
-        if (approvedLicenses != null) {
-            final int length = approvedLicenses.length;
-            results = new String[length];
-            for (int i=0;i<length;i++) {
-                results[i] = approvedLicenses[i].getFamilyName();
-            }
-        }
-        return results;
-    }
+    private List<String> approvedLicenseNames;
 
-    private final String[] approvedLicenseNames;
-    
-    public DefaultPolicy() {
-        this(APPROVED_LICENSES);
-    }
-    
-    public DefaultPolicy(final ILicenseFamily[] approvedLicenses) {
-        this(toNames(approvedLicenses));
+    /**
+     * Creates a policy that matches the default licenses.
+     * Mainly used for testing purposes.
+     */
+    DefaultPolicy() {
+        this(new ArrayList<String>(0), true);
     }
 
-    public DefaultPolicy(final String[] approvedLicenseNames) {
-        if (approvedLicenseNames == null) {
-            this.approvedLicenseNames = APPROVED_LICENSES;
-        } else {
-            final int length = approvedLicenseNames.length;
-            this.approvedLicenseNames = new String[length];
-            System.arraycopy(approvedLicenseNames, 0, this.approvedLicenseNames, 0, length);
-        }
-        Arrays.sort(this.approvedLicenseNames);
+    public DefaultPolicy(final ILicenseFamily[] approvedLicenses, boolean mergeWithDefault) {
+        this(ConfigurationUtil.toNames(approvedLicenses), mergeWithDefault);
     }
 
-    public void reportLicenseApprovalClaim(final Document subject, final boolean isAcceptable) {
-        final Datum datum;
-        if (isAcceptable) {
-            datum = MetaData.RAT_APPROVED_LICENSE_DATIM_TRUE;
+    public DefaultPolicy(final List<String> approvedLicenseNames, boolean mergeWithDefault) {
+        this.approvedLicenseNames = new ArrayList<String>();
+
+        if (approvedLicenseNames == null || approvedLicenseNames.isEmpty()) {
+            // used in tests only, no additional licenses given but defaults requested
+            if(mergeWithDefault) {
+                this.approvedLicenseNames = new ArrayList<String>(Defaults.DEFAULT_LICENSE_FAMILIES);
+            }
         } else {
-            datum = MetaData.RAT_APPROVED_LICENSE_DATIM_FALSE;
+            // avoid duplicate entries and merge with defaults if requested
+            Set<String> mergedLicenses = new HashSet<String>(approvedLicenseNames);
+            if(mergeWithDefault) {
+                mergedLicenses.addAll(Defaults.DEFAULT_LICENSE_FAMILIES);
+            }
+            this.approvedLicenseNames = new ArrayList<String>(mergedLicenses);
         }
-        subject.getMetaData().set(datum);
+        Collections.sort(this.approvedLicenseNames);
     }
-    
+
     public void analyse(final Document subject) throws RatDocumentAnalysisException {
         if (subject != null) {
             final String name = subject.getMetaData().value(MetaData.RAT_URL_LICENSE_FAMILY_NAME);
             if (name != null) {
-                final boolean isApproved = Arrays.binarySearch(approvedLicenseNames, name) >= 0;
+                final boolean isApproved = (Collections.binarySearch(approvedLicenseNames, name) >= 0);
                 reportLicenseApprovalClaim(subject, isApproved);
             }
         }
     }
+
+    public void reportLicenseApprovalClaim(final Document subject, final boolean isAcceptable) {
+        subject.getMetaData().set(//
+         isAcceptable ? MetaData.RAT_APPROVED_LICENSE_DATIM_TRUE: MetaData.RAT_APPROVED_LICENSE_DATIM_FALSE);
+    }
+
+    public List<String> getApprovedLicenseNames() {
+        return Collections.unmodifiableList(approvedLicenseNames);
+    }
 }

Modified: creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/report/xml/XmlReportFactory.java
URL: http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/report/xml/XmlReportFactory.java?rev=1679649&r1=1679648&r2=1679649&view=diff
==============================================================================
--- creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/report/xml/XmlReportFactory.java (original)
+++ creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/report/xml/XmlReportFactory.java Fri May 15 21:19:15 2015
@@ -18,9 +18,6 @@
  */ 
 package org.apache.rat.report.xml;
 
-import java.util.ArrayList;
-import java.util.List;
-
 import org.apache.rat.ReportConfiguration;
 import org.apache.rat.analysis.DefaultAnalyserFactory;
 import org.apache.rat.document.IDocumentAnalyser;
@@ -34,6 +31,9 @@ import org.apache.rat.report.claim.util.
 import org.apache.rat.report.claim.util.LicenseAddingReport;
 import org.apache.rat.report.xml.writer.IXmlWriter;
 
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * Creates reports.
  *
@@ -49,9 +49,11 @@ public class XmlReportFactory {
             reporters.add(new LicenseAddingReport(pConfiguration.getCopyrightMessage(), pConfiguration.isAddingLicensesForced()));
         }
         reporters.add(new SimpleXmlClaimReporter(writer));
-        final IDocumentAnalyser analyser = 
+
+        final IDocumentAnalyser analyser =
             DefaultAnalyserFactory.createDefaultAnalyser(pConfiguration.getHeaderMatcher());
-        final DefaultPolicy policy = new DefaultPolicy(pConfiguration.getApprovedLicenseNames());
+        final DefaultPolicy policy = new DefaultPolicy(pConfiguration.getApprovedLicenseNames(), pConfiguration.isApproveDefaultLicenses());
+
         final IDocumentAnalyser[] analysers = {analyser, policy};
         DocumentAnalyserMultiplexer analysisMultiplexer = new DocumentAnalyserMultiplexer(analysers);
         return new ClaimReporterMultiplexer(analysisMultiplexer, reporters);

Modified: creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/ReportTest.java
URL: http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/ReportTest.java?rev=1679649&r1=1679648&r2=1679649&view=diff
==============================================================================
--- creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/ReportTest.java (original)
+++ creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/ReportTest.java Fri May 15 21:19:15 2015
@@ -110,9 +110,11 @@ public class ReportTest {
         HeaderMatcherMultiplexer matcherMultiplexer = new HeaderMatcherMultiplexer(Defaults.DEFAULT_MATCHERS);
         final String elementsPath = Resources.getResourceDirectory("elements/Source.java");
         final ReportConfiguration configuration = new ReportConfiguration();
+        configuration.setApproveDefaultLicenses(true);
         configuration.setHeaderMatcher(matcherMultiplexer);
         Report.report(out, new DirectoryWalker(new File(elementsPath)),
                 Defaults.getPlainStyleSheet(), configuration);
+
         String result = out.getBuffer().toString();
         final String nl = System.getProperty("line.separator");
         assertTrue("'Generated at' is present in " + result,

Added: creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/config/ConfigurationUtilTest.java
URL: http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/config/ConfigurationUtilTest.java?rev=1679649&view=auto
==============================================================================
--- creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/config/ConfigurationUtilTest.java (added)
+++ creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/config/ConfigurationUtilTest.java Fri May 15 21:19:15 2015
@@ -0,0 +1,44 @@
+package org.apache.rat.config;
+
+import org.apache.rat.api.MetaData;
+import org.apache.rat.license.GPL1LicenseFamily;
+import org.apache.rat.license.ILicenseFamily;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+public class ConfigurationUtilTest {
+    @Test
+    public void toNamesIsNullSafe() {
+        assertTrue(ConfigurationUtil.toNames(null).isEmpty());
+    }
+
+    @Test
+    public void toNamesIsEmptyArraySafe() {
+        assertTrue(ConfigurationUtil.toNames(new ILicenseFamily[0]).isEmpty());
+    }
+    @Test
+    public void toNamesRegular() {
+        assertEquals(MetaData.RAT_LICENSE_FAMILY_NAME_VALUE_GPL_VERSION_1, ConfigurationUtil.toNames(new ILicenseFamily[]{new GPL1LicenseFamily()}).get(0));
+    }
+}

Modified: creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/policy/DefaultPolicyTest.java
URL: http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/policy/DefaultPolicyTest.java?rev=1679649&r1=1679648&r2=1679649&view=diff
==============================================================================
--- creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/policy/DefaultPolicyTest.java (original)
+++ creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/policy/DefaultPolicyTest.java Fri May 15 21:19:15 2015
@@ -15,24 +15,35 @@
  * KIND, either express or implied.  See the License for the    *
  * specific language governing permissions and limitations      *
  * under the License.                                           *
- */ 
+ */
 package org.apache.rat.policy;
 
+import org.apache.rat.Defaults;
 import org.apache.rat.api.Document;
 import org.apache.rat.api.MetaData;
 import org.apache.rat.document.MockLocation;
+import org.apache.rat.license.ILicenseFamily;
 import org.apache.rat.report.claim.impl.xml.MockClaimReporter;
 import org.junit.Before;
 import org.junit.Test;
 
+import java.util.ArrayList;
+
 import static org.junit.Assert.assertEquals;
 
 
 public class DefaultPolicyTest {
+    private static final int NUMBER_OF_DEFAULT_ACCEPTED_LICENSES = Defaults.DEFAULT_LICENSE_FAMILIES.size();
+
+    private static final ILicenseFamily JUST_A_TEST_LIC_FAMILY = new ILicenseFamily() {
+        public String getFamilyName() {
+            return "justATest";
+        }
+    };
 
-    MockClaimReporter reporter;
-    DefaultPolicy policy;
+    private MockClaimReporter reporter;
     private Document subject;
+    private DefaultPolicy policy;
 
     @Before
     public void setUp() throws Exception {
@@ -41,43 +52,104 @@ public class DefaultPolicyTest {
         subject = new MockLocation("subject");
     }
 
+    @SuppressWarnings("boxing") // OK in test code
+    private void assertApproval(boolean pApproved) {
+        assertEquals(pApproved, MetaData.RAT_APPROVED_LICENSE_VALUE_TRUE.equals(subject.getMetaData().value(MetaData.RAT_URL_APPROVED_LICENSE)));
+    }
+
     @Test
     public void testALFamily() throws Exception {
+        assertEquals(NUMBER_OF_DEFAULT_ACCEPTED_LICENSES, policy.getApprovedLicenseNames().size());
         subject.getMetaData().set(MetaData.RAT_LICENSE_FAMILY_NAME_DATUM_APACHE_LICENSE_VERSION_2_0);
         policy.analyse(subject);
         assertApproval(true);
     }
 
-    @SuppressWarnings("boxing") // OK in test code
-    private void assertApproval(boolean pApproved) {
-        assertEquals(pApproved, MetaData.RAT_APPROVED_LICENSE_VALUE_TRUE.equals(subject.getMetaData().value(MetaData.RAT_URL_APPROVED_LICENSE)));
-    }
-
     @Test
     public void testOASISFamily() throws Exception {
+        assertEquals(NUMBER_OF_DEFAULT_ACCEPTED_LICENSES, policy.getApprovedLicenseNames().size());
         subject.getMetaData().set(MetaData.RAT_LICENSE_FAMILY_NAME_DATUM_OASIS_OPEN_LICENSE);
         policy.analyse(subject);
         assertApproval(true);
     }
-    
+
     @Test
     public void testW3CFamily() throws Exception {
+        assertEquals(NUMBER_OF_DEFAULT_ACCEPTED_LICENSES, policy.getApprovedLicenseNames().size());
         subject.getMetaData().set(MetaData.RAT_LICENSE_FAMILY_NAME_DATUM_W3C_SOFTWARE_COPYRIGHT);
         policy.analyse(subject);
         assertApproval(true);
     }
-    
+
     @Test
     public void testW3CDocFamily() throws Exception {
+        assertEquals(NUMBER_OF_DEFAULT_ACCEPTED_LICENSES, policy.getApprovedLicenseNames().size());
         subject.getMetaData().set(MetaData.RAT_LICENSE_FAMILY_NAME_DATUM_W3C_DOCUMENT_COPYRIGHT);
         policy.analyse(subject);
         assertApproval(true);
     }
-    
+
+    @Test
+    public void testModifiedBSDFamily() throws Exception {
+        assertEquals(NUMBER_OF_DEFAULT_ACCEPTED_LICENSES, policy.getApprovedLicenseNames().size());
+        subject.getMetaData().set(MetaData.RAT_LICENSE_FAMILY_NAME_DATUM_MODIFIED_BSD_LICENSE);
+        policy.analyse(subject);
+        assertApproval(true);
+    }
+
+    @Test
+    public void testMITFamily() throws Exception {
+        assertEquals(NUMBER_OF_DEFAULT_ACCEPTED_LICENSES, policy.getApprovedLicenseNames().size());
+        subject.getMetaData().set(MetaData.RAT_LICENSE_FAMILY_NAME_DATUM_MIT);
+        policy.analyse(subject);
+        assertApproval(true);
+    }
+
+    @Test
+    public void testCDDL1Family() throws Exception {
+        assertEquals(NUMBER_OF_DEFAULT_ACCEPTED_LICENSES, policy.getApprovedLicenseNames().size());
+        subject.getMetaData().set(MetaData.RAT_LICENSE_FAMILY_NAME_DATUM_CDDL1);
+        policy.analyse(subject);
+        assertApproval(true);
+    }
+
     @Test
     public void testUnknownFamily() throws Exception {
+        assertEquals(NUMBER_OF_DEFAULT_ACCEPTED_LICENSES, policy.getApprovedLicenseNames().size());
         subject.getMetaData().set(MetaData.RAT_LICENSE_FAMILY_NAME_DATUM_UNKNOWN);
         policy.analyse(subject);
         assertApproval(false);
     }
+
+    @Test
+    public void testNullAsMarkerOfDefaults() {
+        // with defaults
+        for (DefaultPolicy policy : new DefaultPolicy[]{//
+                new DefaultPolicy(), //
+                new DefaultPolicy(new ArrayList<String>(0), true),//
+                new DefaultPolicy(new ILicenseFamily[]{}, true),
+        }) {
+            assertEquals("Did you add new license defaults?", NUMBER_OF_DEFAULT_ACCEPTED_LICENSES, policy.getApprovedLicenseNames().size());
+        }
+
+        // without defaults and no additions == 0
+        for (DefaultPolicy policy : new DefaultPolicy[]{//
+                new DefaultPolicy(new ArrayList<String>(0), false),//
+                new DefaultPolicy(new ILicenseFamily[]{}, false),
+        }) {
+            assertEquals(0, policy.getApprovedLicenseNames().size());
+        }
+    }
+
+    @Test
+    public void testAddNewApprovedLicenseAndDefaults() {
+        assertEquals("justATest", new DefaultPolicy(new ILicenseFamily[]{JUST_A_TEST_LIC_FAMILY}, false).getApprovedLicenseNames().get(0));
+        assertEquals("Did not properly merge approved licenses with default", 1, new DefaultPolicy(new ILicenseFamily[]{JUST_A_TEST_LIC_FAMILY}, false).getApprovedLicenseNames().size());
+    }
+
+    @Test
+    public void testAddNewApprovedLicenseNoDefaults() {
+        assertEquals("justATest", new DefaultPolicy(new ILicenseFamily[]{JUST_A_TEST_LIC_FAMILY}, false).getApprovedLicenseNames().get(0));
+        assertEquals("Did not properly merge approved licenses with default", NUMBER_OF_DEFAULT_ACCEPTED_LICENSES + 1, new DefaultPolicy(new ILicenseFamily[]{JUST_A_TEST_LIC_FAMILY}, true).getApprovedLicenseNames().size());
+    }
 }

Modified: creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/test/utils/Resources.java
URL: http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/test/utils/Resources.java?rev=1679649&r1=1679648&r2=1679649&view=diff
==============================================================================
--- creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/test/utils/Resources.java (original)
+++ creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/test/utils/Resources.java Fri May 15 21:19:15 2015
@@ -15,9 +15,11 @@
  * KIND, either express or implied.  See the License for the    *
  * specific language governing permissions and limitations      *
  * under the License.                                           *
- */ 
+ */
 package org.apache.rat.test.utils;
 
+import org.apache.rat.document.impl.DocumentImplUtils;
+
 import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileFilter;
@@ -28,8 +30,6 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.Reader;
 
-import org.apache.rat.document.impl.DocumentImplUtils;
-
 
 /**
  * Utility class, which provides static methods for creating
@@ -43,11 +43,14 @@ public class Resources {
         // Does nothing
     }
 
+    // Does not work from within IntelliJ since root path is not module, but apache-rat-trunk
+    private static File RESOURCE_BASE_PATH = new File("src/test/resources");
+
     /**
      * Locates a resource file in the class path.
      */
     public static File getResourceFile(String pResource) throws IOException {
-        final File f = new File("src/test/resources", pResource);
+        final File f = new File(RESOURCE_BASE_PATH, pResource);
         if (!f.isFile()) {
             throw new FileNotFoundException("Unable to locate resource file: " + pResource);
         }
@@ -58,14 +61,15 @@ public class Resources {
      * Locates a set of resource files in the class path.
      */
     public static File[] getResourceFiles(String pResource) throws IOException {
-        final File f = new File("src/test/resources", pResource);
+        final File f = new File(RESOURCE_BASE_PATH, pResource);
         if (!f.isDirectory()) {
             throw new FileNotFoundException("Unable to locate resource directory: " + f);
         }
-        return f.listFiles(new FileFilter(){
+        return f.listFiles(new FileFilter() {
             public boolean accept(File pathname) {
                 return pathname.isFile();
-            }});
+            }
+        });
     }
 
     /**

Modified: creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/AbstractRatMojo.java
URL: http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/AbstractRatMojo.java?rev=1679649&r1=1679648&r2=1679649&view=diff
==============================================================================
--- creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/AbstractRatMojo.java (original)
+++ creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/AbstractRatMojo.java Fri May 15 21:19:15 2015
@@ -53,6 +53,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
+import static org.apache.rat.mp.util.ConfigurationHelper.newInstance;
 import static org.apache.rat.mp.util.ExclusionHelper.addEclipseDefaults;
 import static org.apache.rat.mp.util.ExclusionHelper.addIdeaDefaults;
 import static org.apache.rat.mp.util.ExclusionHelper.addMavenDefaults;
@@ -214,68 +215,38 @@ public abstract class AbstractRatMojo ex
      * @throws MojoFailureException   An error in the plugin configuration was detected.
      * @throws MojoExecutionException An error occurred while calculating the result.
      */
-    protected List<IHeaderMatcher> getLicenseMatchers()
+    private List<IHeaderMatcher> mergeLicenseMatchers()
             throws MojoFailureException, MojoExecutionException {
-        final List<IHeaderMatcher> matchers = new ArrayList<IHeaderMatcher>();
+        List<IHeaderMatcher> matchers = new ArrayList<IHeaderMatcher>();
+
         if (licenses != null) {
             matchers.addAll(Arrays.asList(licenses));
+            getLog().info("Added " + licenses.length + " additional default licenses.");
         }
 
         if (licenseMatchers != null) {
             for (final HeaderMatcherSpecification spec : licenseMatchers) {
-                final String className = spec.getClassName();
-                final IHeaderMatcher headerMatcher = newInstance(
-                        IHeaderMatcher.class, className);
-                matchers.add(headerMatcher);
+                matchers.add(newInstance(IHeaderMatcher.class, spec.getClassName()));
             }
         }
 
         if (addDefaultLicenseMatchers) {
+            getLog().info("Enabled default license matchers.");
             matchers.addAll(Defaults.DEFAULT_MATCHERS);
         }
+        logLicenseMatchers(matchers);
+
         return matchers;
     }
 
-    private <T> T newInstance(final Class<T> clazz, final String className)
-            throws MojoExecutionException, MojoFailureException {
-        try {
-            final ClassLoader cl = Thread.currentThread()
-                    .getContextClassLoader();
-            @SuppressWarnings("unchecked") // incorrect cast will be caught below
-            final T o = (T) cl.loadClass(className).newInstance();
-
-            if (!clazz.isAssignableFrom(o.getClass())) {
-                throw new MojoFailureException("The class "
-                        + o.getClass().getName() + " does not implement "
-                        + clazz.getName());
+    private void logLicenseMatchers(List<IHeaderMatcher> matchers) {
+        if (getLog().isDebugEnabled()) {
+            getLog().debug("The following license matchers are activated:");
+            for (IHeaderMatcher matcher : matchers) {
+                getLog().debug("* " + matcher.toString());
             }
-            return o;
-        } catch (final InstantiationException e) {
-            throw new MojoExecutionException("Failed to instantiate class "
-                    + className + ": " + e.getMessage(), e);
-        } catch (final ClassCastException e) {
-            throw new MojoExecutionException("The class " + className
-                    + " is not implementing " + clazz.getName() + ": "
-                    + e.getMessage(), e);
-        } catch (final IllegalAccessException e) {
-            throw new MojoExecutionException("Illegal access to class "
-                    + className + ": " + e.getMessage(), e);
-        } catch (final ClassNotFoundException e) {
-            throw new MojoExecutionException("Class " + className
-                    + " not found: " + e.getMessage(), e);
         }
-    }
 
-    /**
-     * Adds the given string array to the list.
-     *
-     * @param pList  The list to which the array elements are being added.
-     * @param pArray The strings to add to the list.
-     */
-    private static void add(List<String> pList, String[] pArray) {
-        if (pArray != null) {
-            Collections.addAll(pList, pArray);
-        }
     }
 
     /**
@@ -336,7 +307,7 @@ public abstract class AbstractRatMojo ex
     }
 
     private void setExcludes(DirectoryScanner ds) {
-        final List<String> excludeList = buildDefaultExclusions();
+        final List<String> excludeList = mergeDefaultExclusions();
         if (excludes == null || excludes.length == 0) {
             getLog().info("No excludes explicitly specified.");
         } else {
@@ -344,7 +315,9 @@ public abstract class AbstractRatMojo ex
                 getLog().info("Exclude: " + exclude);
             }
         }
-        add(excludeList, excludes);
+        if (excludes != null) {
+            Collections.addAll(excludeList, excludes);
+        }
         if (!excludeList.isEmpty()) {
             final String[] allExcludes = excludeList.toArray(new String[excludeList
                     .size()]);
@@ -352,7 +325,7 @@ public abstract class AbstractRatMojo ex
         }
     }
 
-    private List<String> buildDefaultExclusions() {
+    private List<String> mergeDefaultExclusions() {
         final Set<String> results = new HashSet<String>();
 
         addPlexusAndScmDefaults(getLog(), useDefaultExcludes, results);
@@ -360,7 +333,7 @@ public abstract class AbstractRatMojo ex
         addEclipseDefaults(getLog(), useEclipseDefaultExcludes, results);
         addIdeaDefaults(getLog(), useIdeaDefaultExcludes, results);
 
-        if(parseSCMIgnoresAsExcludes) {
+        if (parseSCMIgnoresAsExcludes) {
             getLog().info("Will parse SCM ignores for exclusions...");
             results.addAll(ScmIgnoreParser.getExclusionsFromSCM(getLog(), project.getBasedir()));
             getLog().info("Finished adding exclusions from SCM ignore files.");
@@ -451,15 +424,18 @@ public abstract class AbstractRatMojo ex
             throws MojoFailureException, MojoExecutionException {
         final ReportConfiguration configuration = new ReportConfiguration();
         configuration.setHeaderMatcher(new HeaderMatcherMultiplexer(
-                getLicenseMatchers()));
-        configuration.setApprovedLicenseNames(getApprovedLicenseNames());
+                mergeLicenseMatchers()));
+        configuration.setApprovedLicenseNames(mergeApprovedLicenseNames());
+        configuration.setApproveDefaultLicenses(addDefaultLicenseMatchers);
         return configuration;
     }
 
-    private ILicenseFamily[] getApprovedLicenseNames()
+    private List<ILicenseFamily> mergeApprovedLicenseNames()
             throws MojoExecutionException, MojoFailureException {
         final List<ILicenseFamily> list = new ArrayList<ILicenseFamily>();
         if (licenseFamilies != null) {
+            int numberOfAddedApprovals = licenseFamilies == null ? 0 : licenseFamilies.length;
+            getLog().info("Added " + numberOfAddedApprovals + " custom approved licenses.");
             list.addAll(Arrays.asList(licenseFamilies));
         }
         if (licenseFamilyNames != null) {
@@ -467,10 +443,6 @@ public abstract class AbstractRatMojo ex
                 list.add(newInstance(ILicenseFamily.class, spec.getClassName()));
             }
         }
-
-        if (list.isEmpty()) {
-            return null;
-        }
-        return list.toArray(new ILicenseFamily[list.size()]);
+        return list;
     }
 }

Modified: creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/RatCheckMojo.java
URL: http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/RatCheckMojo.java?rev=1679649&r1=1679648&r2=1679649&view=diff
==============================================================================
--- creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/RatCheckMojo.java (original)
+++ creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/RatCheckMojo.java Fri May 15 21:19:15 2015
@@ -19,13 +19,6 @@ package org.apache.rat.mp;
  * under the License.
  */
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-
 import org.apache.commons.io.IOUtils;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
@@ -34,8 +27,16 @@ import org.apache.maven.plugins.annotati
 import org.apache.maven.plugins.annotations.Parameter;
 import org.apache.rat.Defaults;
 import org.apache.rat.ReportConfiguration;
+import org.apache.rat.config.AddLicenseHeaders;
 import org.apache.rat.report.claim.ClaimStatistic;
 
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+
 /**
  * Run Rat to perform a violation check.
  */
@@ -209,14 +210,15 @@ public class RatCheckMojo extends Abstra
     protected ReportConfiguration getConfiguration()
             throws MojoFailureException, MojoExecutionException {
         final ReportConfiguration configuration = super.getConfiguration();
-        if ("forced".equals(addLicenseHeaders)) {
+
+        if (AddLicenseHeaders.FORCED.name().equalsIgnoreCase(addLicenseHeaders)) {
             configuration.setAddingLicenses(true);
             configuration.setAddingLicensesForced(true);
             configuration.setCopyrightMessage(copyrightMessage);
-        } else if ("true".equals(addLicenseHeaders)) {
+        } else if (AddLicenseHeaders.TRUE.name().equalsIgnoreCase(addLicenseHeaders)) {
             configuration.setAddingLicenses(true);
             configuration.setCopyrightMessage(copyrightMessage);
-        } else if ("false".equals(addLicenseHeaders)) {
+        } else if (AddLicenseHeaders.FALSE.name().equalsIgnoreCase(addLicenseHeaders)) {
             // Nothing to do
         } else {
             throw new MojoFailureException("Invalid value for addLicenseHeaders: Expected forced|true|false, got "

Added: creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/util/ConfigurationHelper.java
URL: http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/util/ConfigurationHelper.java?rev=1679649&view=auto
==============================================================================
--- creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/util/ConfigurationHelper.java (added)
+++ creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/util/ConfigurationHelper.java Fri May 15 21:19:15 2015
@@ -0,0 +1,61 @@
+package org.apache.rat.mp.util;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+
+public final class ConfigurationHelper {
+
+    private ConfigurationHelper() {
+        // prevent instantiation
+    }
+
+    public static <T> T newInstance(final Class<T> clazz, final String className)
+            throws MojoExecutionException, MojoFailureException {
+        try {
+            final ClassLoader cl = Thread.currentThread()
+                    .getContextClassLoader();
+            @SuppressWarnings("unchecked") // incorrect cast will be caught below
+            final T o = (T) cl.loadClass(className).newInstance();
+
+            if (!clazz.isAssignableFrom(o.getClass())) {
+                throw new MojoFailureException("The class "
+                        + o.getClass().getName() + " does not implement "
+                        + clazz.getName());
+            }
+            return o;
+        } catch (final InstantiationException e) {
+            throw new MojoExecutionException("Failed to instantiate class "
+                    + className + ": " + e.getMessage(), e);
+        } catch (final ClassCastException e) {
+            throw new MojoExecutionException("The class " + className
+                    + " is not implementing " + clazz.getName() + ": "
+                    + e.getMessage(), e);
+        } catch (final IllegalAccessException e) {
+            throw new MojoExecutionException("Illegal access to class "
+                    + className + ": " + e.getMessage(), e);
+        } catch (final ClassNotFoundException e) {
+            throw new MojoExecutionException("Class " + className
+                    + " not found: " + e.getMessage(), e);
+        }
+    }
+
+}

Modified: creadur/rat/trunk/apache-rat-plugin/src/test/java/org/apache/rat/mp/RatCheckMojoTest.java
URL: http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-plugin/src/test/java/org/apache/rat/mp/RatCheckMojoTest.java?rev=1679649&r1=1679648&r2=1679649&view=diff
==============================================================================
--- creadur/rat/trunk/apache-rat-plugin/src/test/java/org/apache/rat/mp/RatCheckMojoTest.java (original)
+++ creadur/rat/trunk/apache-rat-plugin/src/test/java/org/apache/rat/mp/RatCheckMojoTest.java Fri May 15 21:19:15 2015
@@ -17,12 +17,10 @@ package org.apache.rat.mp;
  * limitations under the License.
  */
 
-import static org.apache.rat.mp.RatTestHelpers.ensureRatReportIsCorrect;
-import static org.apache.rat.mp.RatTestHelpers.getSourceDirectory;
-import static org.apache.rat.mp.RatTestHelpers.newArtifactFactory;
-import static org.apache.rat.mp.RatTestHelpers.newArtifactRepository;
-import static org.apache.rat.mp.RatTestHelpers.newArtifactResolver;
-import static org.apache.rat.mp.RatTestHelpers.newSiteRenderer;
+import org.apache.maven.model.Build;
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+import org.apache.rat.config.AddLicenseHeaders;
 
 import java.io.BufferedReader;
 import java.io.File;
@@ -30,9 +28,12 @@ import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStreamReader;
 
-import org.apache.maven.model.Build;
-import org.apache.maven.plugin.testing.AbstractMojoTestCase;
-import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
+import static org.apache.rat.mp.RatTestHelpers.ensureRatReportIsCorrect;
+import static org.apache.rat.mp.RatTestHelpers.getSourceDirectory;
+import static org.apache.rat.mp.RatTestHelpers.newArtifactFactory;
+import static org.apache.rat.mp.RatTestHelpers.newArtifactRepository;
+import static org.apache.rat.mp.RatTestHelpers.newArtifactResolver;
+import static org.apache.rat.mp.RatTestHelpers.newSiteRenderer;
 
 /**
  * Test case for the {@link RatCheckMojo} and {@link RatReportMojo}.
@@ -80,7 +81,7 @@ public class RatCheckMojoTest extends Ab
         setVariableValueToObject(mojo, "useMavenDefaultExcludes", Boolean.TRUE);
         setVariableValueToObject(mojo, "useEclipseDefaultExcludes",
                 Boolean.TRUE);
-        setVariableValueToObject(mojo, "addLicenseHeaders", "false");
+        setVariableValueToObject(mojo, "addLicenseHeaders", AddLicenseHeaders.FALSE.name());
         final Build build = new Build();
         build.setDirectory(buildDirectory.getPath());
         final MavenProjectStub project = new MavenProjectStub() {
@@ -180,7 +181,7 @@ public class RatCheckMojoTest extends Ab
     public void testIt3() throws Exception {
         final RatCheckMojo mojo = (RatCheckMojo) newRatMojo("it3", "check",
                 true);
-        setVariableValueToObject(mojo, "addLicenseHeaders", "true");
+        setVariableValueToObject(mojo, "addLicenseHeaders", AddLicenseHeaders.TRUE.name());
         setVariableValueToObject(mojo, "numUnapprovedLicenses",
                 Integer.valueOf(1));
         mojo.execute();

Modified: creadur/rat/trunk/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Report.java
URL: http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Report.java?rev=1679649&r1=1679648&r2=1679649&view=diff
==============================================================================
--- creadur/rat/trunk/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Report.java (original)
+++ creadur/rat/trunk/apache-rat-tasks/src/main/java/org/apache/rat/anttasks/Report.java Fri May 15 21:19:15 2015
@@ -252,6 +252,7 @@ public class Report extends Task {
         final ReportConfiguration configuration = new ReportConfiguration();
         configuration.setHeaderMatcher(new HeaderMatcherMultiplexer(getLicenseMatchers()));
         configuration.setApprovedLicenseNames(getApprovedLicenseNames());
+        configuration.setApproveDefaultLicenses(true);
         
         if (AddLicenseHeaders.FORCED.equalsIgnoreCase(addLicenseHeaders.getValue())) {
             configuration.setAddingLicenses(true);

Modified: creadur/rat/trunk/pom.xml
URL: http://svn.apache.org/viewvc/creadur/rat/trunk/pom.xml?rev=1679649&r1=1679648&r2=1679649&view=diff
==============================================================================
--- creadur/rat/trunk/pom.xml (original)
+++ creadur/rat/trunk/pom.xml Fri May 15 21:19:15 2015
@@ -130,13 +130,13 @@ agnostic home for software distribution
       <dependency>
         <groupId>org.mockito</groupId>
         <artifactId>mockito-core</artifactId>
-        <version>1.9.5</version>
+        <version>1.10.19</version>
         <scope>test</scope>
       </dependency>
       <dependency>
         <groupId>org.mockito</groupId>
         <artifactId>mockito-all</artifactId>
-        <version>1.9.5</version>
+        <version>1.10.19</version>
         <scope>test</scope>
       </dependency>
       <dependency>