1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.plugin.version;
20
21 import java.util.Collections;
22 import java.util.List;
23 import org.apache.maven.execution.MavenSession;
24 import org.apache.maven.model.Model;
25 import org.apache.maven.model.Plugin;
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 DefaultPluginVersionRequest implements PluginVersionRequest {
37
38 private String groupId;
39
40 private String artifactId;
41
42 private Model pom;
43
44 private List<RemoteRepository> repositories = Collections.emptyList();
45
46 private RepositorySystemSession session;
47
48
49
50
51 public DefaultPluginVersionRequest() {}
52
53
54
55
56
57
58
59
60 public DefaultPluginVersionRequest(Plugin plugin, MavenSession session) {
61 setGroupId(plugin.getGroupId());
62 setArtifactId(plugin.getArtifactId());
63
64 setRepositorySession(session.getRepositorySession());
65
66 MavenProject project = session.getCurrentProject();
67 if (project != null) {
68 setRepositories(project.getRemotePluginRepositories());
69 }
70 }
71
72
73
74
75
76
77
78
79 public DefaultPluginVersionRequest(
80 Plugin plugin, RepositorySystemSession session, List<RemoteRepository> repositories) {
81 setGroupId(plugin.getGroupId());
82 setArtifactId(plugin.getArtifactId());
83
84 setRepositorySession(session);
85
86 setRepositories(repositories);
87 }
88
89 public String getGroupId() {
90 return groupId;
91 }
92
93 public DefaultPluginVersionRequest setGroupId(String groupId) {
94 this.groupId = groupId;
95
96 return this;
97 }
98
99 public String getArtifactId() {
100 return artifactId;
101 }
102
103 public DefaultPluginVersionRequest setArtifactId(String artifactId) {
104 this.artifactId = artifactId;
105
106 return this;
107 }
108
109 public Model getPom() {
110 return pom;
111 }
112
113 public DefaultPluginVersionRequest setPom(Model pom) {
114 this.pom = pom;
115
116 return this;
117 }
118
119 public List<RemoteRepository> getRepositories() {
120 return repositories;
121 }
122
123 public DefaultPluginVersionRequest setRepositories(List<RemoteRepository> repositories) {
124 if (repositories != null) {
125 this.repositories = Collections.unmodifiableList(repositories);
126 } else {
127 this.repositories = Collections.emptyList();
128 }
129
130 return this;
131 }
132
133 public RepositorySystemSession getRepositorySession() {
134 return session;
135 }
136
137 public DefaultPluginVersionRequest setRepositorySession(RepositorySystemSession session) {
138 this.session = session;
139
140 return this;
141 }
142 }