Skip to content

Commit 3233e05

Browse files
slawekjaranowskimichael-o
authored andcommitted
Code refactor to easier add new CI System
1 parent bb7569d commit 3233e05

1 file changed

Lines changed: 31 additions & 51 deletions

File tree

src/main/java/org/apache/maven/report/projectinfo/CiManagementReport.java

Lines changed: 31 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,11 @@
2727
import org.codehaus.plexus.i18n.I18N;
2828
import org.codehaus.plexus.util.StringUtils;
2929

30+
import java.util.Arrays;
31+
import java.util.HashSet;
3032
import java.util.List;
3133
import java.util.Locale;
34+
import java.util.Set;
3235

3336
/**
3437
* Generates the Project Continuous Integration Management report.
@@ -88,6 +91,20 @@ protected String getI18Nsection()
8891
private static class CiManagementRenderer
8992
extends AbstractProjectInfoRenderer
9093
{
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+
91108
private Model model;
92109

93110
CiManagementRenderer( Sink sink, Model model, I18N i18n, Locale locale )
@@ -126,50 +143,7 @@ public void renderBody()
126143
startSection( getI18nString( "overview.title" ) );
127144

128145
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 ) );
173147
sink.paragraph_();
174148

175149
endSection();
@@ -225,23 +199,29 @@ else if ( isCiManagementSystem( system, "travis" ) )
225199
}
226200

227201
/**
228-
* Checks if a CI management system is bugzilla, continuum...
202+
* Search system description.
229203
*
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
231206
*/
232-
private boolean isCiManagementSystem( String system, String actual )
207+
private String getIntroForCiManagementSystem( String system )
233208
{
234209
if ( StringUtils.isEmpty( system ) )
235210
{
236-
return false;
211+
return getI18nString( "general.intro" );
237212
}
238213

239-
if ( StringUtils.isEmpty( actual ) )
214+
String systemLowerCase = system.toLowerCase( Locale.ENGLISH );
215+
216+
for ( String systemName : SYSTEMS )
240217
{
241-
return false;
218+
if ( systemLowerCase.startsWith( systemName ) )
219+
{
220+
return getI18nString( systemName + ".intro" );
221+
}
242222
}
243223

244-
return system.toLowerCase( Locale.ENGLISH ).startsWith( actual.toLowerCase( Locale.ENGLISH ) );
224+
return getI18nString( "general.intro" );
245225
}
246226
}
247227
}

0 commit comments

Comments
 (0)