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.CiManagement; |
24 | |
import org.apache.maven.model.Model; |
25 | |
import org.apache.maven.model.Notifier; |
26 | |
import org.apache.maven.plugins.annotations.Mojo; |
27 | |
import org.codehaus.plexus.i18n.I18N; |
28 | |
import org.codehaus.plexus.util.StringUtils; |
29 | |
|
30 | |
import java.util.List; |
31 | |
import java.util.Locale; |
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
@Mojo( name = "cim" ) |
41 | 1 | public class CimReport |
42 | |
extends AbstractProjectInfoReport |
43 | |
{ |
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
@Override |
49 | |
public void executeReport( Locale locale ) |
50 | |
{ |
51 | 1 | CimRenderer r = new CimRenderer( getSink(), getProject().getModel(), getI18N( locale ), locale ); |
52 | |
|
53 | 1 | r.render(); |
54 | 1 | } |
55 | |
|
56 | |
|
57 | |
public String getOutputName() |
58 | |
{ |
59 | 2 | return "integration"; |
60 | |
} |
61 | |
|
62 | |
@Override |
63 | |
protected String getI18Nsection() |
64 | |
{ |
65 | 1 | return "cim"; |
66 | |
} |
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | |
|
75 | 1 | private static class CimRenderer |
76 | |
extends AbstractProjectInfoRenderer |
77 | |
{ |
78 | |
private Model model; |
79 | |
|
80 | |
CimRenderer( Sink sink, Model model, I18N i18n, Locale locale ) |
81 | |
{ |
82 | 1 | super( sink, i18n, locale ); |
83 | |
|
84 | 1 | this.model = model; |
85 | 1 | } |
86 | |
|
87 | |
@Override |
88 | |
protected String getI18Nsection() |
89 | |
{ |
90 | 3 | return "cim"; |
91 | |
} |
92 | |
|
93 | |
@Override |
94 | |
public void renderBody() |
95 | |
{ |
96 | 1 | CiManagement cim = model.getCiManagement(); |
97 | 1 | if ( cim == null ) |
98 | |
{ |
99 | 1 | startSection( getTitle() ); |
100 | |
|
101 | 1 | paragraph( getI18nString( "nocim" ) ); |
102 | |
|
103 | 1 | endSection(); |
104 | |
|
105 | 1 | return; |
106 | |
} |
107 | |
|
108 | 0 | String system = cim.getSystem(); |
109 | 0 | String url = cim.getUrl(); |
110 | 0 | List<Notifier> notifiers = cim.getNotifiers(); |
111 | |
|
112 | |
|
113 | 0 | startSection( getI18nString( "overview.title" ) ); |
114 | |
|
115 | 0 | sink.paragraph(); |
116 | 0 | if ( isCimSystem( system, "anthill" ) ) |
117 | |
{ |
118 | 0 | linkPatternedText( getI18nString( "anthill.intro" ) ); |
119 | |
} |
120 | 0 | else if ( isCimSystem( system, "buildforge" ) ) |
121 | |
{ |
122 | 0 | linkPatternedText( getI18nString( "buildforge.intro" ) ); |
123 | |
} |
124 | 0 | else if ( isCimSystem( system, "continuum" ) ) |
125 | |
{ |
126 | 0 | linkPatternedText( getI18nString( "continuum.intro" ) ); |
127 | |
} |
128 | 0 | else if ( isCimSystem( system, "cruisecontrol" ) ) |
129 | |
{ |
130 | 0 | linkPatternedText( getI18nString( "cruisecontrol.intro" ) ); |
131 | |
} |
132 | 0 | else if ( isCimSystem( system, "hudson" ) ) |
133 | |
{ |
134 | 0 | linkPatternedText( getI18nString( "hudson.intro" ) ); |
135 | |
} |
136 | 0 | else if ( isCimSystem( system, "jenkins" ) ) |
137 | |
{ |
138 | 0 | linkPatternedText( getI18nString( "jenkins.intro" ) ); |
139 | |
} |
140 | 0 | else if ( isCimSystem( system, "luntbuild" ) ) |
141 | |
{ |
142 | 0 | linkPatternedText( getI18nString( "luntbuild.intro" ) ); |
143 | |
} |
144 | |
else |
145 | |
{ |
146 | 0 | linkPatternedText( getI18nString( "general.intro" ) ); |
147 | |
} |
148 | 0 | sink.paragraph_(); |
149 | |
|
150 | 0 | endSection(); |
151 | |
|
152 | |
|
153 | 0 | startSection( getI18nString( "access" ) ); |
154 | |
|
155 | 0 | if ( !StringUtils.isEmpty( url ) ) |
156 | |
{ |
157 | 0 | paragraph( getI18nString( "url" ) ); |
158 | |
|
159 | 0 | verbatimLink( url, url ); |
160 | |
} |
161 | |
else |
162 | |
{ |
163 | 0 | paragraph( getI18nString( "nourl" ) ); |
164 | |
} |
165 | |
|
166 | 0 | endSection(); |
167 | |
|
168 | |
|
169 | 0 | startSection( getI18nString( "notifiers.title" ) ); |
170 | |
|
171 | 0 | if ( notifiers == null || notifiers.isEmpty() ) |
172 | |
{ |
173 | 0 | paragraph( getI18nString( "notifiers.nolist" ) ); |
174 | |
} |
175 | |
else |
176 | |
{ |
177 | 0 | sink.paragraph(); |
178 | 0 | sink.text( getI18nString( "notifiers.intro" ) ); |
179 | 0 | sink.paragraph_(); |
180 | |
|
181 | 0 | startTable(); |
182 | |
|
183 | 0 | String type = getI18nString( "notifiers.column.type" ); |
184 | 0 | String address = getI18nString( "notifiers.column.address" ); |
185 | 0 | String configuration = getI18nString( "notifiers.column.configuration" ); |
186 | |
|
187 | 0 | tableHeader( new String[]{type, address, configuration} ); |
188 | |
|
189 | 0 | for ( Notifier notifier : notifiers ) |
190 | |
{ |
191 | 0 | tableRow( new String[]{notifier.getType(), |
192 | |
createLinkPatternedText( notifier.getAddress(), notifier.getAddress() ), |
193 | |
propertiesToString( notifier.getConfiguration() )} ); |
194 | |
} |
195 | |
|
196 | 0 | endTable(); |
197 | |
} |
198 | |
|
199 | 0 | endSection(); |
200 | 0 | } |
201 | |
|
202 | |
|
203 | |
|
204 | |
|
205 | |
|
206 | |
|
207 | |
|
208 | |
|
209 | |
private boolean isCimSystem( String connection, String cim ) |
210 | |
{ |
211 | 0 | if ( StringUtils.isEmpty( connection ) ) |
212 | |
{ |
213 | 0 | return false; |
214 | |
} |
215 | |
|
216 | 0 | if ( StringUtils.isEmpty( cim ) ) |
217 | |
{ |
218 | 0 | return false; |
219 | |
} |
220 | |
|
221 | 0 | return connection.toLowerCase( Locale.ENGLISH ).startsWith( cim.toLowerCase( Locale.ENGLISH ) ); |
222 | |
} |
223 | |
} |
224 | |
} |