Skip to content

Commit d6c7cd2

Browse files
committed
Warn-log the case of incomplete name-description
1 parent 1da0c62 commit d6c7cd2

File tree

2 files changed

+81
-7
lines changed

2 files changed

+81
-7
lines changed

src/it/invoker-report/verify.bsh

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,66 @@ import java.util.*;
2222

2323
File reportFile = new File( basedir, "target/site/invoker-report.html");
2424

25+
passed = true;
26+
2527
System.out.println( "Checking for existence of report file: " + reportFile );
2628
if ( !reportFile.exists() )
2729
{
2830
System.out.println( "FAILED!" );
29-
return false;
31+
passed = false;
32+
}
33+
34+
buildLogReader = null;
35+
try
36+
{
37+
buildLogReader = new BufferedReader( new FileReader( new File( basedir, "build.log" ) ) );
38+
allWarningLines = new ArrayList();
39+
40+
currentLine = null;
41+
while ( ( currentLine = buildLogReader.readLine() ) != null )
42+
{
43+
if ( currentLine.contains( "[WARNING] Incomplete job name-description" ) )
44+
{
45+
allWarningLines.add( currentLine );
46+
}
47+
}
48+
49+
missingNameLinesCount = 0;
50+
missingDescriptionLinesCount = 0;
51+
52+
for ( currentLine : allWarningLines )
53+
{
54+
if ( currentLine.contains( "name is missing" ) )
55+
{
56+
++missingNameLinesCount;
57+
}
58+
59+
if ( currentLine.contains( "description is missing" ) )
60+
{
61+
++missingDescriptionLinesCount;
62+
}
63+
}
64+
65+
expectedMissingNames = 5;
66+
if ( expectedMissingNames != missingNameLinesCount )
67+
{
68+
System.out.println( "Current missingNameLinesCount: " + missingNameLinesCount + " but expecting: " + expectedMissingNames );
69+
passed = false;
70+
}
71+
72+
expectedMissingDescriptions = 1;
73+
if ( expectedMissingDescriptions != missingDescriptionLinesCount )
74+
{
75+
System.out.println( "Current missingDescriptionLinesCount: " + missingDescriptionLinesCount + " but expecting: " + expectedMissingDescriptions );
76+
passed = false;
77+
}
78+
}
79+
finally
80+
{
81+
if ( buildLogReader != null )
82+
{
83+
buildLogReader.close();
84+
}
3085
}
3186

32-
return true;
87+
return passed;

src/main/java/org/apache/maven/plugins/invoker/InvokerReport.java

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -301,16 +301,35 @@ private void renderBuildJob( BuildJob buildJob )
301301

302302
private String getBuildJobReportName( BuildJob buildJob )
303303
{
304-
StringBuilder buffer = new StringBuilder();
305-
if ( !StringUtils.isEmpty( buildJob.getName() ) && !StringUtils.isEmpty( buildJob.getDescription() ) )
304+
String buildJobName = buildJob.getName();
305+
String buildJobDescription = buildJob.getDescription();
306+
boolean emptyJobName = StringUtils.isEmpty( buildJobName );
307+
boolean emptyJobDescription = StringUtils.isEmpty( buildJobDescription );
308+
boolean isReportJobNameComplete = !emptyJobName && !emptyJobDescription;
309+
if ( isReportJobNameComplete )
306310
{
307-
buffer.append( getFormattedName( buildJob.getName(), buildJob.getDescription() ) );
311+
return getFormattedName( buildJobName, buildJobDescription );
308312
}
309313
else
310314
{
311-
buffer.append( buildJob.getProject() );
315+
String buildJobProject = buildJob.getProject();
316+
if ( emptyJobName )
317+
{
318+
getLog().warn( incompleteNameWarning( "name", buildJobProject ) );
319+
}
320+
else if ( emptyJobDescription )
321+
{
322+
getLog().warn( incompleteNameWarning( "description", buildJobProject ) );
323+
}
324+
return buildJobProject;
312325
}
313-
return buffer.toString();
326+
}
327+
328+
private static String incompleteNameWarning( String missing, String pom )
329+
{
330+
return String.format( "Incomplete job name-description: %s is missing. "
331+
+ "POM (%s) will be used in place of job name.",
332+
missing, pom );
314333
}
315334

316335
private String getFormattedName( String name, String description )

0 commit comments

Comments
 (0)