1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.scalabench.plugins.dacapo.reporting;
19
20 import java.io.File;
21 import java.util.Locale;
22 import java.util.ResourceBundle;
23
24 import org.apache.maven.doxia.siterenderer.Renderer;
25 import org.apache.maven.project.MavenProject;
26 import org.apache.maven.reporting.AbstractMavenReport;
27 import org.apache.maven.reporting.AbstractMavenReportRenderer;
28 import org.apache.maven.reporting.MavenReportException;
29 import org.dacapo.parser.Config;
30 import org.scalabench.plugins.dacapo.AbstractDacapoBenchmarkMojo;
31
32
33
34
35
36
37
38
39
40
41
42 public class ConfigurationReport extends AbstractMavenReport {
43
44
45
46
47
48
49
50
51 private MavenProject project;
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68 private String benchmarkName;
69
70
71
72
73
74
75
76
77 private File configurationDirectory;
78
79
80
81
82
83
84 private String outputDirectory;
85
86
87
88
89 private Renderer siteRenderer;
90
91 public MavenProject getProject() {
92 return project;
93 }
94
95 public String getBenchmarkName() {
96 if (benchmarkName == null)
97 return AbstractDacapoBenchmarkMojo.getBenchmarkNameFromArtifactId(getProject().getArtifactId());
98 else
99 return benchmarkName;
100 }
101
102 @Override
103 protected void executeReport(Locale locale) throws MavenReportException {
104 final Config config = Config.parse(getConfigurationFile());
105 final AbstractMavenReportRenderer renderer =
106 new ConfigurationReportRenderer(getSink(), config, locale);
107 renderer.render();
108 }
109
110 @Override
111 public boolean canGenerateReport() {
112 return getConfigurationFile().exists();
113 }
114
115 public File getConfigurationFile() {
116 return new File(getConfigurationDirectory(), getBenchmarkName() + ".cnf");
117 }
118
119 public File getConfigurationDirectory() {
120 return configurationDirectory;
121 }
122
123 @Override
124 public String getOutputName() {
125 return "dacapo-benchmark-configuration";
126 }
127
128 @Override
129 public String getOutputDirectory() {
130 return outputDirectory;
131 }
132
133 @Override
134 public Renderer getSiteRenderer() {
135 return siteRenderer;
136 }
137
138 @Override
139 public String getName(Locale locale) {
140 return getBundle(locale).getString("report.dacapo.name");
141 }
142
143 @Override
144 public String getDescription(Locale locale) {
145 return getBundle(locale).getString("report.dacapo.description");
146 }
147
148 public static ResourceBundle getBundle(Locale locale) {
149 return ResourceBundle.getBundle("configuration-report", locale, ConfigurationReport.class.getClassLoader());
150 }
151 }