1 package org.apache.maven.plugins.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.plugins.checkstyle.CheckstyleReport;
26 import org.apache.maven.plugins.checkstyle.exec.CheckstyleResults;
27 import org.apache.maven.reporting.MavenReportException;
28 import org.apache.velocity.VelocityContext;
29 import org.apache.velocity.context.Context;
30 import org.apache.velocity.exception.ResourceNotFoundException;
31 import org.apache.velocity.exception.VelocityException;
32 import org.codehaus.plexus.component.annotations.Component;
33 import org.codehaus.plexus.component.annotations.Requirement;
34 import org.codehaus.plexus.util.StringUtils;
35 import org.codehaus.plexus.velocity.VelocityComponent;
36
37 import com.puppycrawl.tools.checkstyle.api.SeverityLevel;
38
39
40
41
42
43 @Component( role = CheckstyleRssGenerator.class, hint = "default" )
44 @Deprecated
45 public class DefaultCheckstyleRssGenerator
46 implements CheckstyleRssGenerator
47 {
48 @Requirement
49 private VelocityComponent velocityComponent;
50
51 @Override
52 public void generateRSS( CheckstyleResults results, CheckstyleRssGeneratorRequest checkstyleRssGeneratorRequest )
53 throws MavenReportException
54 {
55
56 VelocityTemplate vtemplate = new VelocityTemplate( velocityComponent, CheckstyleReport.PLUGIN_RESOURCES );
57 vtemplate.setLog( checkstyleRssGeneratorRequest.getLog() );
58
59 Context context = new VelocityContext();
60 context.put( "results", results );
61 context.put( "project", checkstyleRssGeneratorRequest.getMavenProject() );
62 context.put( "copyright", checkstyleRssGeneratorRequest.getCopyright() );
63 context.put( "levelInfo", SeverityLevel.INFO );
64 context.put( "levelWarning", SeverityLevel.WARNING );
65 context.put( "levelError", SeverityLevel.ERROR );
66 context.put( "stringutils", new StringUtils() );
67
68 try
69 {
70 vtemplate.generate( checkstyleRssGeneratorRequest.getOutputDirectory().getPath() + "/checkstyle.rss",
71 "checkstyle-rss.vm", context );
72 }
73 catch ( ResourceNotFoundException e )
74 {
75 throw new MavenReportException( "Unable to find checkstyle-rss.vm resource.", e );
76 }
77 catch ( MojoExecutionException | IOException | VelocityException e )
78 {
79 throw new MavenReportException( "Unable to generate checkstyle.rss.", e );
80 }
81 }
82
83 }