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

Fix project build #115

Merged
merged 1 commit into from
Dec 23, 2023
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
2 changes: 1 addition & 1 deletion src/main/java/org/codehaus/mojo/taglist/TagListReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ protected void executeReport( Locale locale )
this.currentLocale = locale;

// User entered no tags and no tagOptions, then default tags
if ( ( tagListOptions == null || tagListOptions.getTagClasses().size() == 0 ) )
if ( (tags == null || tags.length == 0) && ( tagListOptions == null || tagListOptions.getTagClasses().size() == 0 ) )
{
tags = new String[] { "@todo", "TODO" };
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.util.stream.Collectors;

import org.apache.maven.plugin.testing.AbstractMojoTestCase;
import org.codehaus.plexus.util.FileUtils;

public abstract class AbstractTaglistMojoTestCase
extends AbstractMojoTestCase
Expand All @@ -24,8 +26,9 @@ protected TagListReport getTagListReport( File pluginXmlFile )
assertTrue( "Cannot find plugin file.", pluginXmlFile.exists() );
TagListReport mojo = (TagListReport) lookupMojo( "taglist", pluginXmlFile );
assertNotNull( "Mojo not found.", mojo );
setVariableValueToObject( mojo, "encoding", TEST_ENCODING );
setVariableValueToObject( mojo, "xmlOutputDirectory", new File( mojo.getOutputDirectory(),
setVariableValueToObject( mojo, "inputEncoding", TEST_ENCODING );
setVariableValueToObject( mojo, "includes", new String[]{"**/*.java"} );
setVariableValueToObject( mojo, "xmlOutputDirectory", new File( mojo.getOutputDirectory(),
"taglist" ) );

return mojo;
Expand All @@ -45,9 +48,7 @@ protected String getGeneratedOutput( TagListReport mojo )
String filename = mojo.getOutputName() + ".html";
File outputHtml = new File( outputDir, filename );
assertTrue( "Cannont find output html file", outputHtml.exists() );
String htmlString = FileUtils.fileRead( outputHtml, TEST_ENCODING );

return htmlString;
return readFileContentWithoutNewLine( outputHtml );
}

/**
Expand All @@ -64,9 +65,15 @@ protected String getGeneratedXMLOutput( TagListReport mojo )
String filename = mojo.getOutputName() + ".xml";
File outputXML = new File( outputDir, filename );
assertTrue( "Cannont find output xml file", outputXML.exists() );
String xmlString = FileUtils.fileRead( outputXML, TEST_ENCODING );
return readFileContentWithoutNewLine( outputXML );
}


return xmlString;
protected String readFileContentWithoutNewLine(File file) throws IOException {
return Files.readAllLines(file.toPath(), Charset.forName(TEST_ENCODING))
.stream()
.map(String::trim)
.collect(Collectors.joining());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,9 @@ public void testXmlFile()
mojo.execute();

String actualXml = super.getGeneratedXMLOutput( mojo );
actualXml = actualXml.replaceAll( "(\r\n)|(\r)", "\n" );


File expectedFile = new File( getBasedir(), "/target/test-classes/unit/basic-config-test/expected-taglist.xml" );
String expectedXml = FileUtils.fileRead( expectedFile, TEST_ENCODING );
expectedXml = expectedXml.replaceAll( "(\r\n)|(\r)", "\n" );
String expectedXml = readFileContentWithoutNewLine(expectedFile );

assertEquals( "unexpected contents", expectedXml, actualXml );
}
Expand Down