1 | |
package org.apache.maven.report.projectinfo; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
import org.apache.maven.doxia.sink.Sink; |
23 | |
import org.apache.maven.model.Model; |
24 | |
import org.apache.maven.model.Scm; |
25 | |
import org.apache.maven.plugin.logging.Log; |
26 | |
import org.apache.maven.reporting.AbstractMavenReportRenderer; |
27 | |
import org.apache.maven.scm.manager.NoSuchScmProviderException; |
28 | |
import org.apache.maven.scm.manager.ScmManager; |
29 | |
import org.apache.maven.scm.provider.cvslib.repository.CvsScmProviderRepository; |
30 | |
import org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository; |
31 | |
import org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository; |
32 | |
import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository; |
33 | |
import org.apache.maven.scm.repository.ScmRepository; |
34 | |
import org.apache.maven.scm.repository.ScmRepositoryException; |
35 | |
import org.codehaus.plexus.i18n.I18N; |
36 | |
import org.codehaus.plexus.util.StringUtils; |
37 | |
|
38 | |
import java.util.ArrayList; |
39 | |
import java.util.Iterator; |
40 | |
import java.util.List; |
41 | |
import java.util.Locale; |
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
|
50 | |
|
51 | 4 | public class ScmReport |
52 | |
extends AbstractProjectInfoReport |
53 | |
{ |
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
protected ScmManager scmManager; |
64 | |
|
65 | |
|
66 | |
|
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | |
private String checkoutDirectoryName; |
72 | |
|
73 | |
|
74 | |
|
75 | |
|
76 | |
|
77 | |
|
78 | |
|
79 | |
|
80 | |
private String anonymousConnection; |
81 | |
|
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | |
private String developerConnection; |
90 | |
|
91 | |
|
92 | |
|
93 | |
|
94 | |
|
95 | |
|
96 | |
|
97 | |
private String webAccessUrl; |
98 | |
|
99 | |
|
100 | |
|
101 | |
|
102 | |
|
103 | |
|
104 | |
public String getName( Locale locale ) |
105 | |
{ |
106 | 4 | return i18n.getString( "project-info-report", locale, "report.scm.name" ); |
107 | |
} |
108 | |
|
109 | |
|
110 | |
public String getDescription( Locale locale ) |
111 | |
{ |
112 | 0 | return i18n.getString( "project-info-report", locale, "report.scm.description" ); |
113 | |
} |
114 | |
|
115 | |
|
116 | |
public void executeReport( Locale locale ) |
117 | |
{ |
118 | 4 | ScmRenderer r = new ScmRenderer( getLog(), scmManager, getSink(), getProject().getModel(), i18n, locale, |
119 | |
checkoutDirectoryName, webAccessUrl, anonymousConnection, |
120 | |
developerConnection ); |
121 | |
|
122 | 4 | r.render(); |
123 | 1 | } |
124 | |
|
125 | |
|
126 | |
public String getOutputName() |
127 | |
{ |
128 | 6 | return "source-repository"; |
129 | |
} |
130 | |
|
131 | |
|
132 | |
|
133 | |
|
134 | |
|
135 | |
|
136 | |
|
137 | |
|
138 | 4 | private static class ScmRenderer |
139 | |
extends AbstractMavenReportRenderer |
140 | |
{ |
141 | |
private Log log; |
142 | |
|
143 | |
private Model model; |
144 | |
|
145 | |
private I18N i18n; |
146 | |
|
147 | |
private Locale locale; |
148 | |
|
149 | |
private ScmManager scmManager; |
150 | |
|
151 | |
|
152 | |
|
153 | |
|
154 | |
private String anonymousConnection; |
155 | |
|
156 | |
private String devConnection; |
157 | |
|
158 | |
private String checkoutDirectoryName; |
159 | |
|
160 | |
private String webAccessUrl; |
161 | |
|
162 | |
ScmRenderer( Log log, ScmManager scmManager, Sink sink, Model model, I18N i18n, Locale locale, |
163 | |
String checkoutDirName, String webAccessUrl, String anonymousConnection, String devConnection ) |
164 | |
{ |
165 | 4 | super( sink ); |
166 | |
|
167 | 4 | this.log = log; |
168 | |
|
169 | 4 | this.scmManager = scmManager; |
170 | |
|
171 | 4 | this.model = model; |
172 | |
|
173 | 4 | this.i18n = i18n; |
174 | |
|
175 | 4 | this.locale = locale; |
176 | |
|
177 | 4 | this.checkoutDirectoryName = checkoutDirName; |
178 | |
|
179 | 4 | this.webAccessUrl = webAccessUrl; |
180 | |
|
181 | 4 | this.anonymousConnection = anonymousConnection; |
182 | |
|
183 | 4 | this.devConnection = devConnection; |
184 | |
|
185 | 4 | } |
186 | |
|
187 | |
|
188 | |
public String getTitle() |
189 | |
{ |
190 | 4 | return i18n.getString( "project-info-report", locale, "report.scm.title" ); |
191 | |
} |
192 | |
|
193 | |
|
194 | |
public void renderBody() |
195 | |
{ |
196 | 4 | Scm scm = model.getScm(); |
197 | 4 | if ( scm == null ) |
198 | |
{ |
199 | 0 | startSection( getTitle() ); |
200 | |
|
201 | 0 | paragraph( i18n.getString( "project-info-report", locale, "report.scm.noscm" ) ); |
202 | |
|
203 | 0 | endSection(); |
204 | |
|
205 | 0 | return; |
206 | |
} |
207 | |
|
208 | 4 | if ( StringUtils.isEmpty( anonymousConnection ) && StringUtils.isEmpty( devConnection ) |
209 | |
&& StringUtils.isEmpty( scm.getUrl() ) ) |
210 | |
{ |
211 | 0 | startSection( getTitle() ); |
212 | |
|
213 | 0 | paragraph( i18n.getString( "project-info-report", locale, "report.scm.noscm" ) ); |
214 | |
|
215 | 0 | endSection(); |
216 | |
|
217 | 0 | return; |
218 | |
} |
219 | |
|
220 | 4 | ScmRepository anonymousRepository = getScmRepository( anonymousConnection ); |
221 | 1 | ScmRepository devRepository = getScmRepository( devConnection ); |
222 | |
|
223 | |
|
224 | 1 | renderOverViewSection( anonymousRepository ); |
225 | |
|
226 | |
|
227 | 1 | renderWebAccesSection( webAccessUrl ); |
228 | |
|
229 | |
|
230 | 1 | renderAnonymousAccessSection( anonymousRepository ); |
231 | |
|
232 | |
|
233 | 1 | renderDeveloperAccessSection( devRepository ); |
234 | |
|
235 | |
|
236 | 1 | renderAccessBehindFirewallSection( devRepository ); |
237 | |
|
238 | |
|
239 | 1 | renderAccessThroughProxySection( anonymousRepository, devRepository ); |
240 | 1 | } |
241 | |
|
242 | |
|
243 | |
|
244 | |
|
245 | |
|
246 | |
|
247 | |
private void renderOverViewSection( ScmRepository anonymousRepository ) |
248 | |
{ |
249 | 1 | startSection( i18n.getString( "project-info-report", locale, "report.scm.overview.title" ) ); |
250 | |
|
251 | 1 | if ( isScmSystem( anonymousRepository, "clearcase" ) ) |
252 | |
{ |
253 | 0 | linkPatternedText( i18n.getString( "project-info-report", locale, "report.scm.clearcase.intro" ) ); |
254 | |
} |
255 | 1 | else if ( isScmSystem( anonymousRepository, "cvs" ) ) |
256 | |
{ |
257 | 0 | linkPatternedText( i18n.getString( "project-info-report", locale, "report.scm.cvs.intro" ) ); |
258 | |
} |
259 | 1 | else if ( isScmSystem( anonymousRepository, "perforce" ) ) |
260 | |
{ |
261 | 0 | linkPatternedText( i18n.getString( "project-info-report", locale, "report.scm.perforce.intro" ) ); |
262 | |
} |
263 | 1 | else if ( isScmSystem( anonymousRepository, "starteam" ) ) |
264 | |
{ |
265 | 0 | linkPatternedText( i18n.getString( "project-info-report", locale, "report.scm.starteam.intro" ) ); |
266 | |
} |
267 | 1 | else if ( isScmSystem( anonymousRepository, "svn" ) ) |
268 | |
{ |
269 | 0 | linkPatternedText( i18n.getString( "project-info-report", locale, "report.scm.svn.intro" ) ); |
270 | |
} |
271 | |
else |
272 | |
{ |
273 | 1 | paragraph( i18n.getString( "project-info-report", locale, "report.scm.general.intro" ) ); |
274 | |
} |
275 | |
|
276 | 1 | endSection(); |
277 | 1 | } |
278 | |
|
279 | |
|
280 | |
|
281 | |
|
282 | |
|
283 | |
|
284 | |
private void renderWebAccesSection( String scmUrl ) |
285 | |
{ |
286 | 1 | startSection( i18n.getString( "project-info-report", locale, "report.scm.webaccess.title" ) ); |
287 | |
|
288 | 1 | if ( StringUtils.isEmpty( scmUrl ) ) |
289 | |
{ |
290 | 1 | paragraph( i18n.getString( "project-info-report", locale, "report.scm.webaccess.nourl" ) ); |
291 | |
} |
292 | |
else |
293 | |
{ |
294 | 0 | paragraph( i18n.getString( "project-info-report", locale, "report.scm.webaccess.url" ) ); |
295 | |
|
296 | 0 | verbatimLink( scmUrl, scmUrl ); |
297 | |
} |
298 | |
|
299 | 1 | endSection(); |
300 | 1 | } |
301 | |
|
302 | |
|
303 | |
|
304 | |
|
305 | |
|
306 | |
|
307 | |
|
308 | |
private void renderAnonymousAccessSection( ScmRepository anonymousRepository ) |
309 | |
{ |
310 | 1 | if ( isScmSystem( anonymousRepository, "clearcase" ) || isScmSystem( anonymousRepository, "perforce" ) |
311 | |
|| isScmSystem( anonymousRepository, "starteam" ) || StringUtils.isEmpty( anonymousConnection ) ) |
312 | |
{ |
313 | 1 | return; |
314 | |
} |
315 | |
|
316 | 0 | startSection( i18n.getString( "project-info-report", locale, "report.scm.anonymousaccess.title" ) ); |
317 | |
|
318 | 0 | if ( anonymousRepository != null && isScmSystem( anonymousRepository, "cvs" ) ) |
319 | |
{ |
320 | 0 | CvsScmProviderRepository cvsRepo = (CvsScmProviderRepository) anonymousRepository |
321 | |
.getProviderRepository(); |
322 | |
|
323 | 0 | anonymousAccessCVS( cvsRepo ); |
324 | |
} |
325 | 0 | else if ( anonymousRepository != null && isScmSystem( anonymousRepository, "svn" ) ) |
326 | |
{ |
327 | 0 | SvnScmProviderRepository svnRepo = (SvnScmProviderRepository) anonymousRepository |
328 | |
.getProviderRepository(); |
329 | |
|
330 | 0 | anonymousAccessSVN( svnRepo ); |
331 | |
} |
332 | |
else |
333 | |
{ |
334 | 0 | paragraph( i18n.getString( "project-info-report", locale, |
335 | |
"report.scm.anonymousaccess.general.intro" ) ); |
336 | |
|
337 | 0 | verbatimText( anonymousConnection.substring( 4 ) ); |
338 | |
} |
339 | |
|
340 | 0 | endSection(); |
341 | 0 | } |
342 | |
|
343 | |
|
344 | |
|
345 | |
|
346 | |
|
347 | |
|
348 | |
private void renderDeveloperAccessSection( ScmRepository devRepository ) |
349 | |
{ |
350 | 1 | if ( StringUtils.isEmpty( devConnection ) ) |
351 | |
{ |
352 | 1 | return; |
353 | |
} |
354 | |
|
355 | 0 | startSection( i18n.getString( "project-info-report", locale, "report.scm.devaccess.title" ) ); |
356 | |
|
357 | 0 | if ( devRepository != null && isScmSystem( devRepository, "clearcase" ) ) |
358 | |
{ |
359 | 0 | developerAccessClearCase(); |
360 | |
} |
361 | 0 | else if ( devRepository != null && isScmSystem( devRepository, "cvs" ) ) |
362 | |
{ |
363 | 0 | CvsScmProviderRepository cvsRepo = (CvsScmProviderRepository) devRepository.getProviderRepository(); |
364 | |
|
365 | 0 | developerAccessCVS( cvsRepo ); |
366 | |
} |
367 | 0 | else if ( devRepository != null && isScmSystem( devRepository, "perforce" ) ) |
368 | |
{ |
369 | 0 | PerforceScmProviderRepository perforceRepo = (PerforceScmProviderRepository) devRepository |
370 | |
.getProviderRepository(); |
371 | |
|
372 | 0 | developerAccessPerforce( perforceRepo ); |
373 | |
} |
374 | 0 | else if ( devRepository != null && isScmSystem( devRepository, "starteam" ) ) |
375 | |
{ |
376 | 0 | StarteamScmProviderRepository starteamRepo = (StarteamScmProviderRepository) devRepository |
377 | |
.getProviderRepository(); |
378 | |
|
379 | 0 | developerAccessStarteam( starteamRepo ); |
380 | |
} |
381 | 0 | else if ( devRepository != null && isScmSystem( devRepository, "svn" ) ) |
382 | |
{ |
383 | 0 | SvnScmProviderRepository svnRepo = (SvnScmProviderRepository) devRepository.getProviderRepository(); |
384 | |
|
385 | 0 | developerAccessSVN( svnRepo ); |
386 | |
} |
387 | |
else |
388 | |
{ |
389 | 0 | paragraph( i18n.getString( "project-info-report", locale, "report.scm.devaccess.general.intro" ) ); |
390 | |
|
391 | 0 | verbatimText( devConnection.substring( 4 ) ); |
392 | |
} |
393 | |
|
394 | 0 | endSection(); |
395 | 0 | } |
396 | |
|
397 | |
|
398 | |
|
399 | |
|
400 | |
|
401 | |
|
402 | |
private void renderAccessBehindFirewallSection( ScmRepository devRepository ) |
403 | |
{ |
404 | 1 | startSection( i18n.getString( "project-info-report", locale, "report.scm.accessbehindfirewall.title" ) ); |
405 | |
|
406 | 1 | if ( devRepository != null && isScmSystem( devRepository, "svn" ) ) |
407 | |
{ |
408 | 0 | SvnScmProviderRepository svnRepo = (SvnScmProviderRepository) devRepository.getProviderRepository(); |
409 | |
|
410 | 0 | paragraph( i18n.getString( "project-info-report", locale, |
411 | |
"report.scm.accessbehindfirewall.svn.intro" ) ); |
412 | |
|
413 | 0 | StringBuffer sb = new StringBuffer(); |
414 | 0 | sb.append( "$ svn checkout " ).append( svnRepo.getUrl() ); |
415 | 0 | sb.append( " " ).append( checkoutDirectoryName ); |
416 | 0 | verbatimText( sb.toString() ); |
417 | |
} |
418 | 1 | else if ( devRepository != null && isScmSystem( devRepository, "cvs" ) ) |
419 | |
{ |
420 | 0 | linkPatternedText( i18n.getString( "project-info-report", locale, |
421 | |
"report.scm.accessbehindfirewall.cvs.intro" ) ); |
422 | |
} |
423 | |
else |
424 | |
{ |
425 | 1 | paragraph( i18n.getString( "project-info-report", locale, |
426 | |
"report.scm.accessbehindfirewall.general.intro" ) ); |
427 | |
} |
428 | |
|
429 | 1 | endSection(); |
430 | 1 | } |
431 | |
|
432 | |
|
433 | |
|
434 | |
|
435 | |
|
436 | |
|
437 | |
|
438 | |
private void renderAccessThroughProxySection( ScmRepository anonymousRepository, ScmRepository devRepository ) |
439 | |
{ |
440 | 1 | if ( isScmSystem( anonymousRepository, "svn" ) || isScmSystem( devRepository, "svn" ) ) |
441 | |
{ |
442 | 0 | startSection( i18n.getString( "project-info-report", locale, |
443 | |
"report.scm.accessthroughtproxy.title" ) ); |
444 | |
|
445 | 0 | paragraph( i18n.getString( "project-info-report", locale, |
446 | |
"report.scm.accessthroughtproxy.svn.intro1" ) ); |
447 | 0 | paragraph( i18n.getString( "project-info-report", locale, |
448 | |
"report.scm.accessthroughtproxy.svn.intro2" ) ); |
449 | 0 | paragraph( i18n.getString( "project-info-report", locale, |
450 | |
"report.scm.accessthroughtproxy.svn.intro3" ) ); |
451 | |
|
452 | 0 | StringBuffer sb = new StringBuffer(); |
453 | 0 | sb.append( "[global]" ); |
454 | 0 | sb.append( "\n" ); |
455 | 0 | sb.append( "http-proxy-host = your.proxy.name" ).append( "\n" ); |
456 | 0 | sb.append( "http-proxy-port = 3128" ).append( "\n" ); |
457 | 0 | verbatimText( sb.toString() ); |
458 | |
|
459 | 0 | endSection(); |
460 | |
} |
461 | 1 | } |
462 | |
|
463 | |
|
464 | |
|
465 | |
|
466 | |
|
467 | |
|
468 | |
|
469 | |
|
470 | |
private void developerAccessClearCase() |
471 | |
{ |
472 | 0 | paragraph( i18n.getString( "project-info-report", locale, "report.scm.devaccess.clearcase.intro" ) ); |
473 | |
|
474 | 0 | StringBuffer command = new StringBuffer(); |
475 | 0 | command.append( "$ cleartool checkout " ); |
476 | |
|
477 | 0 | verbatimText( command.toString() ); |
478 | 0 | } |
479 | |
|
480 | |
|
481 | |
|
482 | |
|
483 | |
|
484 | |
|
485 | |
|
486 | |
|
487 | |
|
488 | |
|
489 | |
|
490 | |
|
491 | |
private void anonymousAccessCVS( CvsScmProviderRepository cvsRepo ) |
492 | |
{ |
493 | 0 | paragraph( i18n.getString( "project-info-report", locale, "report.scm.anonymousaccess.cvs.intro" ) ); |
494 | |
|
495 | 0 | StringBuffer command = new StringBuffer(); |
496 | 0 | command.append( "$ cvs -d " ).append( cvsRepo.getCvsRoot() ).append( " login" ); |
497 | 0 | command.append( "\n" ); |
498 | 0 | command.append( "$ cvs -z3 -d " ).append( cvsRepo.getCvsRoot() ); |
499 | 0 | command.append( " co " ).append( cvsRepo.getModule() ); |
500 | |
|
501 | 0 | verbatimText( command.toString() ); |
502 | 0 | } |
503 | |
|
504 | |
|
505 | |
|
506 | |
|
507 | |
|
508 | |
|
509 | |
|
510 | |
|
511 | |
|
512 | |
|
513 | |
private void developerAccessCVS( CvsScmProviderRepository cvsRepo ) |
514 | |
{ |
515 | 0 | paragraph( i18n.getString( "project-info-report", locale, "report.scm.devaccess.cvs.intro" ) ); |
516 | |
|
517 | |
|
518 | 0 | String cvsRoot = StringUtils.replace( cvsRepo.getCvsRoot(), cvsRepo.getUser(), "username" ); |
519 | |
|
520 | 0 | StringBuffer command = new StringBuffer(); |
521 | 0 | command.append( "$ cvs -d " ).append( cvsRoot ).append( " login" ); |
522 | 0 | command.append( "\n" ); |
523 | 0 | command.append( "$ cvs -z3 -d " ).append( cvsRoot ).append( " co " ).append( cvsRepo.getModule() ); |
524 | |
|
525 | 0 | verbatimText( command.toString() ); |
526 | 0 | } |
527 | |
|
528 | |
|
529 | |
|
530 | |
|
531 | |
|
532 | |
|
533 | |
|
534 | |
|
535 | |
|
536 | |
|
537 | |
|
538 | |
|
539 | |
private void developerAccessPerforce( PerforceScmProviderRepository perforceRepo ) |
540 | |
{ |
541 | 0 | paragraph( i18n.getString( "project-info-report", locale, "report.scm.devaccess.perforce.intro" ) ); |
542 | |
|
543 | 0 | StringBuffer command = new StringBuffer(); |
544 | 0 | command.append( "$ p4" ); |
545 | 0 | if ( !StringUtils.isEmpty( perforceRepo.getHost() ) ) |
546 | |
{ |
547 | 0 | command.append( " -H " ).append( perforceRepo.getHost() ); |
548 | |
} |
549 | 0 | if ( perforceRepo.getPort() > 0 ) |
550 | |
{ |
551 | 0 | command.append( " -p " ).append( perforceRepo.getPort() ); |
552 | |
} |
553 | 0 | command.append( " -u username" ); |
554 | 0 | command.append( " -P password" ); |
555 | 0 | command.append( " " ); |
556 | 0 | command.append( perforceRepo.getPath() ); |
557 | 0 | command.append( "\n" ); |
558 | 0 | command.append( "$ p4 submit -c \"A comment\"" ); |
559 | |
|
560 | 0 | verbatimText( command.toString() ); |
561 | 0 | } |
562 | |
|
563 | |
|
564 | |
|
565 | |
|
566 | |
|
567 | |
|
568 | |
|
569 | |
|
570 | |
|
571 | |
|
572 | |
|
573 | |
private void developerAccessStarteam( StarteamScmProviderRepository starteamRepo ) |
574 | |
{ |
575 | 0 | paragraph( i18n.getString( "project-info-report", locale, "report.scm.devaccess.starteam.intro" ) ); |
576 | |
|
577 | 0 | StringBuffer command = new StringBuffer(); |
578 | |
|
579 | |
|
580 | 0 | String fullUrl = StringUtils.replace( starteamRepo.getFullUrl(), starteamRepo.getUser(), "username" ); |
581 | 0 | fullUrl = StringUtils.replace( fullUrl, starteamRepo.getPassword(), "password" ); |
582 | |
|
583 | 0 | command.append( "$ stcmd co -x -nologo -stop -p " ); |
584 | 0 | command.append( fullUrl ); |
585 | 0 | command.append( " -is" ); |
586 | 0 | command.append( "\n" ); |
587 | 0 | command.append( "$ stcmd ci -x -nologo -stop -p " ); |
588 | 0 | command.append( fullUrl ); |
589 | 0 | command.append( " -f NCI -is" ); |
590 | |
|
591 | 0 | verbatimText( command.toString() ); |
592 | 0 | } |
593 | |
|
594 | |
|
595 | |
|
596 | |
|
597 | |
|
598 | |
|
599 | |
|
600 | |
|
601 | |
|
602 | |
|
603 | |
|
604 | |
private void anonymousAccessSVN( SvnScmProviderRepository svnRepo ) |
605 | |
{ |
606 | 0 | paragraph( i18n.getString( "project-info-report", locale, "report.scm.anonymousaccess.svn.intro" ) ); |
607 | |
|
608 | 0 | StringBuffer sb = new StringBuffer(); |
609 | 0 | sb.append( "$ svn checkout " ).append( svnRepo.getUrl() ).append( " " ).append( checkoutDirectoryName ); |
610 | |
|
611 | 0 | verbatimText( sb.toString() ); |
612 | 0 | } |
613 | |
|
614 | |
|
615 | |
|
616 | |
|
617 | |
|
618 | |
|
619 | |
|
620 | |
|
621 | |
|
622 | |
|
623 | |
private void developerAccessSVN( SvnScmProviderRepository svnRepo ) |
624 | |
{ |
625 | 0 | if ( svnRepo.getUrl() != null ) |
626 | |
{ |
627 | 0 | if ( svnRepo.getUrl().startsWith( "https://" ) ) |
628 | |
{ |
629 | 0 | paragraph( i18n.getString( "project-info-report", locale, |
630 | |
"report.scm.devaccess.svn.intro1.https" ) ); |
631 | |
} |
632 | 0 | else if ( svnRepo.getUrl().startsWith( "svn://" ) ) |
633 | |
{ |
634 | 0 | paragraph( i18n.getString( "project-info-report", locale, |
635 | |
"report.scm.devaccess.svn.intro1.svn" ) ); |
636 | |
} |
637 | 0 | else if ( svnRepo.getUrl().startsWith( "svn+ssh://" ) ) |
638 | |
{ |
639 | 0 | paragraph( i18n.getString( "project-info-report", locale, |
640 | |
"report.scm.devaccess.svn.intro1.svnssh" ) ); |
641 | |
} |
642 | |
else |
643 | |
{ |
644 | 0 | paragraph( i18n.getString( "project-info-report", locale, |
645 | |
"report.scm.devaccess.svn.intro1.other" ) ); |
646 | |
} |
647 | |
} |
648 | |
|
649 | 0 | StringBuffer sb = new StringBuffer(); |
650 | |
|
651 | 0 | sb.append( "$ svn checkout " ).append( svnRepo.getUrl() ).append( " " ).append( checkoutDirectoryName ); |
652 | |
|
653 | 0 | verbatimText( sb.toString() ); |
654 | |
|
655 | 0 | paragraph( i18n.getString( "project-info-report", locale, "report.scm.devaccess.svn.intro2" ) ); |
656 | |
|
657 | 0 | sb = new StringBuffer(); |
658 | 0 | sb.append( "$ svn commit --username your-username -m \"A message\"" ); |
659 | |
|
660 | 0 | verbatimText( sb.toString() ); |
661 | 0 | } |
662 | |
|
663 | |
|
664 | |
|
665 | |
|
666 | |
|
667 | |
|
668 | |
|
669 | |
public ScmRepository getScmRepository( String scmUrl ) |
670 | |
{ |
671 | 5 | if ( StringUtils.isEmpty( scmUrl ) ) |
672 | |
{ |
673 | 2 | return null; |
674 | |
} |
675 | |
|
676 | 3 | ScmRepository repo = null; |
677 | 3 | List messages = new ArrayList(); |
678 | |
try |
679 | |
{ |
680 | 3 | messages.addAll( scmManager.validateScmRepository( scmUrl ) ); |
681 | |
} |
682 | 2 | catch ( Exception e ) |
683 | |
{ |
684 | 2 | messages.add( e.getMessage() ); |
685 | 1 | } |
686 | |
|
687 | 3 | if ( messages.size() > 0 ) |
688 | |
{ |
689 | 3 | StringBuffer sb = new StringBuffer(); |
690 | 3 | boolean isIntroAdded = false; |
691 | 3 | for ( Iterator it = messages.iterator(); it.hasNext(); ) |
692 | |
{ |
693 | 3 | String msg = it.next().toString(); |
694 | |
|
695 | |
|
696 | |
|
697 | 3 | if ( msg.startsWith( "No such provider" ) ) |
698 | |
{ |
699 | 0 | continue; |
700 | |
} |
701 | |
|
702 | 3 | if ( !isIntroAdded ) |
703 | |
{ |
704 | 3 | sb.append( "This SCM url '" + scmUrl + "' is invalid due to the following errors:" ); |
705 | 3 | sb.append( "\n" ); |
706 | 3 | isIntroAdded = true; |
707 | |
} |
708 | 3 | sb.append( " * " ); |
709 | 3 | sb.append( msg ); |
710 | 3 | sb.append( "\n" ); |
711 | |
} |
712 | |
|
713 | 3 | if ( StringUtils.isNotEmpty( sb.toString() ) ) |
714 | |
{ |
715 | 3 | sb.append( "For more information about SCM URL Format, please refer to: " |
716 | |
+ "http://maven.apache.org/scm/scm-url-format.html" ); |
717 | |
|
718 | 3 | throw new IllegalArgumentException( sb.toString() ); |
719 | |
} |
720 | |
} |
721 | |
|
722 | |
try |
723 | |
{ |
724 | 0 | repo = scmManager.makeScmRepository( scmUrl ); |
725 | |
} |
726 | 0 | catch ( NoSuchScmProviderException e ) |
727 | |
{ |
728 | 0 | if ( log.isDebugEnabled() ) |
729 | |
{ |
730 | 0 | log.debug( e.getMessage(), e ); |
731 | |
} |
732 | |
} |
733 | 0 | catch ( ScmRepositoryException e ) |
734 | |
{ |
735 | 0 | if ( log.isDebugEnabled() ) |
736 | |
{ |
737 | 0 | log.debug( e.getMessage(), e ); |
738 | |
} |
739 | |
} |
740 | 0 | catch ( Exception e ) |
741 | |
{ |
742 | |
|
743 | 0 | if ( log.isDebugEnabled() ) |
744 | |
{ |
745 | 0 | log.debug( e.getMessage(), e ); |
746 | |
} |
747 | 0 | } |
748 | |
|
749 | 0 | return repo; |
750 | |
} |
751 | |
|
752 | |
|
753 | |
|
754 | |
|
755 | |
|
756 | |
|
757 | |
|
758 | |
|
759 | |
|
760 | |
|
761 | |
|
762 | |
|
763 | |
private static boolean isScmSystem( ScmRepository scmRepository, String scmProvider ) |
764 | |
{ |
765 | 10 | if ( StringUtils.isEmpty( scmProvider ) ) |
766 | |
{ |
767 | 0 | return false; |
768 | |
} |
769 | |
|
770 | 10 | if ( scmRepository != null && scmProvider.equalsIgnoreCase( scmRepository.getProvider() ) ) |
771 | |
{ |
772 | 0 | return true; |
773 | |
} |
774 | |
|
775 | 10 | return false; |
776 | |
} |
777 | |
} |
778 | |
} |