Author: pottlinger
Date: Sun Aug 31 22:03:18 2014
New Revision: 1621645
URL: http://svn.apache.org/r1621645
Log:
RAT-172: Filter source code management system directories and ignore files
* Extracted information about revision control systems into an enum
SourceCodeManagementSystems with tests.
* Use these SCM information when generating RAT plugin's default excludes.
* Refactored Exclusions to be Sets instead of Lists to prevent a slow RAT run
on many duplicate exclusions.
* Introduced mockito and unit tests.
* ExclusionHelperTest verifies that behaviour; AbstractRatMojo is cleaner now
to only encapsulate mvn related stuff.
Added:
creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/config/
creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/config/SourceCodeManagementSystems.java
creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/config/package.html
creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/config/
creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/config/SourceCodeManagementSystemsTest.java
creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/ExclusionHelper.java
creadur/rat/trunk/apache-rat-plugin/src/test/java/org/apache/rat/mp/ExclusionHelperTest.java
Removed:
creadur/rat/trunk/apache-rat-plugin/src/test/java/org/apache/rat/mp/AbstractRatMojoTest.java
Modified:
creadur/rat/trunk/apache-rat-plugin/pom.xml
creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/AbstractRatMojo.java
creadur/rat/trunk/pom.xml
Added:
creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/config/SourceCodeManagementSystems.java
URL:
http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/config/SourceCodeManagementSystems.java?rev=1621645&view=auto
==============================================================================
---
creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/config/SourceCodeManagementSystems.java
(added)
+++
creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/config/SourceCodeManagementSystems.java
Sun Aug 31 22:03:18 2014
@@ -0,0 +1,95 @@
+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 java.util.ArrayList;
+import java.util.List;
+
+public enum SourceCodeManagementSystems {
+ SUBVERSION(".svn", null), //
+ GIT(".git", ".gitignore"), //
+ BAZAAR(".bzr", ".bzrignore"), //
+ MERCURIAL(".hg", ".hgignore"), //
+ CVS("CVS", ".cvsignore")
+ //
+ ;
+
+ /**
+ * Technical directory of that SCM which contains SCM internals.
+ */
+ private String directory;
+ /**
+ * If there is a external way to configure files to be ignored: name of
this
+ * file, <code>null</code> otherwise.
+ */
+ private String ignoreFile;
+
+ private SourceCodeManagementSystems(String directory, String
ignoreFile) {
+ this.directory = directory;
+ this.ignoreFile = ignoreFile;
+ }
+
+ /**
+ * If an ignore file exists it's added as
+ *
+ * <pre>
+ * *⁄.scm⁄*
+ * </pre>
+ *
+ * . Otherwise the technical directory of the SCM is added as
+ *
+ * <pre>
+ * **⁄.scmignore
+ * </pre>
+ *
+ * to be used as exclusion during RAT runs.
+ *
+ * @return list of excludes if the current SCM is used.
+ */
+ public List<String> getExclusions() {
+ List<String> excludes = new ArrayList<String>(2);
+
+ if (hasIgnoreFile()) {
+ excludes.add("**/" + ignoreFile);
+ }
+ excludes.add("*/" + directory + "/*");
+
+ return excludes;
+ }
+
+ public Boolean hasIgnoreFile() {
+ return ignoreFile != null && ignoreFile.length() != 0;
+ }
+
+ /**
+ * Calls {@link #getExclusions()} on each SCM to generate a global list
of
+ * exclusions to be used during RAT runs.
+ *
+ * @return the global list of exclusions usable for all known SCM.
+ */
+ public static List<String> getPluginExclusions() {
+ List<String> pluginExclusions = new ArrayList<String>();
+
+ for (SourceCodeManagementSystems scm : values()) {
+ pluginExclusions.addAll(scm.getExclusions());
+ }
+
+ return pluginExclusions;
+ }
+}
\ No newline at end of file
Added:
creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/config/package.html
URL:
http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/config/package.html?rev=1621645&view=auto
==============================================================================
---
creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/config/package.html
(added)
+++
creadur/rat/trunk/apache-rat-core/src/main/java/org/apache/rat/config/package.html
Sun Aug 31 22:03:18 2014
@@ -0,0 +1,17 @@
+<!--
+ 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.
+-->
+<body><p>Contains source code management / revision control information used
during plugin runs.</p></body>
\ No newline at end of file
Added:
creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/config/SourceCodeManagementSystemsTest.java
URL:
http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/config/SourceCodeManagementSystemsTest.java?rev=1621645&view=auto
==============================================================================
---
creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/config/SourceCodeManagementSystemsTest.java
(added)
+++
creadur/rat/trunk/apache-rat-core/src/test/java/org/apache/rat/config/SourceCodeManagementSystemsTest.java
Sun Aug 31 22:03:18 2014
@@ -0,0 +1,56 @@
+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 static org.junit.Assert.*;
+
+import static org.apache.rat.config.SourceCodeManagementSystems.*;
+
+import org.junit.Test;
+
+public class SourceCodeManagementSystemsTest {
+
+ @Test
+ public void testSubversionAndNumberOfSCMSystems() {
+ assertFalse("SVN does not have any external ignore files.",
SUBVERSION.hasIgnoreFile());
+
+ int hasIgnore = 0;
+ int hasNoIgnore = 0;
+ for(SourceCodeManagementSystems scm : values()) {
+ if(scm.hasIgnoreFile()) {
+ hasIgnore++;
+ } else {
+ hasNoIgnore++;
+ }
+ }
+
+ assertEquals("Did you change the number of SCMs?", 4,
hasIgnore);
+ assertEquals("Did you add a new SCM without ignoreFile?", 1,
hasNoIgnore);
+ assertEquals("Amount of SCM has changed.", values().length,
hasIgnore+hasNoIgnore);
+ }
+
+ @Test
+ public void testPluginExcludeLists() {
+ assertEquals(1, SUBVERSION.getExclusions().size());
+ assertEquals(2, GIT.getExclusions().size());
+
+ assertEquals("Did you change the number of SCM systems?", 9,
getPluginExclusions().size());
+ assertEquals("Did you change the number of SCM systems?", 5,
values().length);
+ }
+
+}
Modified: creadur/rat/trunk/apache-rat-plugin/pom.xml
URL:
http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-plugin/pom.xml?rev=1621645&r1=1621644&r2=1621645&view=diff
==============================================================================
--- creadur/rat/trunk/apache-rat-plugin/pom.xml (original)
+++ creadur/rat/trunk/apache-rat-plugin/pom.xml Sun Aug 31 22:03:18 2014
@@ -1,4 +1,4 @@
-<?xml version='1.0'?>
+<?xml version="1.0"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
@@ -31,13 +31,11 @@
<prerequisites>
<maven>${mavenVersion}</maven>
</prerequisites>
-
<properties>
<currentVersion>${project.version}</currentVersion>
<doxiaVersion>1.2</doxiaVersion>
<doxiaSitetoolsVersion>1.2</doxiaSitetoolsVersion>
</properties>
-
<build>
<resources>
<resource>
@@ -114,7 +112,6 @@
</plugin>
</plugins>
</build>
-
<profiles>
<profile>
<id>rat</id>
@@ -143,7 +140,6 @@
</build>
</profile>
</profiles>
-
<dependencies>
<dependency>
<groupId>org.apache.rat</groupId>
@@ -153,7 +149,10 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
-
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ </dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
@@ -228,7 +227,6 @@
<version>3.0.8</version>
</dependency>
</dependencies>
-
<reporting>
<plugins>
<plugin>
@@ -242,7 +240,6 @@
</plugin>
</plugins>
</reporting>
-
<developers>
<developer>
<id>jochen</id>
@@ -250,7 +247,6 @@
<email>[email protected]</email>
</developer>
</developers>
-
<contributors>
<contributor>
<name>Bernd Bohmann</name>
@@ -265,8 +261,7 @@
<email>[email protected]</email>
</contributor>
</contributors>
-
-<!--
+ <!--
<profiles>
<profile>
<id>apache-release</id>
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=1621645&r1=1621644&r2=1621645&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
Sun Aug 31 22:03:18 2014
@@ -19,6 +19,11 @@ package org.apache.rat.mp;
* under the License.
*/
+import static org.apache.rat.mp.ExclusionHelper.addEclipseDefaults;
+import static org.apache.rat.mp.ExclusionHelper.addIdeaDefaults;
+import static org.apache.rat.mp.ExclusionHelper.addMavenDefaults;
+import static org.apache.rat.mp.ExclusionHelper.addPlexusAndScmDefaults;
+
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -27,7 +32,9 @@ import java.lang.reflect.UndeclaredThrow
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import javax.xml.transform.TransformerConfigurationException;
@@ -42,42 +49,16 @@ import org.apache.rat.ReportConfiguratio
import org.apache.rat.analysis.IHeaderMatcher;
import org.apache.rat.analysis.util.HeaderMatcherMultiplexer;
import org.apache.rat.api.RatException;
+import org.apache.rat.config.SourceCodeManagementSystems;
import org.apache.rat.license.ILicenseFamily;
import org.apache.rat.report.IReportable;
import org.apache.rat.report.claim.ClaimStatistic;
import org.codehaus.plexus.util.DirectoryScanner;
-
/**
* Abstract base class for Mojos, which are running Rat.
*/
public abstract class AbstractRatMojo extends AbstractMojo {
- /**
- * The Maven specific default excludes.
- */
- static final List<String> MAVEN_DEFAULT_EXCLUDES = Collections
- .unmodifiableList(Arrays.asList("target/**/*", //
- "cobertura.ser", //
- "release.properties", //
- "pom.xml.releaseBackup"));
-
- /**
- * The Eclipse specific default excludes.
- */
- static final List<String> ECLIPSE_DEFAULT_EXCLUDES = Collections
- .unmodifiableList(Arrays.asList(".classpath",//
- ".project", //
- ".settings/**/*"));
-
- /**
- * The IDEA specific default excludes.
- */
- static final List<String> IDEA_DEFAULT_EXCLUDES = Collections
- .unmodifiableList(Arrays.asList(//
- "*.iml", //
- "*.ipr", //
- "*.iws", //
- ".idea/**/*"));
-
+
/**
* The base directory, in which to search for files.
*
@@ -148,7 +129,8 @@ public abstract class AbstractRatMojo ex
* Whether to use the default excludes when scanning for files. The default
* excludes are:
* <ul>
- * <li>meta data files for version control systems</li>
+ * <li>meta data files for source code management / revision control
systems,
+ * see {@link SourceCodeManagementSystems}</li>
* <li>temporary files used by Maven, see <a
* href="#useMavenDefaultExcludes">useMavenDefaultExcludes</a></li>
* <li>configuration files for Eclipse, see <a
@@ -254,17 +236,17 @@ public abstract class AbstractRatMojo ex
+ clazz.getName());
}
return o;
- } catch (InstantiationException e) {
+ } catch (final InstantiationException e) {
throw new MojoExecutionException("Failed to instantiate class "
+ className + ": " + e.getMessage(), e);
- } catch (ClassCastException e) {
+ } catch (final ClassCastException e) {
throw new MojoExecutionException("The class " + className
+ " is not implementing " + clazz.getName() + ": "
+ e.getMessage(), e);
- } catch (IllegalAccessException e) {
+ } catch (final IllegalAccessException e) {
throw new MojoExecutionException("Illegal access to class "
+ className + ": " + e.getMessage(), e);
- } catch (ClassNotFoundException e) {
+ } catch (final ClassNotFoundException e) {
throw new MojoExecutionException("Class " + className
+ " not found: " + e.getMessage(), e);
}
@@ -300,7 +282,7 @@ public abstract class AbstractRatMojo ex
logAboutIncludedFiles(files);
try {
return new FilesReportable(basedir, files);
- } catch (IOException e) {
+ } catch (final IOException e) {
throw new UndeclaredThrowableException(e);
}
}
@@ -313,7 +295,7 @@ public abstract class AbstractRatMojo ex
files.length
+ " resources included (use -debug for more
details)");
if (getLog().isDebugEnabled()) {
- for (String resource : files) {
+ for (final String resource : files) {
getLog().debug(" - included " + resource);
}
}
@@ -346,33 +328,30 @@ public abstract class AbstractRatMojo ex
if (excludes == null || excludes.length == 0) {
getLog().info("No excludes explicitly specified.");
} else {
- for (String exclude : excludes) {
+ for (final String exclude : excludes) {
getLog().info("Exclude: " + exclude);
}
}
add(excludeList, excludes);
if (!excludeList.isEmpty()) {
- String[] allExcludes = excludeList.toArray(new String[excludeList
+ final String[] allExcludes = excludeList.toArray(new
String[excludeList
.size()]);
ds.setExcludes(allExcludes);
}
}
private List<String> buildDefaultExclusions() {
- final List<String> results = new ArrayList<String>();
-
- addPlexusDefaults(results);
+ final Set<String> results = new HashSet<String>();
- addMavenDefaults(results);
-
- addEclipseDefaults(results);
-
- addIdeaDefaults(results);
+ addPlexusAndScmDefaults(getLog(), useDefaultExcludes, results);
+ addMavenDefaults(getLog(), useMavenDefaultExcludes, results);
+ addEclipseDefaults(getLog(), useEclipseDefaultExcludes, results);
+ addIdeaDefaults(getLog(), useIdeaDefaultExcludes, results);
if (excludeSubProjects && project != null
&& project.getModules() != null) {
- for (Object o : project.getModules()) {
- String moduleSubPath = (String) o;
+ for (final Object o : project.getModules()) {
+ final String moduleSubPath = (String) o;
results.add(moduleSubPath + "/**/*");
}
}
@@ -389,58 +368,7 @@ public abstract class AbstractRatMojo ex
}
}
- return results;
- }
-
- private void addPlexusDefaults(final List<String> excludeList1) {
- if (useDefaultExcludes) {
- getLog().debug("Adding plexus default exclusions...");
- Collections.addAll(excludeList1, DirectoryScanner.DEFAULTEXCLUDES);
- } else {
- getLog().debug(
- "rat.useDefaultExcludes set to false. "
- + "Plexus default exclusions will not be added");
- }
- }
-
- private void addMavenDefaults(final List<String> excludeList1) {
- if (useMavenDefaultExcludes) {
- getLog().debug(
- "Adding exclusions often needed by Maven projects...");
- excludeList1.addAll(MAVEN_DEFAULT_EXCLUDES);
- } else {
- getLog().debug(
- "rat.useMavenDefaultExcludes set to false. "
- + "Exclusions often needed by Maven projects will
not be added.");
- }
- }
-
- private void addEclipseDefaults(final List<String> excludeList1) {
- if (useEclipseDefaultExcludes) {
- getLog().debug(
- "Adding exclusions often needed by projects "
- + "developed in Eclipse...");
- excludeList1.addAll(ECLIPSE_DEFAULT_EXCLUDES);
- } else {
- getLog().debug(
- "rat.useEclipseDefaultExcludes set to false. "
- + "Exclusions often needed by projects developed
in "
- + "Eclipse will not be added.");
- }
- }
-
- private void addIdeaDefaults(final List<String> excludeList1) {
- if (useIdeaDefaultExcludes) {
- getLog().debug(
- "Adding exclusions often needed by projects "
- + "developed in IDEA...");
- excludeList1.addAll(IDEA_DEFAULT_EXCLUDES);
- } else {
- getLog().debug(
- "rat.useIdeaDefaultExcludes set to false. "
- + "Exclusions often needed by projects developed
in "
- + "IDEA will not be added.");
- }
+ return new ArrayList<String>(results);
}
/**
@@ -467,13 +395,13 @@ public abstract class AbstractRatMojo ex
} else {
return Report.report(getResources(), out, configuration);
}
- } catch (TransformerConfigurationException e) {
+ } catch (final TransformerConfigurationException e) {
throw new MojoExecutionException(e.getMessage(), e);
- } catch (IOException e) {
+ } catch (final IOException e) {
throw new MojoExecutionException(e.getMessage(), e);
- } catch (InterruptedException e) {
+ } catch (final InterruptedException e) {
throw new MojoExecutionException(e.getMessage(), e);
- } catch (RatException e) {
+ } catch (final RatException e) {
throw new MojoExecutionException(e.getMessage(), e);
}
}
@@ -494,7 +422,7 @@ public abstract class AbstractRatMojo ex
list.addAll(Arrays.asList(licenseFamilies));
}
if (licenseFamilyNames != null) {
- for (LicenseFamilySpecification spec : licenseFamilyNames) {
+ for (final LicenseFamilySpecification spec : licenseFamilyNames) {
list.add(newInstance(ILicenseFamily.class,
spec.getClassName()));
}
}
Added:
creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/ExclusionHelper.java
URL:
http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/ExclusionHelper.java?rev=1621645&view=auto
==============================================================================
---
creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/ExclusionHelper.java
(added)
+++
creadur/rat/trunk/apache-rat-plugin/src/main/java/org/apache/rat/mp/ExclusionHelper.java
Sun Aug 31 22:03:18 2014
@@ -0,0 +1,114 @@
+package org.apache.rat.mp;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.maven.plugin.logging.Log;
+import org.apache.rat.config.SourceCodeManagementSystems;
+import org.codehaus.plexus.util.DirectoryScanner;
+
+/*
+ * 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.
+ */
+
+/**
+ * This class encapsulates the file/directory exclusion handling of RAT.
+ */
+public final class ExclusionHelper {
+ /**
+ * The Maven specific default excludes.
+ */
+ static final List<String> MAVEN_DEFAULT_EXCLUDES = Collections
+ .unmodifiableList(Arrays.asList(//
+ "target/**/*", //
+ "cobertura.ser", //
+ "release.properties", //
+ "pom.xml.releaseBackup"));
+
+ /**
+ * The Eclipse specific default excludes.
+ */
+ static final List<String> ECLIPSE_DEFAULT_EXCLUDES = Collections
+ .unmodifiableList(Arrays.asList(".classpath",//
+ ".project", //
+ ".settings/**/*"));
+
+ /**
+ * The IDEA specific default excludes.
+ */
+ static final List<String> IDEA_DEFAULT_EXCLUDES = Collections
+ .unmodifiableList(Arrays.asList(//
+ "*.iml", //
+ "*.ipr", //
+ "*.iws", //
+ ".idea/**/*"));
+
+ static void addPlexusAndScmDefaults(Log log, final boolean
useDefaultExcludes,
+ final Set<String> excludeList1) {
+ if (useDefaultExcludes) {
+ log.debug("Adding plexus default exclusions...");
+ Collections.addAll(excludeList1,
DirectoryScanner.DEFAULTEXCLUDES);
+ log.debug("Adding SCM default exclusions...");
+ excludeList1.addAll(//
+
SourceCodeManagementSystems.getPluginExclusions());
+ } else {
+ log.debug("rat.useDefaultExcludes set to false. "
+ + "Plexus and SCM default exclusions
will not be added");
+ }
+ }
+
+ static void addMavenDefaults(Log log, boolean useMavenDefaultExcludes,
+ final Set<String> excludeList) {
+ if (useMavenDefaultExcludes) {
+ log.debug("Adding exclusions often needed by Maven
projects...");
+ excludeList.addAll(MAVEN_DEFAULT_EXCLUDES);
+ } else {
+ log.debug("rat.useMavenDefaultExcludes set to false. "
+ + "Exclusions often needed by Maven
projects will not be added.");
+ }
+ }
+
+ static void addEclipseDefaults(Log log, boolean
useEclipseDefaultExcludes,
+ final Set<String> excludeList) {
+ if (useEclipseDefaultExcludes) {
+ log.debug("Adding exclusions often needed by projects "
+ + "developed in Eclipse...");
+ excludeList.addAll(ECLIPSE_DEFAULT_EXCLUDES);
+ } else {
+ log.debug("rat.useEclipseDefaultExcludes set to false. "
+ + "Exclusions often needed by projects
developed in "
+ + "Eclipse will not be added.");
+ }
+ }
+
+ static void addIdeaDefaults(Log log, boolean useIdeaDefaultExcludes,
+ final Set<String> excludeList) {
+ if (useIdeaDefaultExcludes) {
+ log.debug("Adding exclusions often needed by projects "
+ + "developed in IDEA...");
+ excludeList.addAll(IDEA_DEFAULT_EXCLUDES);
+ } else {
+ log.debug("rat.useIdeaDefaultExcludes set to false. "
+ + "Exclusions often needed by projects
developed in "
+ + "IDEA will not be added.");
+ }
+ }
+
+}
Added:
creadur/rat/trunk/apache-rat-plugin/src/test/java/org/apache/rat/mp/ExclusionHelperTest.java
URL:
http://svn.apache.org/viewvc/creadur/rat/trunk/apache-rat-plugin/src/test/java/org/apache/rat/mp/ExclusionHelperTest.java?rev=1621645&view=auto
==============================================================================
---
creadur/rat/trunk/apache-rat-plugin/src/test/java/org/apache/rat/mp/ExclusionHelperTest.java
(added)
+++
creadur/rat/trunk/apache-rat-plugin/src/test/java/org/apache/rat/mp/ExclusionHelperTest.java
Sun Aug 31 22:03:18 2014
@@ -0,0 +1,108 @@
+package org.apache.rat.mp;
+
+/*
+ * 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 static org.apache.rat.mp.ExclusionHelper.ECLIPSE_DEFAULT_EXCLUDES;
+import static org.apache.rat.mp.ExclusionHelper.IDEA_DEFAULT_EXCLUDES;
+import static org.apache.rat.mp.ExclusionHelper.MAVEN_DEFAULT_EXCLUDES;
+import static org.apache.rat.mp.ExclusionHelper.addEclipseDefaults;
+import static org.apache.rat.mp.ExclusionHelper.addIdeaDefaults;
+import static org.apache.rat.mp.ExclusionHelper.addMavenDefaults;
+import static org.apache.rat.mp.ExclusionHelper.addPlexusAndScmDefaults;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.maven.plugin.logging.Log;
+import org.apache.rat.config.SourceCodeManagementSystems;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+
+@RunWith(MockitoJUnitRunner.class)
+public class ExclusionHelperTest {
+
+ @Mock
+ Log log;
+
+ @Test
+ public void testNumberOfExclusions() {
+ assertEquals("Did you change the number of eclipse excludes?",
3,
+ ECLIPSE_DEFAULT_EXCLUDES.size());
+ assertEquals("Did you change the number of idea excludes?", 4,
+ IDEA_DEFAULT_EXCLUDES.size());
+ assertEquals("Did you change the number of mvn excludes?", 4,
+ MAVEN_DEFAULT_EXCLUDES.size());
+ }
+
+ @Test
+ public void testAddingEclipseExclusions() {
+ final Set<String> exclusion = new HashSet<String>();
+ addEclipseDefaults(log, false, exclusion);
+ assertTrue(exclusion.isEmpty());
+ addEclipseDefaults(log, true, exclusion);
+ assertEquals(3, exclusion.size());
+ addEclipseDefaults(log, true, exclusion);
+ assertEquals(3, exclusion.size());
+ }
+
+ @Test
+ public void testAddingIdeaExclusions() {
+ final Set<String> exclusion = new HashSet<String>();
+ addIdeaDefaults(log, false, exclusion);
+ assertTrue(exclusion.isEmpty());
+ addIdeaDefaults(log, true, exclusion);
+ assertEquals(4, exclusion.size());
+ addIdeaDefaults(log, true, exclusion);
+ assertEquals(4, exclusion.size());
+ }
+
+ @Test
+ public void testAddingMavenExclusions() {
+ final Set<String> exclusion = new HashSet<String>();
+ addMavenDefaults(log, false, exclusion);
+ assertTrue(exclusion.isEmpty());
+ addMavenDefaults(log, true, exclusion);
+ assertEquals(4, exclusion.size());
+ addMavenDefaults(log, true, exclusion);
+ assertEquals(4, exclusion.size());
+ }
+
+ @Test
+ public void testAddingPlexusAndScmExclusion() {
+ final int expectedSizeMergedFromPlexusDefaultsAndScm = (38 +
SourceCodeManagementSystems.getPluginExclusions().size());
+
+ final Set<String> exclusion = new HashSet<String>();
+ addPlexusAndScmDefaults(log, false, exclusion);
+ assertTrue(exclusion.isEmpty());
+ addPlexusAndScmDefaults(log, true, exclusion);
+ assertEquals(
+ "Did you upgrade plexus to get more default
excludes?",//
+ expectedSizeMergedFromPlexusDefaultsAndScm,//
+ exclusion.size());
+ addPlexusAndScmDefaults(log, true, exclusion);
+ assertEquals(
+ "Did you upgrade plexus to get more default
excludes?",//
+ expectedSizeMergedFromPlexusDefaultsAndScm,//
+ exclusion.size());
+ }
+
+}
Modified: creadur/rat/trunk/pom.xml
URL:
http://svn.apache.org/viewvc/creadur/rat/trunk/pom.xml?rev=1621645&r1=1621644&r2=1621645&view=diff
==============================================================================
--- creadur/rat/trunk/pom.xml (original)
+++ creadur/rat/trunk/pom.xml Sun Aug 31 22:03:18 2014
@@ -42,11 +42,9 @@ Apache Rat is developed by the Apache Cr
agnostic home for software distribution comprehension and audit tools.
</description>
<inceptionYear>2006</inceptionYear>
-
<prerequisites>
<maven>${mavenVersion}</maven>
</prerequisites>
-
<properties>
<javaVersion>1.5</javaVersion>
<maven.compiler.source>${javaVersion}</maven.compiler.source>
@@ -75,13 +73,11 @@ agnostic home for software distribution
<rat.site.url>file:${rat.LocalSiteStaging}</rat.site.url>
<rat.site.name>Apache Rat Website</rat.site.name>
<rat.site.id>org.apache.rat.site</rat.site.id>
-
<!-- maven plugin versions -->
<mavenInvokerPluginVersion>1.9</mavenInvokerPluginVersion>
<mavenPluginPluginVersion>3.3</mavenPluginPluginVersion>
<surefire.version>2.17</surefire.version>
</properties>
-
<dependencyManagement>
<dependencies>
<dependency>
@@ -128,6 +124,12 @@ agnostic home for software distribution
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.9.5</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.7.1</version>
@@ -147,7 +149,6 @@ agnostic home for software distribution
</dependency>
</dependencies>
</dependencyManagement>
-
<reporting>
<plugins>
<plugin>
@@ -229,7 +230,6 @@ agnostic home for software distribution
</plugin>
</plugins>
</reporting>
-
<build>
<defaultGoal>clean install</defaultGoal>
<pluginManagement>
@@ -329,7 +329,7 @@ agnostic home for software distribution
</goals>
<configuration>
<target>
- <copy file="RELEASE_NOTES.txt"
todir="${project.build.directory}/site/" failonerror="false" />
+ <copy file="RELEASE_NOTES.txt"
todir="${project.build.directory}/site/" failonerror="false"/>
</target>
</configuration>
</execution>
@@ -400,12 +400,10 @@ agnostic home for software distribution
</extension>
</extensions>
</build>
-
<issueManagement>
<system>JIRA</system>
<url>https://issues.apache.org/jira/browse/RAT</url>
</issueManagement>
-
<ciManagement>
<system>Buildbot</system>
<url>http://ci.apache.org/builders/rat_trunk</url>
@@ -414,7 +412,6 @@ agnostic home for software distribution
https://builds.apache.org/job/Creadur-Rat-Site/ - generate mvn site
-->
</ciManagement>
-
<mailingLists>
<mailingList>
<name>Rat Development (Apache Creadur project)</name>
@@ -512,13 +509,11 @@ agnostic home for software distribution
<email>[email protected]</email>
</contributor>
</contributors>
-
<scm>
<connection>scm:svn:http://svn.apache.org/repos/asf/creadur/rat/trunk</connection>
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/creadur/rat/trunk</developerConnection>
<url>http://svn.apache.org/repos/asf/creadur/rat/trunk</url>
</scm>
-
<distributionManagement>
<site>
<id>${rat.site.id}</id>
@@ -526,14 +521,12 @@ agnostic home for software distribution
<url>${rat.site.url}</url>
</site>
</distributionManagement>
-
<modules>
<module>apache-rat-core</module>
<module>apache-rat-plugin</module>
<module>apache-rat-tasks</module>
<module>apache-rat</module>
</modules>
-
<licenses>
<license>
<name>Apache License, Version 2</name>
@@ -542,12 +535,10 @@ agnostic home for software distribution
<comments>An OSI approved open source license.</comments>
</license>
</licenses>
-
<organization>
<name>Apache Software Foundation</name>
<url>http://www.apache.org</url>
</organization>
-
<profiles>
<profile>
<id>apache-release</id>