| 1 | |
package net.sf.statscm; |
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
import net.sf.statsvn.util.SvnStartupUtils; |
| 20 | |
import net.sf.statsvn.util.SvnVersionMismatchException; |
| 21 | |
import net.sf.statcvs.Messages; |
| 22 | |
import net.sf.statcvs.input.LogSyntaxException; |
| 23 | |
import net.sf.statcvs.output.CommandLineParser; |
| 24 | |
import net.sf.statsvn.output.SvnCommandLineParser; |
| 25 | |
import net.sf.statsvn.output.SvnConfigurationOptions; |
| 26 | |
import net.sf.statcvs.output.ConfigurationException; |
| 27 | |
import org.apache.maven.doxia.sink.Sink; |
| 28 | |
import org.apache.maven.doxia.siterenderer.Renderer; |
| 29 | |
import org.apache.maven.reporting.AbstractMavenReport; |
| 30 | |
import org.apache.maven.reporting.MavenReportException; |
| 31 | |
|
| 32 | |
import java.io.File; |
| 33 | |
import java.io.FileInputStream; |
| 34 | |
import java.io.FileNotFoundException; |
| 35 | |
import java.io.FileOutputStream; |
| 36 | |
import java.io.IOException; |
| 37 | |
import java.util.Locale; |
| 38 | |
import java.util.ResourceBundle; |
| 39 | |
|
| 40 | |
import org.apache.maven.model.Reporting; |
| 41 | |
import org.apache.maven.project.MavenProject; |
| 42 | |
|
| 43 | |
|
| 44 | |
|
| 45 | |
|
| 46 | |
|
| 47 | |
|
| 48 | |
|
| 49 | 27 | public class StatScmMojo extends AbstractMavenReport |
| 50 | |
{ |
| 51 | |
|
| 52 | |
|
| 53 | |
|
| 54 | |
|
| 55 | |
|
| 56 | |
|
| 57 | |
|
| 58 | |
|
| 59 | |
|
| 60 | |
private MavenProject project; |
| 61 | |
|
| 62 | |
|
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
|
| 68 | |
|
| 69 | |
|
| 70 | |
|
| 71 | |
|
| 72 | |
|
| 73 | |
private String[] includes; |
| 74 | |
|
| 75 | |
|
| 76 | |
|
| 77 | |
|
| 78 | |
|
| 79 | |
|
| 80 | |
|
| 81 | |
|
| 82 | |
|
| 83 | |
|
| 84 | |
|
| 85 | |
|
| 86 | |
private String[] excludes; |
| 87 | |
|
| 88 | |
|
| 89 | |
|
| 90 | |
|
| 91 | |
|
| 92 | |
|
| 93 | |
|
| 94 | |
|
| 95 | |
|
| 96 | |
|
| 97 | |
private String[] nonDeveloperLogins; |
| 98 | |
|
| 99 | |
|
| 100 | |
|
| 101 | |
|
| 102 | |
|
| 103 | |
|
| 104 | |
|
| 105 | |
|
| 106 | |
private String cacheDir; |
| 107 | |
|
| 108 | |
|
| 109 | |
|
| 110 | |
|
| 111 | |
|
| 112 | |
|
| 113 | |
|
| 114 | |
|
| 115 | |
|
| 116 | |
|
| 117 | |
|
| 118 | |
|
| 119 | |
|
| 120 | |
|
| 121 | |
|
| 122 | |
|
| 123 | |
|
| 124 | |
|
| 125 | |
|
| 126 | |
|
| 127 | |
|
| 128 | |
|
| 129 | |
private String notesFile; |
| 130 | |
|
| 131 | |
|
| 132 | |
|
| 133 | |
|
| 134 | |
|
| 135 | |
|
| 136 | |
|
| 137 | 27 | private String configFile = "src/site/stat-scm.properties"; |
| 138 | |
|
| 139 | |
|
| 140 | |
|
| 141 | |
|
| 142 | |
|
| 143 | |
|
| 144 | |
|
| 145 | |
private boolean skip; |
| 146 | |
|
| 147 | |
|
| 148 | |
|
| 149 | |
|
| 150 | |
|
| 151 | |
|
| 152 | |
|
| 153 | |
|
| 154 | |
private String title; |
| 155 | |
|
| 156 | |
|
| 157 | |
|
| 158 | |
|
| 159 | 27 | private StatConf statConf = new StatConf(); |
| 160 | |
|
| 161 | |
|
| 162 | |
|
| 163 | |
|
| 164 | |
|
| 165 | |
public void execute() |
| 166 | |
{ |
| 167 | 3 | getLog().error( "StatSCM can not be run directly!" ); |
| 168 | 3 | getLog().info( "Configure it to run with the \"mvn site\" command." ); |
| 169 | 3 | getLog().info( "See: http://sourceforge.net/tracker/index.php?func=detail&aid=1610964&group_id=182522&atid=901553." ); |
| 170 | 3 | } |
| 171 | |
|
| 172 | |
|
| 173 | |
|
| 174 | |
|
| 175 | |
|
| 176 | |
|
| 177 | |
|
| 178 | |
|
| 179 | |
public void executeReport( Locale locale ) throws MavenReportException |
| 180 | |
{ |
| 181 | 6 | if (skip) |
| 182 | |
{ |
| 183 | 3 | getLog().info( getMessage("info.greeting.skip") ); |
| 184 | |
} |
| 185 | |
else |
| 186 | |
{ |
| 187 | |
|
| 188 | 3 | getLog().info( getMessage("info.greeting.ok") ); |
| 189 | |
|
| 190 | |
|
| 191 | |
try |
| 192 | |
{ |
| 193 | 3 | getLog().info( "StatSCM Version:" + getStatSCMVersion() ); |
| 194 | 3 | getLog().info( "Configuring StatXXX" ); |
| 195 | 3 | StatConf.setConfigFile(configFile); |
| 196 | 3 | statConf.configure( project, locale ); |
| 197 | 3 | configFromMojoProperties(); |
| 198 | 3 | getLog().info( "SCM Connection Type :" + statConf.getConnectionType() ); |
| 199 | 3 | getLog().info( "Output Directory :" + this.getOutputDirectory() ); |
| 200 | |
} |
| 201 | 0 | catch ( ConfigurationException e ) |
| 202 | |
{ |
| 203 | 0 | getLog().error( getMessage( "error.config" ), e ); |
| 204 | 0 | return; |
| 205 | 3 | } |
| 206 | |
|
| 207 | |
|
| 208 | 3 | SrcManager scm = new SrcManager(); |
| 209 | 3 | if ( !scm.log( statConf.getBaseDirectory(), getLog(), statConf ) ) |
| 210 | |
{ |
| 211 | 0 | getLog().error( getMessage( "error.scmlog.file_missing" ) ); |
| 212 | 0 | return; |
| 213 | |
} |
| 214 | |
|
| 215 | |
|
| 216 | 3 | if ( !createOutputDirectory() ) |
| 217 | |
{ |
| 218 | 0 | getLog().error( getMessage( "error.ouput.can_not_create_output_folder" ) ); |
| 219 | 0 | return; |
| 220 | |
} |
| 221 | |
|
| 222 | |
|
| 223 | |
try |
| 224 | |
{ |
| 225 | 3 | if ( statConf.isStatSVN() || statConf.isStatCVS() ) |
| 226 | |
{ |
| 227 | 3 | if ( statConf.isStatSVN() ) |
| 228 | |
{ |
| 229 | 3 | doSvnStats(); |
| 230 | |
} |
| 231 | 0 | else if ( statConf.isStatCVS() ) |
| 232 | |
{ |
| 233 | 0 | doCvsStats(); |
| 234 | |
} |
| 235 | 3 | doGenerateReport( getSink() ); |
| 236 | 3 | copyResourceFiles( getOutputDirectory(), getReportingTargetDirectory() ); |
| 237 | |
} |
| 238 | |
else |
| 239 | |
{ |
| 240 | 0 | getLog().error( getMessage( "warn.scm.type_xxx" ) ); |
| 241 | |
} |
| 242 | |
} |
| 243 | 0 | catch ( Exception e ) |
| 244 | |
{ |
| 245 | 0 | getLog().error( getMessage( "error.config" ), e ); |
| 246 | 3 | } |
| 247 | |
} |
| 248 | 6 | } |
| 249 | |
|
| 250 | |
|
| 251 | |
|
| 252 | |
|
| 253 | |
|
| 254 | |
|
| 255 | |
private void doSvnStats() throws MavenReportException |
| 256 | |
{ |
| 257 | 3 | Messages.setPrimaryResource( "net.sf.statsvn.statcvs" ); |
| 258 | |
try |
| 259 | |
{ |
| 260 | 3 | Messages.setPrimaryResource( "net.sf.statsvn.statcvs" ); |
| 261 | 3 | new SvnCommandLineParser( new String[] { statConf.getSCMLogFileName(), "." } ).parse(); |
| 262 | 3 | SvnStartupUtils.checkSvnVersionSufficient(); |
| 263 | 3 | SvnStartupUtils.checkRepoRootAvailable(); |
| 264 | 3 | net.sf.statsvn.Main.generateDefaultHTMLSuite(); |
| 265 | |
} |
| 266 | 0 | catch ( LogSyntaxException e ) |
| 267 | |
{ |
| 268 | 0 | getLog().error( getMessage( "error.scmlog.parsing" ), e ); |
| 269 | 0 | throw new MavenReportException( e.getMessage() ); |
| 270 | |
} |
| 271 | 0 | catch ( IOException e ) |
| 272 | |
{ |
| 273 | 0 | getLog().error( "Error generating Subversion Stats.", e ); |
| 274 | 0 | throw new MavenReportException( e.getMessage() ); |
| 275 | |
} |
| 276 | 0 | catch ( ConfigurationException e ) |
| 277 | |
{ |
| 278 | 0 | getLog().error( getMessage( "error.config" ), e ); |
| 279 | 0 | throw new MavenReportException( e.getMessage() ); |
| 280 | |
|
| 281 | |
} |
| 282 | 0 | catch ( SvnVersionMismatchException e ) |
| 283 | |
{ |
| 284 | 0 | getLog().error( e.getMessage(), e ); |
| 285 | 0 | throw new MavenReportException( e.getMessage() ); |
| 286 | |
} |
| 287 | 0 | catch ( NullPointerException e ) |
| 288 | |
{ |
| 289 | 0 | getLog().warn("Null Pointer: Sometimes happens when local files are not synced with the repository!"); |
| 290 | 0 | getLog().error( e.getMessage(), e ); |
| 291 | |
|
| 292 | 3 | } |
| 293 | 3 | } |
| 294 | |
|
| 295 | |
|
| 296 | |
|
| 297 | |
|
| 298 | |
|
| 299 | |
|
| 300 | |
private void doCvsStats() throws MavenReportException |
| 301 | |
{ |
| 302 | |
|
| 303 | |
try |
| 304 | |
{ |
| 305 | 0 | new CommandLineParser( new String[] { statConf.getSCMLogFileName(), "." } ).parse(); |
| 306 | 0 | net.sf.statcvs.Main.generateDefaultHTMLSuite(); |
| 307 | |
} |
| 308 | 0 | catch ( LogSyntaxException e ) |
| 309 | |
{ |
| 310 | 0 | getLog().error( getMessage( "error.scmlog.parsing" ), e ); |
| 311 | 0 | throw new MavenReportException( e.getMessage() ); |
| 312 | |
} |
| 313 | 0 | catch ( IOException e ) |
| 314 | |
{ |
| 315 | 0 | getLog().error( "Error generating Subversion Stats.", e ); |
| 316 | 0 | throw new MavenReportException( e.getMessage() ); |
| 317 | |
} |
| 318 | 0 | catch ( ConfigurationException e ) |
| 319 | |
{ |
| 320 | 0 | getLog().error( getMessage( "error.config" ), e ); |
| 321 | 0 | throw new MavenReportException( e.getMessage() ); |
| 322 | 0 | } |
| 323 | 0 | } |
| 324 | |
|
| 325 | |
|
| 326 | |
|
| 327 | |
|
| 328 | |
|
| 329 | |
|
| 330 | |
private boolean createOutputDirectory() |
| 331 | |
{ |
| 332 | 3 | File outputDir = new File( getOutputDirectory() ); |
| 333 | 3 | if ( outputDir.exists() ) |
| 334 | |
{ |
| 335 | 3 | if ( outputDir.isDirectory() ) |
| 336 | |
{ |
| 337 | 3 | return true; |
| 338 | |
} |
| 339 | |
else |
| 340 | |
{ |
| 341 | 0 | getLog().error( getMessage( "error.outputDir.file_in_the_way" ) |
| 342 | |
+ outputDir.getAbsolutePath() ); |
| 343 | 0 | return false; |
| 344 | |
} |
| 345 | |
} |
| 346 | |
else |
| 347 | |
{ |
| 348 | 0 | if ( outputDir.mkdirs() ) |
| 349 | |
{ |
| 350 | 0 | return true; |
| 351 | |
} |
| 352 | |
else |
| 353 | |
{ |
| 354 | 0 | getLog().error( "Can not make output directory at: " + outputDir.getAbsolutePath() ); |
| 355 | 0 | return false; |
| 356 | |
} |
| 357 | |
} |
| 358 | |
} |
| 359 | |
|
| 360 | |
|
| 361 | |
|
| 362 | |
|
| 363 | |
|
| 364 | |
|
| 365 | |
private void configFromMojoProperties() throws ConfigurationException |
| 366 | |
{ |
| 367 | 3 | configIncludeExclude(); |
| 368 | 3 | configNonDeveloperLogins(); |
| 369 | 3 | configCacheSettings(); |
| 370 | 3 | configNotesFile(); |
| 371 | 3 | configTitle(); |
| 372 | 3 | } |
| 373 | |
|
| 374 | |
|
| 375 | |
|
| 376 | |
|
| 377 | |
|
| 378 | |
private void configTitle() |
| 379 | |
{ |
| 380 | 3 | if ( title != null ) |
| 381 | |
{ |
| 382 | 0 | String projectName = title.trim(); |
| 383 | 0 | if ( projectName.length() > 0 ) |
| 384 | |
{ |
| 385 | 0 | statConf.setProjectName( projectName ); |
| 386 | |
} |
| 387 | 0 | getLog().info( "Page title: " + statConf.getProjectName() ); |
| 388 | |
} |
| 389 | 3 | } |
| 390 | |
|
| 391 | |
|
| 392 | |
|
| 393 | |
|
| 394 | |
|
| 395 | |
|
| 396 | |
private void configNotesFile() throws ConfigurationException |
| 397 | |
{ |
| 398 | 3 | if ( notesFile != null ) |
| 399 | |
{ |
| 400 | 0 | String filename = notesFile.trim(); |
| 401 | 0 | if ( filename.length() > 0 ) |
| 402 | |
{ |
| 403 | |
try |
| 404 | |
{ |
| 405 | 0 | statConf.setNotesFile( filename ); |
| 406 | 0 | getLog().info( "Notes file: " + filename ); |
| 407 | |
} |
| 408 | 0 | catch ( ConfigurationException e ) |
| 409 | |
{ |
| 410 | 0 | getLog().info( "Notes file: " + filename ); |
| 411 | 0 | throw e; |
| 412 | |
|
| 413 | |
|
| 414 | 0 | } |
| 415 | |
} |
| 416 | |
} |
| 417 | 3 | } |
| 418 | |
|
| 419 | |
|
| 420 | |
|
| 421 | |
|
| 422 | |
|
| 423 | |
|
| 424 | |
private void configCacheSettings() throws ConfigurationException |
| 425 | |
{ |
| 426 | 3 | if ( cacheDir != null ) |
| 427 | |
{ |
| 428 | 0 | String dir = cacheDir.trim(); |
| 429 | 0 | if ( dir.length() > 0 ) |
| 430 | |
{ |
| 431 | |
try |
| 432 | |
{ |
| 433 | 0 | SvnConfigurationOptions.setCacheDir( dir ); |
| 434 | 0 | getLog().info( "Cache directory: " + dir ); |
| 435 | |
} |
| 436 | 0 | catch ( ConfigurationException e ) |
| 437 | |
{ |
| 438 | 0 | getLog().info( "Cache directory: " + dir ); |
| 439 | 0 | throw e; |
| 440 | |
|
| 441 | 0 | } |
| 442 | |
} |
| 443 | |
} |
| 444 | 3 | } |
| 445 | |
|
| 446 | |
|
| 447 | |
|
| 448 | |
|
| 449 | |
|
| 450 | |
private void configIncludeExclude() |
| 451 | |
{ |
| 452 | 3 | String patternList = buildIncludeExcludeString( includes ); |
| 453 | 3 | if ( patternList.length() > 0 ) |
| 454 | |
{ |
| 455 | 0 | statConf.setIncludePattern( patternList ); |
| 456 | 0 | getLog().info( "Includes: " + patternList ); |
| 457 | |
} |
| 458 | |
else |
| 459 | |
{ |
| 460 | 3 | getLog().info( "Include all" ); |
| 461 | |
} |
| 462 | |
|
| 463 | 3 | patternList = buildIncludeExcludeString( excludes ); |
| 464 | 3 | if ( patternList.length() > 0 ) |
| 465 | |
{ |
| 466 | 0 | statConf.setExcludePattern( patternList ); |
| 467 | 0 | getLog().info( "Excludes: " + patternList ); |
| 468 | |
} |
| 469 | |
else |
| 470 | |
{ |
| 471 | 3 | getLog().info( "Exclude none" ); |
| 472 | |
} |
| 473 | 3 | } |
| 474 | |
|
| 475 | |
|
| 476 | |
|
| 477 | |
|
| 478 | |
|
| 479 | |
|
| 480 | |
protected String buildIncludeExcludeString( String[] list ) |
| 481 | |
{ |
| 482 | |
StringBuffer patternList; |
| 483 | 15 | patternList = new StringBuffer(); |
| 484 | 15 | if ( list != null ) |
| 485 | |
{ |
| 486 | 36 | for ( int i = 0; i < list.length; i++ ) |
| 487 | |
{ |
| 488 | 27 | String include = list[i].trim(); |
| 489 | 27 | if ( include.indexOf( ';' ) > 0 ) |
| 490 | |
{ |
| 491 | 3 | getLog().warn( |
| 492 | |
getMessage( "warn.config.include.exclude.delimiter.1" ) + " ':' " |
| 493 | |
+ getMessage( "warn.config.include.exclude.delimiter.2" ) + include ); |
| 494 | |
} |
| 495 | 27 | if ( include.indexOf( ':' ) > 0 ) |
| 496 | |
{ |
| 497 | 3 | getLog().warn( |
| 498 | |
getMessage( "warn.config.include.exclude.delimiter.1" ) + " ';' " |
| 499 | |
+ getMessage( "warn.config.include.exclude.delimiter.2" ) + include ); |
| 500 | |
} |
| 501 | 27 | if ( include.length() > 0 ) |
| 502 | |
{ |
| 503 | 27 | if ( patternList.length() > 0 ) |
| 504 | |
{ |
| 505 | 18 | patternList.append( ';' ); |
| 506 | |
} |
| 507 | 27 | patternList.append( list[i] ); |
| 508 | |
} |
| 509 | |
} |
| 510 | |
} |
| 511 | 15 | return patternList.toString(); |
| 512 | |
} |
| 513 | |
|
| 514 | |
|
| 515 | |
|
| 516 | |
|
| 517 | |
private void configNonDeveloperLogins() |
| 518 | |
{ |
| 519 | 3 | if ( nonDeveloperLogins != null ) |
| 520 | |
{ |
| 521 | 0 | for ( int i = 0; i < nonDeveloperLogins.length; i++ ) |
| 522 | |
{ |
| 523 | 0 | String login = nonDeveloperLogins[i].trim(); |
| 524 | 0 | if ( login.length() > 0 ) |
| 525 | |
{ |
| 526 | 0 | statConf.addNonDeveloperLogin( login ); |
| 527 | 0 | getLog().info( "Non-developer login: " + login ); |
| 528 | |
} |
| 529 | |
} |
| 530 | |
} |
| 531 | 3 | } |
| 532 | |
|
| 533 | |
|
| 534 | |
|
| 535 | |
|
| 536 | |
|
| 537 | |
|
| 538 | |
protected Renderer getSiteRenderer() |
| 539 | |
{ |
| 540 | 0 | return null; |
| 541 | |
} |
| 542 | |
|
| 543 | |
|
| 544 | |
|
| 545 | |
|
| 546 | |
|
| 547 | |
|
| 548 | |
protected String getOutputDirectory() |
| 549 | |
{ |
| 550 | 9 | return StatConf.getOutputDir(); |
| 551 | |
} |
| 552 | |
|
| 553 | |
|
| 554 | |
|
| 555 | |
|
| 556 | |
|
| 557 | |
|
| 558 | |
protected String getReportingTargetDirectory() |
| 559 | |
{ |
| 560 | 9 | String targetBaseDirectory = null; |
| 561 | 9 | Reporting reporting = getProject().getReporting(); |
| 562 | 9 | if ( reporting != null) |
| 563 | |
{ |
| 564 | 3 | targetBaseDirectory = reporting.getOutputDirectory(); |
| 565 | |
} |
| 566 | 9 | if ( targetBaseDirectory == null) |
| 567 | |
{ |
| 568 | 6 | targetBaseDirectory = statConf.getBaseDirectory().getAbsolutePath() |
| 569 | |
+ statConf.FILE_SEPARATOR + "target" |
| 570 | |
+ statConf.FILE_SEPARATOR + "site"; |
| 571 | |
} |
| 572 | 9 | return targetBaseDirectory + statConf.FILE_SEPARATOR + StatConf.STATSCM_DIR_NAME; |
| 573 | |
} |
| 574 | |
|
| 575 | |
|
| 576 | |
|
| 577 | |
|
| 578 | |
|
| 579 | |
|
| 580 | |
public String getOutputName() |
| 581 | |
{ |
| 582 | 0 | return StatConf.STATSCM_DIR_NAME + "/statscm"; |
| 583 | |
} |
| 584 | |
|
| 585 | |
|
| 586 | |
|
| 587 | |
|
| 588 | |
|
| 589 | |
|
| 590 | |
|
| 591 | |
|
| 592 | |
public String getName( Locale locale ) |
| 593 | |
{ |
| 594 | 0 | return "StatSCM"; |
| 595 | |
} |
| 596 | |
|
| 597 | |
|
| 598 | |
|
| 599 | |
|
| 600 | |
|
| 601 | |
|
| 602 | |
|
| 603 | |
public String getDescription( Locale loc ) |
| 604 | |
{ |
| 605 | 0 | return getMessage( "statscm.description" ); |
| 606 | |
} |
| 607 | |
|
| 608 | |
|
| 609 | |
|
| 610 | |
|
| 611 | |
|
| 612 | |
|
| 613 | |
|
| 614 | |
|
| 615 | |
|
| 616 | |
private void copyResourceFiles( String src, String dest ) |
| 617 | |
{ |
| 618 | 3 | getLog().info("Copying resources from " + src + " to " + dest); |
| 619 | |
|
| 620 | 3 | File srcDir = new File( src ); |
| 621 | 3 | if ( !srcDir.isDirectory() ) |
| 622 | |
{ |
| 623 | 0 | getLog().error( "Can not copy reources src is not a directory: " + srcDir.getAbsolutePath() ); |
| 624 | 0 | return; |
| 625 | |
} |
| 626 | 3 | File destDir = new File( dest ); |
| 627 | 3 | if ( !destDir.isDirectory() ) |
| 628 | |
{ |
| 629 | 0 | destDir.mkdirs(); |
| 630 | |
} |
| 631 | |
|
| 632 | 3 | String[] resoures = srcDir.list( new java.io.FilenameFilter() |
| 633 | 3 | { |
| 634 | |
public boolean accept( File dir, String name ) |
| 635 | |
{ |
| 636 | 306 | String[] extensions = { ".png", ".jar", ".txt" }; |
| 637 | 306 | String fileName = name.toLowerCase( Locale.getDefault() ); |
| 638 | 909 | for ( int i = 0; i < extensions.length; i++ ) |
| 639 | |
{ |
| 640 | 711 | if ( fileName.endsWith( extensions[i] ) ) |
| 641 | |
{ |
| 642 | 108 | return true; |
| 643 | |
} |
| 644 | |
} |
| 645 | 198 | return false; |
| 646 | |
|
| 647 | |
} |
| 648 | |
} ); |
| 649 | |
|
| 650 | 111 | for ( int i = 0; i < resoures.length; i++ ) |
| 651 | |
{ |
| 652 | 108 | FileInputStream fis = null; |
| 653 | 108 | FileOutputStream fos = null; |
| 654 | |
try |
| 655 | |
{ |
| 656 | 108 | fis = new FileInputStream( new File( src + statConf.FILE_SEPARATOR + resoures[i] ) ); |
| 657 | 108 | fos = new FileOutputStream( new File( dest + statConf.FILE_SEPARATOR + resoures[i] ) ); |
| 658 | 108 | int b = -1; |
| 659 | 1716327 | while ( ( b = fis.read() ) != -1 ) |
| 660 | |
{ |
| 661 | 1716219 | fos.write( b ); |
| 662 | |
} |
| 663 | |
|
| 664 | 108 | fis.close(); |
| 665 | 108 | fos.close(); |
| 666 | |
} |
| 667 | 0 | catch ( FileNotFoundException e ) |
| 668 | |
{ |
| 669 | 0 | getLog().error( "Can not find file " + resoures[i], e ); |
| 670 | |
} |
| 671 | 0 | catch ( IOException e ) |
| 672 | |
{ |
| 673 | 0 | getLog().error( "Error copying file: " + src + "/" + resoures[i], e ); |
| 674 | |
} |
| 675 | |
finally |
| 676 | |
{ |
| 677 | 0 | try |
| 678 | |
{ |
| 679 | 108 | if ( fis != null ) |
| 680 | |
{ |
| 681 | 108 | fis.close(); |
| 682 | |
} |
| 683 | 108 | if ( fos != null ) |
| 684 | |
{ |
| 685 | 108 | fos.close(); |
| 686 | |
} |
| 687 | |
} |
| 688 | 0 | catch ( IOException e ) |
| 689 | |
{ |
| 690 | 0 | getLog().error( "I/O Exception copying resources.", e ); |
| 691 | |
} |
| 692 | |
finally |
| 693 | |
{ |
| 694 | 108 | fis = null; |
| 695 | 108 | fos = null; |
| 696 | 108 | } |
| 697 | 108 | } |
| 698 | 108 | if ( getLog().isDebugEnabled() ) |
| 699 | |
{ |
| 700 | 0 | getLog().debug( |
| 701 | |
"Copied file " + src + statConf.FILE_SEPARATOR + resoures[i] + " to " + dest |
| 702 | |
+ statConf.FILE_SEPARATOR + resoures[i] ); |
| 703 | |
} |
| 704 | |
} |
| 705 | 3 | } |
| 706 | |
|
| 707 | |
|
| 708 | |
|
| 709 | |
|
| 710 | |
|
| 711 | |
|
| 712 | |
|
| 713 | |
private void doGenerateReport( Sink sink ) |
| 714 | |
{ |
| 715 | |
|
| 716 | |
|
| 717 | 3 | if ( sink == null ) |
| 718 | |
{ |
| 719 | 3 | return; |
| 720 | |
} |
| 721 | |
|
| 722 | 0 | sink.head(); |
| 723 | 0 | sink.title(); |
| 724 | 0 | sink.text( "StatSCM" ); |
| 725 | 0 | sink.title_(); |
| 726 | 0 | sink.head_(); |
| 727 | |
|
| 728 | 0 | sink.body(); |
| 729 | 0 | sink.section1(); |
| 730 | |
|
| 731 | 0 | sink.sectionTitle1(); |
| 732 | 0 | sink.text( getDescription( Locale.getDefault() ) ); |
| 733 | 0 | sink.sectionTitle1_(); |
| 734 | |
|
| 735 | 0 | sink.bold(); |
| 736 | 0 | sink.link( "index.html" ); |
| 737 | 0 | sink.text( "Main page" ); |
| 738 | 0 | sink.link_(); |
| 739 | 0 | sink.bold_(); |
| 740 | |
|
| 741 | 0 | sink.lineBreak(); |
| 742 | |
|
| 743 | |
|
| 744 | |
|
| 745 | 0 | sink.link( "index.html" ); |
| 746 | 0 | sink.figure(); |
| 747 | 0 | sink.figureGraphics( "loc.png" ); |
| 748 | 0 | sink.figure_(); |
| 749 | 0 | sink.link_(); |
| 750 | 0 | sink.lineBreak(); |
| 751 | |
|
| 752 | 0 | sink.text( "Generated using " ); |
| 753 | 0 | sink.link( "http://stat-scm.sourceforge.net/" ); |
| 754 | 0 | sink.text( "StatSCM" + getStatSCMVersion() ); |
| 755 | 0 | sink.link_(); |
| 756 | 0 | sink.text( "." ); |
| 757 | |
|
| 758 | 0 | sink.flush(); |
| 759 | 0 | sink.close(); |
| 760 | 0 | } |
| 761 | |
|
| 762 | |
|
| 763 | |
|
| 764 | |
|
| 765 | |
|
| 766 | |
|
| 767 | |
|
| 768 | |
private String getStatSCMVersion() { |
| 769 | 3 | String versionText = getMessage("statscm.version"); |
| 770 | 3 | if (versionText == null) { |
| 771 | 0 | return ""; |
| 772 | 3 | } else if (versionText.equals("${pom.version}")) { |
| 773 | 0 | return ""; |
| 774 | |
} |
| 775 | |
|
| 776 | 3 | return " (" + versionText +")"; |
| 777 | |
} |
| 778 | |
|
| 779 | |
|
| 780 | |
|
| 781 | |
|
| 782 | |
|
| 783 | |
|
| 784 | |
protected MavenProject getProject() |
| 785 | |
{ |
| 786 | 9 | return project; |
| 787 | |
} |
| 788 | |
|
| 789 | |
|
| 790 | |
|
| 791 | |
|
| 792 | |
|
| 793 | |
|
| 794 | |
public void setProject( MavenProject project ) |
| 795 | |
{ |
| 796 | 12 | this.project = project; |
| 797 | 12 | } |
| 798 | |
|
| 799 | |
public String getMessage(String messageKey) { |
| 800 | 39 | return ResourceBundle.getBundle( "net.sf.statscm.message", statConf.getLocale() ).getString( messageKey ); |
| 801 | |
} |
| 802 | |
|
| 803 | |
void setSkipParameter( boolean b ) |
| 804 | |
{ |
| 805 | 3 | skip = b; |
| 806 | 3 | } |
| 807 | |
|
| 808 | |
public StatConf getStatConf() { |
| 809 | 27 | return statConf; |
| 810 | |
} |
| 811 | |
|
| 812 | |
public void setConfigFileParameter(String configFile) throws ConfigurationException { |
| 813 | 0 | if (configFile != null) { |
| 814 | 0 | this.configFile = configFile; |
| 815 | |
} |
| 816 | 0 | } |
| 817 | |
} |