1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.report.projectinfo;
20
21 import java.util.Locale;
22
23 import org.apache.maven.doxia.sink.Sink;
24 import org.apache.maven.model.IssueManagement;
25 import org.apache.maven.model.Model;
26 import org.apache.maven.plugins.annotations.Mojo;
27 import org.apache.maven.reporting.MavenReportException;
28 import org.codehaus.plexus.i18n.I18N;
29
30
31
32
33
34
35
36 @Mojo(name = "issue-management")
37 public class IssueManagementReport extends AbstractProjectInfoReport {
38
39
40
41
42 @Override
43 public boolean canGenerateReport() throws MavenReportException {
44 boolean result = super.canGenerateReport();
45 if (result && skipEmptyReport) {
46 result = getProject().getModel().getIssueManagement() != null;
47 }
48
49 return result;
50 }
51
52 @Override
53 public void executeReport(Locale locale) {
54 IssueManagementRenderer r =
55 new IssueManagementRenderer(getSink(), getProject().getModel(), getI18N(locale), locale);
56
57 r.render();
58 }
59
60
61 public String getOutputName() {
62 return "issue-management";
63 }
64
65 @Override
66 protected String getI18Nsection() {
67 return "issue-management";
68 }
69
70
71
72
73
74
75
76
77 private static class IssueManagementRenderer extends AbstractProjectInfoRenderer {
78 private Model model;
79
80 IssueManagementRenderer(Sink sink, Model model, I18N i18n, Locale locale) {
81 super(sink, i18n, locale);
82
83 this.model = model;
84 }
85
86 @Override
87 protected String getI18Nsection() {
88 return "issue-management";
89 }
90
91 @Override
92 protected void renderBody() {
93 IssueManagement issueManagement = model.getIssueManagement();
94 if (issueManagement == null) {
95 startSection(getTitle());
96
97 paragraph(getI18nString("noissueManagement"));
98
99 endSection();
100
101 return;
102 }
103
104 String system = issueManagement.getSystem();
105 String url = issueManagement.getUrl();
106
107
108 startSection(getI18nString("overview.title"));
109
110 if (isIssueManagementSystem(system, "jira")) {
111 sink.paragraph();
112 linkPatternedText(getI18nString("jira.intro"));
113 sink.paragraph_();
114 } else if (isIssueManagementSystem(system, "bugzilla")) {
115 sink.paragraph();
116 linkPatternedText(getI18nString("bugzilla.intro"));
117 sink.paragraph_();
118 } else if (isIssueManagementSystem(system, "scarab")) {
119 sink.paragraph();
120 linkPatternedText(getI18nString("scarab.intro"));
121 sink.paragraph_();
122 } else if (system == null || "".equals(system.trim())) {
123 paragraph(getI18nString("general.intro"));
124 } else {
125 paragraph(getI18nString("custom.intro").replaceFirst("%issueManagementSystem%", system));
126 }
127
128 endSection();
129
130
131 startSection(getTitle());
132
133 paragraph(getI18nString("intro"));
134
135 verbatimLink(url, url);
136
137 endSection();
138 }
139
140
141
142
143
144
145
146
147 private boolean isIssueManagementSystem(String system, String actual) {
148 if (system == null || system.isEmpty()) {
149 return false;
150 }
151
152 if (actual == null || actual.isEmpty()) {
153 return false;
154 }
155
156 return system.toLowerCase(Locale.ENGLISH).startsWith(actual.toLowerCase(Locale.ENGLISH));
157 }
158 }
159 }