1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.plugin.prefix;
20
21 import java.util.Collections;
22 import java.util.List;
23
24 import org.apache.maven.execution.MavenSession;
25 import org.apache.maven.model.Model;
26 import org.apache.maven.project.MavenProject;
27 import org.eclipse.aether.RepositorySystemSession;
28 import org.eclipse.aether.repository.RemoteRepository;
29
30
31
32
33
34
35 public class DefaultPluginPrefixRequest implements PluginPrefixRequest {
36
37 private String prefix;
38
39 private List<String> pluginGroups = Collections.emptyList();
40
41 private Model pom;
42
43 private List<RemoteRepository> repositories = Collections.emptyList();
44
45 private RepositorySystemSession session;
46
47
48
49
50 public DefaultPluginPrefixRequest() {}
51
52
53
54
55
56
57
58
59
60 public DefaultPluginPrefixRequest(String prefix, MavenSession session) {
61 setPrefix(prefix);
62
63 setRepositorySession(session.getRepositorySession());
64
65 MavenProject project = session.getCurrentProject();
66 if (project != null) {
67 setRepositories(project.getRemotePluginRepositories());
68 setPom(project.getModel());
69 }
70
71 setPluginGroups(session.getPluginGroups());
72 }
73
74 public String getPrefix() {
75 return prefix;
76 }
77
78 public DefaultPluginPrefixRequest setPrefix(String prefix) {
79 this.prefix = prefix;
80
81 return this;
82 }
83
84 public List<String> getPluginGroups() {
85 return pluginGroups;
86 }
87
88 public DefaultPluginPrefixRequest setPluginGroups(List<String> pluginGroups) {
89 if (pluginGroups != null) {
90 this.pluginGroups = Collections.unmodifiableList(pluginGroups);
91 } else {
92 this.pluginGroups = Collections.emptyList();
93 }
94
95 return this;
96 }
97
98 public Model getPom() {
99 return pom;
100 }
101
102 public DefaultPluginPrefixRequest setPom(Model pom) {
103 this.pom = pom;
104
105 return this;
106 }
107
108 public List<RemoteRepository> getRepositories() {
109 return repositories;
110 }
111
112 public DefaultPluginPrefixRequest setRepositories(List<RemoteRepository> repositories) {
113 if (repositories != null) {
114 this.repositories = Collections.unmodifiableList(repositories);
115 } else {
116 this.repositories = Collections.emptyList();
117 }
118
119 return this;
120 }
121
122 public RepositorySystemSession getRepositorySession() {
123 return session;
124 }
125
126 public DefaultPluginPrefixRequest setRepositorySession(RepositorySystemSession session) {
127 this.session = session;
128
129 return this;
130 }
131 }