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