1 package org.kuali.maven.plugin.ksite.mojo;
2
3 import java.util.Properties;
4
5 import org.apache.maven.model.DistributionManagement;
6 import org.apache.maven.model.Site;
7 import org.apache.maven.plugin.AbstractMojo;
8 import org.apache.maven.plugin.MojoExecutionException;
9 import org.apache.maven.plugin.MojoFailureException;
10 import org.apache.maven.project.MavenProject;
11 import org.kuali.maven.common.SiteContext;
12 import org.kuali.maven.common.UrlBuilder;
13
14
15
16
17
18
19
20 public class KualiSiteMojo extends AbstractMojo implements SiteContext {
21
22
23
24
25
26
27 private String downloadSnapshotPrefix;
28
29
30
31
32
33
34 private String downloadReleasePrefix;
35
36
37
38
39
40
41 private String publishUrlProtocol;
42
43
44
45
46
47
48 private String publicUrlProtocol;
49
50
51
52
53
54
55
56 private String downloadPrefix;
57
58
59
60
61
62
63 private String organizationGroupId;
64
65
66
67
68
69
70
71 private String bucket;
72
73
74
75
76
77
78
79 private String hostname;
80
81
82
83
84
85
86
87
88 private MavenProject project;
89
90 @Override
91 public void execute() throws MojoExecutionException, MojoFailureException {
92 UrlBuilder builder = new UrlBuilder();
93
94
95 String publicUrl = builder.getPublicUrl(getProject(), this);
96 String publishUrl = builder.getPublishUrl(getProject(), this);
97 String downloadUrl = builder.getDownloadUrl(getProject(), this);
98
99
100 MavenProject project = getProject();
101 DistributionManagement dm = project.getDistributionManagement();
102 Site site = dm.getSite();
103
104 getLog().info("Public url - " + publicUrl);
105 getLog().info("Publish url - " + publishUrl);
106 getLog().info("Download url - " + downloadUrl);
107
108
109 project.setUrl(publicUrl);
110 dm.setDownloadUrl(downloadUrl);
111 site.setUrl(publishUrl);
112
113
114 Properties properties = getProject().getProperties();
115 properties.setProperty("kuali.site.public.url", publicUrl);
116 }
117
118
119
120
121 public MavenProject getProject() {
122 return project;
123 }
124
125
126
127
128
129 public void setProject(final MavenProject project) {
130 this.project = project;
131 }
132
133
134
135
136 @Override
137 public String getBucket() {
138 return bucket;
139 }
140
141
142
143
144
145 public void setBucket(final String bucket) {
146 this.bucket = bucket;
147 }
148
149
150
151
152 @Override
153 public String getHostname() {
154 return hostname;
155 }
156
157
158
159
160
161 public void setHostname(final String hostname) {
162 this.hostname = hostname;
163 }
164
165
166
167
168 @Override
169 public String getDownloadPrefix() {
170 return downloadPrefix;
171 }
172
173
174
175
176
177 public void setDownloadPrefix(final String downloadPrefix) {
178 this.downloadPrefix = downloadPrefix;
179 }
180
181
182
183
184 @Override
185 public String getOrganizationGroupId() {
186 return organizationGroupId;
187 }
188
189
190
191
192
193 public void setOrganizationGroupId(final String parentGroupId) {
194 this.organizationGroupId = parentGroupId;
195 }
196
197
198
199
200 @Override
201 public String getPublishUrlProtocol() {
202 return publishUrlProtocol;
203 }
204
205
206
207
208
209 public void setPublishUrlProtocol(final String publishUrlProtocol) {
210 this.publishUrlProtocol = publishUrlProtocol;
211 }
212
213
214
215
216 @Override
217 public String getPublicUrlProtocol() {
218 return publicUrlProtocol;
219 }
220
221
222
223
224
225 public void setPublicUrlProtocol(final String publicUrlProtocol) {
226 this.publicUrlProtocol = publicUrlProtocol;
227 }
228
229
230
231
232 @Override
233 public String getDownloadSnapshotPrefix() {
234 return downloadSnapshotPrefix;
235 }
236
237
238
239
240
241 public void setDownloadSnapshotPrefix(final String downloadSnapshotPrefix) {
242 this.downloadSnapshotPrefix = downloadSnapshotPrefix;
243 }
244
245
246
247
248 @Override
249 public String getDownloadReleasePrefix() {
250 return downloadReleasePrefix;
251 }
252
253
254
255
256
257 public void setDownloadReleasePrefix(final String downloadReleasePrefix) {
258 this.downloadReleasePrefix = downloadReleasePrefix;
259 }
260
261 }