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