| 1 |
|
package org.kuali.maven.plugin.ksite.mojo; |
| 2 |
|
|
| 3 |
|
import org.apache.commons.lang.StringUtils; |
| 4 |
|
import org.apache.maven.model.DistributionManagement; |
| 5 |
|
import org.apache.maven.model.Site; |
| 6 |
|
import org.apache.maven.plugin.AbstractMojo; |
| 7 |
|
import org.apache.maven.plugin.MojoExecutionException; |
| 8 |
|
import org.apache.maven.plugin.MojoFailureException; |
| 9 |
|
import org.apache.maven.project.MavenProject; |
| 10 |
|
import org.kuali.maven.common.SiteContext; |
| 11 |
|
import org.kuali.maven.common.UrlBuilder; |
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
|
|
|
| 0% |
Uncovered Elements: 114 (114) |
Complexity: 36 |
Complexity Density: 0.54 |
|
| 19 |
|
public class KualiSiteMojo extends AbstractMojo implements SiteContext { |
| 20 |
|
|
| 21 |
|
|
| 22 |
|
|
| 23 |
|
|
| 24 |
|
|
| 25 |
|
|
| 26 |
|
private String downloadSnapshotPrefix; |
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
private String downloadReleasePrefix; |
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
|
| 39 |
|
|
| 40 |
|
private String publishUrlProtocol; |
| 41 |
|
|
| 42 |
|
|
| 43 |
|
|
| 44 |
|
|
| 45 |
|
|
| 46 |
|
|
| 47 |
|
private String publicUrlProtocol; |
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| 51 |
|
|
| 52 |
|
|
| 53 |
|
|
| 54 |
|
|
| 55 |
|
private String downloadPrefix; |
| 56 |
|
|
| 57 |
|
|
| 58 |
|
|
| 59 |
|
|
| 60 |
|
|
| 61 |
|
|
| 62 |
|
private String organizationGroupId; |
| 63 |
|
|
| 64 |
|
|
| 65 |
|
|
| 66 |
|
|
| 67 |
|
|
| 68 |
|
|
| 69 |
|
|
| 70 |
|
private String bucket; |
| 71 |
|
|
| 72 |
|
|
| 73 |
|
|
| 74 |
|
|
| 75 |
|
|
| 76 |
|
|
| 77 |
|
|
| 78 |
|
private String hostname; |
| 79 |
|
|
| 80 |
|
|
| 81 |
|
|
| 82 |
|
|
| 83 |
|
|
| 84 |
|
|
| 85 |
|
|
| 86 |
|
|
| 87 |
|
private MavenProject project; |
| 88 |
|
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
|
| 89 |
0
|
@Override... |
| 90 |
|
public void execute() throws MojoExecutionException, MojoFailureException { |
| 91 |
0
|
UrlBuilder builder = new UrlBuilder(); |
| 92 |
|
|
| 93 |
|
|
| 94 |
0
|
String publicUrl = builder.getPublicUrl(getProject(), this); |
| 95 |
0
|
String publishUrl = builder.getPublishUrl(getProject(), this); |
| 96 |
0
|
String downloadUrl = builder.getDownloadUrl(getProject(), this); |
| 97 |
|
|
| 98 |
|
|
| 99 |
0
|
MavenProject project = getProject(); |
| 100 |
0
|
DistributionManagement dm = project.getDistributionManagement(); |
| 101 |
0
|
Site site = dm.getSite(); |
| 102 |
|
|
| 103 |
|
|
| 104 |
0
|
handlePublicUrl(publicUrl, project); |
| 105 |
0
|
handlePublishUrl(publishUrl, site); |
| 106 |
0
|
handleDownloadUrl(downloadUrl, dm); |
| 107 |
|
|
| 108 |
|
} |
| 109 |
|
|
| 110 |
|
|
| 111 |
|
|
| 112 |
|
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 3 |
Complexity Density: 0.5 |
|
| 113 |
0
|
protected boolean isReplace(final String s, final String token) {... |
| 114 |
0
|
if (StringUtils.isEmpty(s)) { |
| 115 |
0
|
return true; |
| 116 |
|
} |
| 117 |
0
|
int pos = s.indexOf(token); |
| 118 |
0
|
if (pos != -1) { |
| 119 |
0
|
return true; |
| 120 |
|
} |
| 121 |
0
|
return false; |
| 122 |
|
} |
| 123 |
|
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 124 |
0
|
protected void warn(final String pomString, final String calculatedString, final String propertyDescription) {... |
| 125 |
0
|
getLog().warn("****************************************"); |
| 126 |
0
|
getLog().warn(propertyDescription + " mismatch"); |
| 127 |
0
|
getLog().warn("Value from the POM: " + pomString); |
| 128 |
0
|
getLog().warn(" Calculated value: " + calculatedString); |
| 129 |
0
|
getLog().warn("****************************************"); |
| 130 |
|
} |
| 131 |
|
|
| 132 |
|
|
| 133 |
|
|
| 134 |
|
|
|
|
|
| 0% |
Uncovered Elements: 13 (13) |
Complexity: 4 |
Complexity Density: 0.57 |
|
| 135 |
0
|
protected boolean isUrlMatch(final String url1, final String url2) {... |
| 136 |
0
|
if (url1.equals(url2)) { |
| 137 |
0
|
return true; |
| 138 |
|
} |
| 139 |
0
|
if ((url1 + "/").equals(url2)) { |
| 140 |
0
|
return true; |
| 141 |
|
} |
| 142 |
0
|
if (url1.equals(url2 + "/")) { |
| 143 |
0
|
return true; |
| 144 |
|
} |
| 145 |
0
|
return false; |
| 146 |
|
} |
| 147 |
|
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
| 148 |
0
|
protected void handleDownloadUrl(final String downloadUrl, final DistributionManagement dm) {... |
| 149 |
0
|
if (isReplace(dm.getDownloadUrl(), "${kuali.site.download.url}")) { |
| 150 |
0
|
getLog().info("Setting download url to " + downloadUrl + " (was " + dm.getDownloadUrl() + ")"); |
| 151 |
0
|
dm.setDownloadUrl(downloadUrl); |
| 152 |
0
|
return; |
| 153 |
|
} |
| 154 |
0
|
if (!isUrlMatch(downloadUrl, dm.getDownloadUrl())) { |
| 155 |
0
|
warn(dm.getDownloadUrl(), downloadUrl, "Download url"); |
| 156 |
|
} |
| 157 |
0
|
getLog().info("Using download url from the POM " + dm.getDownloadUrl()); |
| 158 |
|
} |
| 159 |
|
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
| 160 |
0
|
protected void handlePublishUrl(final String publishUrl, final Site site) {... |
| 161 |
0
|
if (isReplace(site.getUrl(), "${kuali.site.publish.url}")) { |
| 162 |
0
|
getLog().info("Setting site publication url to " + publishUrl + " (was " + site.getUrl() + ")"); |
| 163 |
0
|
site.setUrl(publishUrl); |
| 164 |
0
|
return; |
| 165 |
|
} |
| 166 |
0
|
if (!isUrlMatch(publishUrl, site.getUrl())) { |
| 167 |
0
|
warn(site.getUrl(), publishUrl, "Site publication url"); |
| 168 |
|
} |
| 169 |
0
|
getLog().info("Using site publication url from the POM " + site.getUrl()); |
| 170 |
|
} |
| 171 |
|
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
| 172 |
0
|
protected void handlePublicUrl(final String publicUrl, final MavenProject project) {... |
| 173 |
0
|
if (isReplace(project.getUrl(), "${kuali.site.public.url}")) { |
| 174 |
0
|
getLog().info("Setting public url to " + publicUrl + " (was " + project.getUrl() + ")"); |
| 175 |
0
|
project.setUrl(publicUrl); |
| 176 |
0
|
return; |
| 177 |
|
} |
| 178 |
0
|
if (!isUrlMatch(publicUrl, project.getUrl())) { |
| 179 |
0
|
warn(project.getUrl(), publicUrl, "Public url"); |
| 180 |
|
} |
| 181 |
0
|
getLog().info("Using public url from the POM " + project.getUrl()); |
| 182 |
|
} |
| 183 |
|
|
| 184 |
|
|
| 185 |
|
@return |
| 186 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 187 |
0
|
public MavenProject getProject() {... |
| 188 |
0
|
return project; |
| 189 |
|
} |
| 190 |
|
|
| 191 |
|
|
| 192 |
|
@param |
| 193 |
|
|
| 194 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 195 |
0
|
public void setProject(final MavenProject project) {... |
| 196 |
0
|
this.project = project; |
| 197 |
|
} |
| 198 |
|
|
| 199 |
|
|
| 200 |
|
@return |
| 201 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 202 |
0
|
@Override... |
| 203 |
|
public String getBucket() { |
| 204 |
0
|
return bucket; |
| 205 |
|
} |
| 206 |
|
|
| 207 |
|
|
| 208 |
|
@param |
| 209 |
|
|
| 210 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 211 |
0
|
public void setBucket(final String bucket) {... |
| 212 |
0
|
this.bucket = bucket; |
| 213 |
|
} |
| 214 |
|
|
| 215 |
|
|
| 216 |
|
@return |
| 217 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 218 |
0
|
@Override... |
| 219 |
|
public String getHostname() { |
| 220 |
0
|
return hostname; |
| 221 |
|
} |
| 222 |
|
|
| 223 |
|
|
| 224 |
|
@param |
| 225 |
|
|
| 226 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 227 |
0
|
public void setHostname(final String hostname) {... |
| 228 |
0
|
this.hostname = hostname; |
| 229 |
|
} |
| 230 |
|
|
| 231 |
|
|
| 232 |
|
@return |
| 233 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 234 |
0
|
@Override... |
| 235 |
|
public String getDownloadPrefix() { |
| 236 |
0
|
return downloadPrefix; |
| 237 |
|
} |
| 238 |
|
|
| 239 |
|
|
| 240 |
|
@param |
| 241 |
|
|
| 242 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 243 |
0
|
public void setDownloadPrefix(final String downloadPrefix) {... |
| 244 |
0
|
this.downloadPrefix = downloadPrefix; |
| 245 |
|
} |
| 246 |
|
|
| 247 |
|
|
| 248 |
|
@return |
| 249 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 250 |
0
|
@Override... |
| 251 |
|
public String getOrganizationGroupId() { |
| 252 |
0
|
return organizationGroupId; |
| 253 |
|
} |
| 254 |
|
|
| 255 |
|
|
| 256 |
|
@param |
| 257 |
|
|
| 258 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 259 |
0
|
public void setOrganizationGroupId(final String parentGroupId) {... |
| 260 |
0
|
this.organizationGroupId = parentGroupId; |
| 261 |
|
} |
| 262 |
|
|
| 263 |
|
|
| 264 |
|
@return |
| 265 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 266 |
0
|
@Override... |
| 267 |
|
public String getPublishUrlProtocol() { |
| 268 |
0
|
return publishUrlProtocol; |
| 269 |
|
} |
| 270 |
|
|
| 271 |
|
|
| 272 |
|
@param |
| 273 |
|
|
| 274 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 275 |
0
|
public void setPublishUrlProtocol(final String publishUrlProtocol) {... |
| 276 |
0
|
this.publishUrlProtocol = publishUrlProtocol; |
| 277 |
|
} |
| 278 |
|
|
| 279 |
|
|
| 280 |
|
@return |
| 281 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 282 |
0
|
@Override... |
| 283 |
|
public String getPublicUrlProtocol() { |
| 284 |
0
|
return publicUrlProtocol; |
| 285 |
|
} |
| 286 |
|
|
| 287 |
|
|
| 288 |
|
@param |
| 289 |
|
|
| 290 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 291 |
0
|
public void setPublicUrlProtocol(final String publicUrlProtocol) {... |
| 292 |
0
|
this.publicUrlProtocol = publicUrlProtocol; |
| 293 |
|
} |
| 294 |
|
|
| 295 |
|
|
| 296 |
|
@return |
| 297 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 298 |
0
|
@Override... |
| 299 |
|
public String getDownloadSnapshotPrefix() { |
| 300 |
0
|
return downloadSnapshotPrefix; |
| 301 |
|
} |
| 302 |
|
|
| 303 |
|
|
| 304 |
|
@param |
| 305 |
|
|
| 306 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 307 |
0
|
public void setDownloadSnapshotPrefix(final String downloadSnapshotPrefix) {... |
| 308 |
0
|
this.downloadSnapshotPrefix = downloadSnapshotPrefix; |
| 309 |
|
} |
| 310 |
|
|
| 311 |
|
|
| 312 |
|
@return |
| 313 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 314 |
0
|
@Override... |
| 315 |
|
public String getDownloadReleasePrefix() { |
| 316 |
0
|
return downloadReleasePrefix; |
| 317 |
|
} |
| 318 |
|
|
| 319 |
|
|
| 320 |
|
@param |
| 321 |
|
|
| 322 |
|
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 323 |
0
|
public void setDownloadReleasePrefix(final String downloadReleasePrefix) {... |
| 324 |
0
|
this.downloadReleasePrefix = downloadReleasePrefix; |
| 325 |
|
} |
| 326 |
|
|
| 327 |
|
} |