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
36 public class DefaultPluginPrefixRequest implements PluginPrefixRequest {
37
38 private String prefix;
39
40 private List<String> pluginGroups = Collections.emptyList();
41
42 private Model pom;
43
44 private List<RemoteRepository> repositories = Collections.emptyList();
45
46 private RepositorySystemSession session;
47
48
49
50
51 public DefaultPluginPrefixRequest() {}
52
53
54
55
56
57
58
59
60
61 public DefaultPluginPrefixRequest(String prefix, MavenSession session) {
62 setPrefix(prefix);
63
64 setRepositorySession(session.getRepositorySession());
65
66 MavenProject project = session.getCurrentProject();
67 if (project != null) {
68 setRepositories(project.getRemotePluginRepositories());
69 setPom(project.getModel());
70 }
71
72 setPluginGroups(session.getPluginGroups());
73 }
74
75 public String getPrefix() {
76 return prefix;
77 }
78
79 public DefaultPluginPrefixRequest setPrefix(String prefix) {
80 this.prefix = prefix;
81
82 return this;
83 }
84
85 public List<String> getPluginGroups() {
86 return pluginGroups;
87 }
88
89 public DefaultPluginPrefixRequest setPluginGroups(List<String> pluginGroups) {
90 if (pluginGroups != null) {
91 this.pluginGroups = Collections.unmodifiableList(pluginGroups);
92 } else {
93 this.pluginGroups = Collections.emptyList();
94 }
95
96 return this;
97 }
98
99 public Model getPom() {
100 return pom;
101 }
102
103 public DefaultPluginPrefixRequest setPom(Model pom) {
104 this.pom = pom;
105
106 return this;
107 }
108
109 public List<RemoteRepository> getRepositories() {
110 return repositories;
111 }
112
113 public DefaultPluginPrefixRequest setRepositories(List<RemoteRepository> repositories) {
114 if (repositories != null) {
115 this.repositories = Collections.unmodifiableList(repositories);
116 } else {
117 this.repositories = Collections.emptyList();
118 }
119
120 return this;
121 }
122
123 public RepositorySystemSession getRepositorySession() {
124 return session;
125 }
126
127 public DefaultPluginPrefixRequest setRepositorySession(RepositorySystemSession session) {
128 this.session = session;
129
130 return this;
131 }
132 }