| 1 | |
package org.apache.maven.plugin.checkstyle.rss; |
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
|
| 20 | |
|
| 21 | |
|
| 22 | |
import java.io.IOException; |
| 23 | |
|
| 24 | |
import org.apache.maven.plugin.MojoExecutionException; |
| 25 | |
import org.apache.maven.plugin.checkstyle.CheckstyleReport; |
| 26 | |
import org.apache.maven.plugin.checkstyle.CheckstyleResults; |
| 27 | |
import org.apache.maven.plugin.checkstyle.VelocityTemplate; |
| 28 | |
import org.apache.maven.reporting.MavenReportException; |
| 29 | |
import org.apache.velocity.VelocityContext; |
| 30 | |
import org.apache.velocity.context.Context; |
| 31 | |
import org.apache.velocity.exception.ResourceNotFoundException; |
| 32 | |
import org.apache.velocity.exception.VelocityException; |
| 33 | |
import org.codehaus.plexus.util.StringUtils; |
| 34 | |
import org.codehaus.plexus.velocity.VelocityComponent; |
| 35 | |
|
| 36 | |
import com.puppycrawl.tools.checkstyle.api.SeverityLevel; |
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | |
|
| 42 | |
|
| 43 | |
|
| 44 | 0 | public class DefaultCheckstyleRssGenerator |
| 45 | |
implements CheckstyleRssGenerator |
| 46 | |
{ |
| 47 | |
|
| 48 | |
|
| 49 | |
|
| 50 | |
|
| 51 | |
private VelocityComponent velocityComponent; |
| 52 | |
|
| 53 | |
|
| 54 | |
|
| 55 | |
|
| 56 | |
|
| 57 | |
public void generateRSS( CheckstyleResults results, CheckstyleRssGeneratorRequest checkstyleRssGeneratorRequest ) |
| 58 | |
throws MavenReportException |
| 59 | |
{ |
| 60 | |
|
| 61 | 0 | VelocityTemplate vtemplate = new VelocityTemplate( velocityComponent, CheckstyleReport.PLUGIN_RESOURCES ); |
| 62 | 0 | vtemplate.setLog( checkstyleRssGeneratorRequest.getLog() ); |
| 63 | |
|
| 64 | 0 | Context context = new VelocityContext(); |
| 65 | 0 | context.put( "results", results ); |
| 66 | 0 | context.put( "project", checkstyleRssGeneratorRequest.getMavenProject() ); |
| 67 | 0 | context.put( "copyright", checkstyleRssGeneratorRequest.getCopyright() ); |
| 68 | 0 | context.put( "levelInfo", SeverityLevel.INFO ); |
| 69 | 0 | context.put( "levelWarning", SeverityLevel.WARNING ); |
| 70 | 0 | context.put( "levelError", SeverityLevel.ERROR ); |
| 71 | 0 | context.put( "stringutils", new StringUtils() ); |
| 72 | |
|
| 73 | |
try |
| 74 | |
{ |
| 75 | 0 | vtemplate.generate( checkstyleRssGeneratorRequest.getOutputDirectory().getPath() + "/checkstyle.rss", "checkstyle-rss.vm", context ); |
| 76 | |
} |
| 77 | 0 | catch ( ResourceNotFoundException e ) |
| 78 | |
{ |
| 79 | 0 | throw new MavenReportException( "Unable to find checkstyle-rss.vm resource.", e ); |
| 80 | |
} |
| 81 | 0 | catch ( MojoExecutionException e ) |
| 82 | |
{ |
| 83 | 0 | throw new MavenReportException( "Unable to generate checkstyle.rss.", e ); |
| 84 | |
} |
| 85 | 0 | catch ( VelocityException e ) |
| 86 | |
{ |
| 87 | 0 | throw new MavenReportException( "Unable to generate checkstyle.rss.", e ); |
| 88 | |
} |
| 89 | 0 | catch ( IOException e ) |
| 90 | |
{ |
| 91 | 0 | throw new MavenReportException( "Unable to generate checkstyle.rss.", e ); |
| 92 | 0 | } |
| 93 | 0 | } |
| 94 | |
|
| 95 | |
} |