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