|
27 | 27 | import org.codehaus.plexus.i18n.I18N; |
28 | 28 | import org.codehaus.plexus.util.StringUtils; |
29 | 29 |
|
| 30 | +import java.util.Arrays; |
| 31 | +import java.util.HashSet; |
30 | 32 | import java.util.List; |
31 | 33 | import java.util.Locale; |
| 34 | +import java.util.Set; |
32 | 35 |
|
33 | 36 | /** |
34 | 37 | * Generates the Project Continuous Integration Management report. |
@@ -88,6 +91,20 @@ protected String getI18Nsection() |
88 | 91 | private static class CiManagementRenderer |
89 | 92 | extends AbstractProjectInfoRenderer |
90 | 93 | { |
| 94 | + |
| 95 | + private static final Set<String> SYSTEMS = new HashSet<>( Arrays.asList( |
| 96 | + "anthill", |
| 97 | + "bamboo", |
| 98 | + "buildforge", |
| 99 | + "continuum", |
| 100 | + "cruisecontrol", |
| 101 | + "hudson", |
| 102 | + "jenkins", |
| 103 | + "luntbuild", |
| 104 | + "teamcity", |
| 105 | + "travis" |
| 106 | + ) ); |
| 107 | + |
91 | 108 | private Model model; |
92 | 109 |
|
93 | 110 | CiManagementRenderer( Sink sink, Model model, I18N i18n, Locale locale ) |
@@ -126,50 +143,7 @@ public void renderBody() |
126 | 143 | startSection( getI18nString( "overview.title" ) ); |
127 | 144 |
|
128 | 145 | sink.paragraph(); |
129 | | - if ( isCiManagementSystem( system, "anthill" ) ) |
130 | | - { |
131 | | - linkPatternedText( getI18nString( "anthill.intro" ) ); |
132 | | - } |
133 | | - else if ( isCiManagementSystem( system, "bamboo" ) ) |
134 | | - { |
135 | | - linkPatternedText( getI18nString( "bamboo.intro" ) ); |
136 | | - } |
137 | | - else if ( isCiManagementSystem( system, "buildforge" ) ) |
138 | | - { |
139 | | - linkPatternedText( getI18nString( "buildforge.intro" ) ); |
140 | | - } |
141 | | - else if ( isCiManagementSystem( system, "continuum" ) ) |
142 | | - { |
143 | | - linkPatternedText( getI18nString( "continuum.intro" ) ); |
144 | | - } |
145 | | - else if ( isCiManagementSystem( system, "cruisecontrol" ) ) |
146 | | - { |
147 | | - linkPatternedText( getI18nString( "cruisecontrol.intro" ) ); |
148 | | - } |
149 | | - else if ( isCiManagementSystem( system, "hudson" ) ) |
150 | | - { |
151 | | - linkPatternedText( getI18nString( "hudson.intro" ) ); |
152 | | - } |
153 | | - else if ( isCiManagementSystem( system, "jenkins" ) ) |
154 | | - { |
155 | | - linkPatternedText( getI18nString( "jenkins.intro" ) ); |
156 | | - } |
157 | | - else if ( isCiManagementSystem( system, "luntbuild" ) ) |
158 | | - { |
159 | | - linkPatternedText( getI18nString( "luntbuild.intro" ) ); |
160 | | - } |
161 | | - else if ( isCiManagementSystem( system, "teamcity" ) ) |
162 | | - { |
163 | | - linkPatternedText( getI18nString( "teamcity.intro" ) ); |
164 | | - } |
165 | | - else if ( isCiManagementSystem( system, "travis" ) ) |
166 | | - { |
167 | | - linkPatternedText( getI18nString( "travis.intro" ) ); |
168 | | - } |
169 | | - else |
170 | | - { |
171 | | - linkPatternedText( getI18nString( "general.intro" ) ); |
172 | | - } |
| 146 | + linkPatternedText( getIntroForCiManagementSystem( system ) ); |
173 | 147 | sink.paragraph_(); |
174 | 148 |
|
175 | 149 | endSection(); |
@@ -225,23 +199,29 @@ else if ( isCiManagementSystem( system, "travis" ) ) |
225 | 199 | } |
226 | 200 |
|
227 | 201 | /** |
228 | | - * Checks if a CI management system is bugzilla, continuum... |
| 202 | + * Search system description. |
229 | 203 | * |
230 | | - * @return true if the CI management system is bugzilla, continuum..., false otherwise. |
| 204 | + * @param system a system for description |
| 205 | + * @return system description from properties |
231 | 206 | */ |
232 | | - private boolean isCiManagementSystem( String system, String actual ) |
| 207 | + private String getIntroForCiManagementSystem( String system ) |
233 | 208 | { |
234 | 209 | if ( StringUtils.isEmpty( system ) ) |
235 | 210 | { |
236 | | - return false; |
| 211 | + return getI18nString( "general.intro" ); |
237 | 212 | } |
238 | 213 |
|
239 | | - if ( StringUtils.isEmpty( actual ) ) |
| 214 | + String systemLowerCase = system.toLowerCase( Locale.ENGLISH ); |
| 215 | + |
| 216 | + for ( String systemName : SYSTEMS ) |
240 | 217 | { |
241 | | - return false; |
| 218 | + if ( systemLowerCase.startsWith( systemName ) ) |
| 219 | + { |
| 220 | + return getI18nString( systemName + ".intro" ); |
| 221 | + } |
242 | 222 | } |
243 | 223 |
|
244 | | - return system.toLowerCase( Locale.ENGLISH ).startsWith( actual.toLowerCase( Locale.ENGLISH ) ); |
| 224 | + return getI18nString( "general.intro" ); |
245 | 225 | } |
246 | 226 | } |
247 | 227 | } |
0 commit comments