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.sonatype.aether.RepositorySystemSession;
30 import org.sonatype.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, List<RemoteRepository> repositories )
88 {
89 setGroupId( plugin.getGroupId() );
90 setArtifactId( plugin.getArtifactId() );
91
92 setRepositorySession( session );
93
94 setRepositories( repositories );
95 }
96
97 public String getGroupId()
98 {
99 return groupId;
100 }
101
102 public DefaultPluginVersionRequest setGroupId( String groupId )
103 {
104 this.groupId = groupId;
105
106 return this;
107 }
108
109 public String getArtifactId()
110 {
111 return artifactId;
112 }
113
114 public DefaultPluginVersionRequest setArtifactId( String artifactId )
115 {
116 this.artifactId = artifactId;
117
118 return this;
119 }
120
121 public Model getPom()
122 {
123 return pom;
124 }
125
126 public DefaultPluginVersionRequest setPom( Model pom )
127 {
128 this.pom = pom;
129
130 return this;
131 }
132
133 public List<RemoteRepository> getRepositories()
134 {
135 return repositories;
136 }
137
138 public DefaultPluginVersionRequest setRepositories( List<RemoteRepository> repositories )
139 {
140 if ( repositories != null )
141 {
142 this.repositories = repositories;
143 }
144 else
145 {
146 this.repositories = Collections.emptyList();
147 }
148
149 return this;
150 }
151
152 public RepositorySystemSession getRepositorySession()
153 {
154 return session;
155 }
156
157 public DefaultPluginVersionRequest setRepositorySession( RepositorySystemSession session )
158 {
159 this.session = session;
160
161 return this;
162 }
163
164 }