1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven;
20
21 import javax.inject.Inject;
22 import javax.inject.Named;
23 import javax.inject.Singleton;
24
25 import java.util.LinkedHashSet;
26 import java.util.List;
27 import java.util.Set;
28
29 import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
30 import org.apache.maven.artifact.resolver.filter.ExclusionSetFilter;
31 import org.apache.maven.extension.internal.CoreExports;
32
33
34
35 @Named
36 @Singleton
37 @Deprecated
38 public class DefaultArtifactFilterManager implements ArtifactFilterManager {
39
40
41 protected final List<ArtifactFilterManagerDelegate> delegates;
42
43 protected Set<String> excludedArtifacts;
44
45 private final Set<String> coreArtifacts;
46
47 @Inject
48 public DefaultArtifactFilterManager(List<ArtifactFilterManagerDelegate> delegates, CoreExports coreExports) {
49 this.delegates = delegates;
50 this.coreArtifacts = coreExports.getExportedArtifacts();
51 }
52
53 private synchronized Set<String> getExcludedArtifacts() {
54 if (excludedArtifacts == null) {
55 excludedArtifacts = new LinkedHashSet<>(coreArtifacts);
56 }
57 return excludedArtifacts;
58 }
59
60
61
62
63
64
65 public ArtifactFilter getArtifactFilter() {
66 Set<String> excludes = new LinkedHashSet<>(getExcludedArtifacts());
67
68 for (ArtifactFilterManagerDelegate delegate : delegates) {
69 delegate.addExcludes(excludes);
70 }
71
72 return new ExclusionSetFilter(excludes);
73 }
74
75
76
77
78
79
80 public ArtifactFilter getCoreArtifactFilter() {
81 return new ExclusionSetFilter(getCoreArtifactExcludes());
82 }
83
84 public void excludeArtifact(String artifactId) {
85 getExcludedArtifacts().add(artifactId);
86 }
87
88 public Set<String> getCoreArtifactExcludes() {
89 Set<String> excludes = new LinkedHashSet<>(coreArtifacts);
90
91 for (ArtifactFilterManagerDelegate delegate : delegates) {
92 delegate.addCoreExcludes(excludes);
93 }
94
95 return excludes;
96 }
97 }