Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MINVOKER-296] Warn-log the case of incomplete name-description #97

Merged
merged 1 commit into from
Feb 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 57 additions & 2 deletions src/it/invoker-report/verify.bsh
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,66 @@ import java.util.*;

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

passed = true;

System.out.println( "Checking for existence of report file: " + reportFile );
if ( !reportFile.exists() )
{
System.out.println( "FAILED!" );
return false;
passed = false;
}

buildLogReader = null;
try
{
buildLogReader = new BufferedReader( new FileReader( new File( basedir, "build.log" ) ) );
allWarningLines = new ArrayList();

currentLine = null;
while ( ( currentLine = buildLogReader.readLine() ) != null )
{
if ( currentLine.contains( "[WARNING] Incomplete job name-description" ) )
{
allWarningLines.add( currentLine );
}
}

missingNameLinesCount = 0;
missingDescriptionLinesCount = 0;

for ( currentLine : allWarningLines )
{
if ( currentLine.contains( "name is missing" ) )
{
++missingNameLinesCount;
}

if ( currentLine.contains( "description is missing" ) )
{
++missingDescriptionLinesCount;
}
}

expectedMissingNames = 4;
if ( expectedMissingNames != missingNameLinesCount )
{
System.out.println( "Current missingNameLinesCount: " + missingNameLinesCount + " but expecting: " + expectedMissingNames );
passed = false;
}

expectedMissingDescriptions = 1;
if ( expectedMissingDescriptions != missingDescriptionLinesCount )
{
System.out.println( "Current missingDescriptionLinesCount: " + missingDescriptionLinesCount + " but expecting: " + expectedMissingDescriptions );
passed = false;
}
}
finally
{
if ( buildLogReader != null )
{
buildLogReader.close();
}
}

return true;
return passed;
Original file line number Diff line number Diff line change
Expand Up @@ -529,12 +529,10 @@ public abstract class AbstractInvokerMojo
* # can be indexed
* invoker.systemPropertiesFile = test.properties
*
* # An optional human friendly name for this build job to be included in the build reports.
* # An optional human friendly name and description for this build job.
* # Both name and description have to be set to be included in the build reports.
* # Since plugin version 1.4
* invoker.name = Test Build 01
*
* # An optional description for this build job to be included in the build reports.
* # Since plugin version 1.4
* invoker.description = Checks the support for build reports.
*
* # A comma separated list of JRE versions on which this build job should be run.
Expand Down
29 changes: 24 additions & 5 deletions src/main/java/org/apache/maven/plugins/invoker/InvokerReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -301,16 +301,35 @@ private void renderBuildJob( BuildJob buildJob )

private String getBuildJobReportName( BuildJob buildJob )
{
StringBuilder buffer = new StringBuilder();
if ( !StringUtils.isEmpty( buildJob.getName() ) && !StringUtils.isEmpty( buildJob.getDescription() ) )
String buildJobName = buildJob.getName();
String buildJobDescription = buildJob.getDescription();
boolean emptyJobName = StringUtils.isEmpty( buildJobName );
boolean emptyJobDescription = StringUtils.isEmpty( buildJobDescription );
boolean isReportJobNameComplete = !emptyJobName && !emptyJobDescription;
if ( isReportJobNameComplete )
{
buffer.append( getFormattedName( buildJob.getName(), buildJob.getDescription() ) );
return getFormattedName( buildJobName, buildJobDescription );
}
else
{
buffer.append( buildJob.getProject() );
String buildJobProject = buildJob.getProject();
if ( !emptyJobName )
{
getLog().warn( incompleteNameWarning( "description", buildJobProject ) );
}
else if ( !emptyJobDescription )
{
getLog().warn( incompleteNameWarning( "name", buildJobProject ) );
}
return buildJobProject;
}
return buffer.toString();
}

private static String incompleteNameWarning( String missing, String pom )
{
return String.format( "Incomplete job name-description: %s is missing. "
+ "POM (%s) will be used in place of job name.",
missing, pom );
}

private String getFormattedName( String name, String description )
Expand Down