1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package nl.geodienstencentrum.maven.plugin.sass.report;
17
18 import java.io.File;
19 import java.util.Collections;
20 import java.util.List;
21 import java.util.Locale;
22 import java.util.Map;
23 import java.util.ResourceBundle;
24 import nl.geodienstencentrum.maven.plugin.sass.Resource;
25 import org.apache.maven.doxia.siterenderer.Renderer;
26 import org.apache.maven.plugins.annotations.Component;
27 import org.apache.maven.plugins.annotations.Execute;
28 import org.apache.maven.plugins.annotations.LifecyclePhase;
29 import org.apache.maven.plugins.annotations.Mojo;
30 import org.apache.maven.plugins.annotations.Parameter;
31 import org.apache.maven.plugins.annotations.ResolutionScope;
32 import org.apache.maven.project.MavenProject;
33 import org.apache.maven.reporting.AbstractMavenReport;
34
35
36
37
38
39
40
41 @Mojo(name = "scss-lint-report",
42 defaultPhase = LifecyclePhase.SITE,
43 requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME,
44 threadSafe = false)
45 @Execute(goal = "scss-lint"
46
47 )
48 public class SCSSLintReportMojo extends AbstractMavenReport {
49
50
51
52
53
54
55 @Parameter
56 private Map<String, String> sassOptions;
57
58
59
60
61
62
63
64 @Parameter(defaultValue = "${basedir}/src/main/sass", property = "sassSourceDirectory")
65 private File sassSourceDirectory;
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95 @Parameter
96 private List<Resource> resources = Collections.emptyList();
97
98
99
100
101 @Parameter(defaultValue = "false")
102 private boolean failOnError;
103
104
105
106
107
108
109 @Parameter(defaultValue = "scss-lint", property = "outputName", required = true)
110 private String outputName;
111
112
113
114
115
116
117 @Parameter(defaultValue = "${project.build.directory}/site/", required = true)
118 private File outputDirectory;
119
120 @Parameter(defaultValue = "${project}", readonly = true, required = true)
121 private MavenProject project;
122
123 @Component
124 private Renderer siteRenderer;
125
126
127
128
129
130
131 @Parameter(defaultValue = "false")
132 private boolean skip;
133
134
135
136
137
138
139
140
141
142 @Override
143 public void executeReport(final Locale locale) {
144 if (this.skip) {
145 return;
146 }
147 try {
148 final SCSSLintReportGeneratorport/SCSSLintReportGenerator.html#SCSSLintReportGenerator">SCSSLintReportGenerator generator = new SCSSLintReportGenerator(
149 getSink(),
150 this.getDescription(locale),
151 new File(getProject().getBasedir() + "/target", "scss-lint.xml"),
152 getLog());
153 generator.generateReport();
154 } catch (Exception t) {
155 getLog().error("Error during SCSS Lint report generation", t);
156 if (failOnError) {
157 throw t;
158 }
159 }
160 }
161
162 @Override
163 protected Renderer getSiteRenderer() {
164 return siteRenderer;
165 }
166
167 @Override
168 protected String getOutputDirectory() {
169 return outputDirectory.getAbsolutePath();
170 }
171
172 @Override
173 public void setReportOutputDirectory(final File reportOutputDirectory) {
174 this.outputDirectory = reportOutputDirectory;
175 }
176
177 @Override
178 public File getReportOutputDirectory() {
179 return outputDirectory;
180 }
181
182 @Override
183 protected MavenProject getProject() {
184 return project;
185 }
186
187 @Override
188 public String getOutputName() {
189 return this.outputName;
190 }
191
192 @Override
193 public String getName(final Locale locale) {
194 return "scss-lint report";
195 }
196
197 @Override
198 public String getDescription(final Locale locale) {
199 return "A scss-lint report.";
200 }
201
202 private ResourceBundle getBundle(final Locale locale) {
203 return ResourceBundle.getBundle("scss-lint-report", locale,
204 this.getClass().getClassLoader());
205 }
206 }