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