1 package org.apache.rat.mp.util;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 import org.apache.maven.plugin.logging.Log;
24 import org.apache.rat.config.SourceCodeManagementSystems;
25 import org.apache.rat.mp.util.ignore.GitIgnoreMatcher;
26 import org.apache.rat.mp.util.ignore.GlobIgnoreMatcher;
27 import org.apache.rat.mp.util.ignore.IgnoreMatcher;
28
29 import java.io.File;
30 import java.util.ArrayList;
31 import java.util.List;
32
33
34
35
36
37 public final class ScmIgnoreParser {
38 private ScmIgnoreParser() {
39
40 }
41
42
43
44
45
46
47
48
49 public static List<IgnoreMatcher> getExclusionsFromSCM(final Log log, final File baseDir) {
50 List<IgnoreMatcher> ignoreMatchers = new ArrayList<>();
51 for (SourceCodeManagementSystems scm : SourceCodeManagementSystems.values()) {
52 switch (scm) {
53 case GIT:
54 GitIgnoreMatcher gitIgnoreMatcher = new GitIgnoreMatcher(log, baseDir);
55 if (!gitIgnoreMatcher.isEmpty()) {
56 ignoreMatchers.add(gitIgnoreMatcher);
57 }
58 break;
59 default:
60 if (scm.hasIgnoreFile()) {
61 GlobIgnoreMatcher ignoreMatcher = new GlobIgnoreMatcher(log, new File(baseDir, scm.getIgnoreFile()));
62 if (!ignoreMatcher.isEmpty()) {
63 ignoreMatchers.add(ignoreMatcher);
64 }
65 }
66 break;
67 }
68 }
69 return ignoreMatchers;
70 }
71
72
73 }