1 package org.apache.rat.mp.util;
2
3 import org.apache.maven.plugin.logging.Log;
4 import org.apache.rat.config.SourceCodeManagementSystems;
5
6 import java.util.Arrays;
7 import java.util.Collections;
8 import java.util.HashSet;
9 import java.util.List;
10 import java.util.Set;
11
12 import static org.codehaus.plexus.util.AbstractScanner.DEFAULTEXCLUDES;
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37 public final class ExclusionHelper {
38
39
40
41 static final List<String> MAVEN_DEFAULT_EXCLUDES = Collections
42 .unmodifiableList(Arrays.asList(
43 "target/**/*",
44 "cobertura.ser",
45 "**/MANIFEST.MF",
46 "release.properties",
47 ".repository",
48 "build.log",
49 ".mvn/**/*",
50 "pom.xml.releaseBackup"));
51
52
53
54
55 static final List<String> ECLIPSE_DEFAULT_EXCLUDES = Collections
56 .unmodifiableList(Arrays.asList(
57 ".checkstyle",
58 ".classpath",
59 ".factorypath",
60 ".project",
61 ".settings/**/*"));
62
63
64
65
66 static final List<String> IDEA_DEFAULT_EXCLUDES = Collections
67 .unmodifiableList(Arrays.asList(
68 "*.iml",
69 "*.ipr",
70 "*.iws",
71 ".idea/**/*"));
72
73 public static Set<String> addPlexusAndScmDefaults(Log log, final boolean useDefaultExcludes) {
74 Set<String> excludeList = new HashSet<>();
75 if (useDefaultExcludes) {
76 log.debug("Adding plexus default exclusions...");
77 Collections.addAll(excludeList, DEFAULTEXCLUDES);
78 log.debug("Adding SCM default exclusions...");
79 excludeList.addAll(SourceCodeManagementSystems.getPluginExclusions());
80 } else {
81 log.debug("rat.useDefaultExcludes set to false. "
82 + "Plexus and SCM default exclusions will not be added");
83 }
84 return excludeList;
85 }
86
87 public static Set<String> addMavenDefaults(Log log, boolean useMavenDefaultExcludes) {
88 Set<String> excludeList = new HashSet<>();
89 if (useMavenDefaultExcludes) {
90 log.debug("Adding exclusions often needed by Maven projects...");
91 excludeList.addAll(MAVEN_DEFAULT_EXCLUDES);
92 } else {
93 log.debug("rat.useMavenDefaultExcludes set to false. "
94 + "Exclusions often needed by Maven projects will not be added.");
95 }
96 return excludeList;
97 }
98
99 public static Set<String> addEclipseDefaults(Log log, boolean useEclipseDefaultExcludes) {
100 Set<String> excludeList = new HashSet<>();
101 if (useEclipseDefaultExcludes) {
102 log.debug("Adding exclusions often needed by projects "
103 + "developed in Eclipse...");
104 excludeList.addAll(ECLIPSE_DEFAULT_EXCLUDES);
105 } else {
106 log.debug("rat.useEclipseDefaultExcludes set to false. "
107 + "Exclusions often needed by projects developed in "
108 + "Eclipse will not be added.");
109 }
110 return excludeList;
111 }
112
113 public static Set<String> addIdeaDefaults(Log log, boolean useIdeaDefaultExcludes) {
114 Set<String> excludeList = new HashSet<>();
115 if (useIdeaDefaultExcludes) {
116 log.debug("Adding exclusions often needed by projects "
117 + "developed in IDEA...");
118 excludeList.addAll(IDEA_DEFAULT_EXCLUDES);
119 } else {
120 log.debug("rat.useIdeaDefaultExcludes set to false. "
121 + "Exclusions often needed by projects developed in "
122 + "IDEA will not be added.");
123 }
124 return excludeList;
125 }
126
127 }