Skip to content
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
16 changes: 5 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<configuration>
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
</configuration>
<executions>
<execution>
<goals>
<goal>helpmojo</goal>
<goal>descriptor</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.modello</groupId>
Expand Down Expand Up @@ -220,6 +209,11 @@
<artifactId>plexus-utils</artifactId>
<version>3.4.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-api</artifactId>
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/codehaus/mojo/taglist/FileAnalyser.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,21 +106,21 @@ public class FileAnalyser
/**
* ArrayList of tag classes.
*/
private ArrayList tagClasses = new ArrayList();
private List<TagClass> tagClasses = new ArrayList();

/**
* Constructor.
*
* @param report the MOJO that is using this analyzer.
* @param tagClasses the array of tag classes to use for searching
*/
public FileAnalyser( TagListReport report, ArrayList tagClasses )
public FileAnalyser( TagListReport report, List<TagClass> tagClasses )
{
multipleLineCommentsOn = report.isMultipleLineComments();
emptyCommentsOn = report.isEmptyComments();
log = report.getLog();
sourceDirs = report.constructSourceDirs();
encoding = report.getEncoding();
encoding = report.getInputEncoding();
locale = report.getLocale();
noCommentString = report.getBundle().getString( "report.taglist.nocomment" );
this.tagClasses = tagClasses;
Expand Down
115 changes: 34 additions & 81 deletions src/main/java/org/codehaus/mojo/taglist/TagListReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@

import org.apache.maven.doxia.siterenderer.Renderer;
import org.apache.maven.model.ReportPlugin;
import org.apache.maven.plugins.annotations.Execute;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;
import org.apache.maven.project.MavenProject;
import org.apache.maven.reporting.AbstractMavenReport;
import org.apache.maven.reporting.MavenReportException;
Expand All @@ -53,59 +58,28 @@
* Scans the source files for tags and generates a report on their occurrences.
*
* @author <a href="mailto:[email protected]">Fabrice Bellingard</a>
* @goal taglist
*/
@Mojo( name="taglist", requiresDependencyResolution = ResolutionScope.COMPILE)
public class TagListReport
extends AbstractMavenReport
{
/**
* @parameter expression="${project}"
* @required
* @readonly
*/
private MavenProject project;

/**
* @component
*/
private Renderer siteRenderer;

/**
* Specifies the character encoding of the source files.
*
* @parameter expression="${encoding}" default-value="${project.build.sourceEncoding}"
* @since 2.3
*/
private String encoding;

/**
* Specifies the Locale of the source files.
*
* @parameter default-value="en"
* @since 2.4
*/
@Parameter( property = "sourceFileLocale", defaultValue = "en" )
private String sourceFileLocale;

/** Default locale used if the source file locale is null. */
private static final String DEFAULT_LOCALE = "en";

/**
* The output directory for the report. Note that this parameter is only evaluated if the goal is run directly from
* the command line or from a build life cycle phase. If the goal is run indirectly as part of a site generation,
* the output directory configured in the Maven Site Plugin is used instead.
*
* @parameter default-value="${project.reporting.outputDirectory}"
* @required
*/
private File outputDirectory;

/**
* Specifies the directory where the xml output will be generated.
*
* @parameter default-value="${project.build.directory}/taglist"
* @since 2.3
* @required
*/
@Parameter( defaultValue = "${project.build.directory}/taglist", required = true )
private File xmlOutputDirectory;

/**
Expand All @@ -119,61 +93,55 @@ public class TagListReport
* /**).</li>
* </ul>
*
* @deprecated
* @parameter
* @deprecated use {@link #tagListOptions} instead.
*/
@Deprecated
@Parameter
private String[] tags;

/**
* This parameter indicates whether for simple tags (like "TODO"), the analyzer should look for multiple line
* comments.
*
* @parameter default-value="true"
*/
@Parameter( defaultValue = "true" )
private boolean multipleLineComments;

/**
* This parameter indicates whether to look for tags even if they don't have a comment.
*
* @parameter default-value="true"
*/
@Parameter( defaultValue = "true" )
private boolean emptyComments;

/**
* Link the tag line numbers to the source xref. Defaults to true and will link automatically if jxr plugin is being
* used.
*
* @parameter expression="${linkXRef}" default-value="true"
*/
@Parameter( defaultValue = "true", property = "taglists.linkXRef")
private boolean linkXRef;

/**
* Location of the Xrefs to link to.
*
* @parameter default-value="${project.reporting.outputDirectory}/xref"
*/
@Parameter( defaultValue = "${project.reporting.outputDirectory}/xref", property = "taglists.xrefLocation" )
private File xrefLocation;

/**
* Location of the Test Xrefs to link to.
*
* @parameter default-value="${project.reporting.outputDirectory}/xref-test"
*/
@Parameter( defaultValue = "${project.reporting.outputDirectory}/xref-test", property = "taglists.testXrefLocation" )
private File testXrefLocation;

/**
* The projects in the reactor for aggregation report.
*
* @parameter expression="${reactorProjects}"
* @readonly
*/
@Parameter( readonly = true, defaultValue = "${reactorProjects}" )
private List reactorProjects;

/**
* Whether to build an aggregated report at the root, or build individual reports.
*
* @parameter expression="${aggregate}" default-value="false"
*/
@Parameter( defaultValue = "false", property = "taglists.aggregate" )
private boolean aggregate;

/**
Expand All @@ -184,17 +152,17 @@ public class TagListReport
/**
* This parameter indicates whether to generate details for tags with zero occurrences.
*
* @parameter default-value="false"
* @since 2.2
*/
@Parameter( defaultValue = "false" )
private boolean showEmptyDetails;

/**
* Skips reporting of test sources.
*
* @parameter default-value="false"
* @since 2.4
*/
@Parameter( defaultValue = "false" )
private boolean skipTestSources;

/**
Expand Down Expand Up @@ -222,9 +190,9 @@ public class TagListReport
* tagListOptions is permitted; however the tags configuration should be avoided whenever possible because those
* strings are only checked using the exact match logic.
*
* @parameter
* @since 2.4
*/
@Parameter
private org.codehaus.mojo.taglist.options.TagListOptions tagListOptions;

/**
Expand All @@ -244,15 +212,15 @@ protected void executeReport( Locale locale )
tags = new String[] { "@todo", "TODO" };
}

if ( StringUtils.isEmpty( encoding ) )
if ( StringUtils.isEmpty( getInputEncoding() ) )
{
getLog().warn(
"File encoding has not been set, using platform encoding "
+ System.getProperty( "file.encoding" ) + ", i.e. build is platform dependent!" );
}

// Create the tag classes
ArrayList tagClasses = new ArrayList();
List<TagClass> tagClasses = new ArrayList<>();

// If any old style tags were used, then add each tag as a tag class
if ( tags != null && tags.length > 0 )
Expand Down Expand Up @@ -339,7 +307,7 @@ protected void executeReport( Locale locale )
else
{
// Not yet generated - check if the report is on its way
for ( Iterator reports = project.getReportPlugins().iterator(); reports.hasNext(); )
for ( Iterator reports = getProject().getReportPlugins().iterator(); reports.hasNext(); )
{
ReportPlugin report = (ReportPlugin) reports.next();

Expand Down Expand Up @@ -372,7 +340,7 @@ protected void executeReport( Locale locale )
private void generateXmlReport( Collection tagReports )
{
TagListXMLReport report = new TagListXMLReport();
report.setModelEncoding( getEncoding() );
report.setModelEncoding( getInputEncoding() );

// Iterate through each tag and populate an XML tag object.
for ( Iterator ite = tagReports.iterator(); ite.hasNext(); )
Expand Down Expand Up @@ -419,7 +387,7 @@ private void generateXmlReport( Collection tagReports )
try
{
fos = new FileOutputStream( xmlFile );
output = new OutputStreamWriter( fos, getEncoding() );
output = new OutputStreamWriter( fos, getInputEncoding());

// Write out the XML output file.
TaglistOutputXpp3Writer xmlWriter = new TaglistOutputXpp3Writer();
Expand Down Expand Up @@ -461,7 +429,7 @@ private String getRelativePath( File location )
public boolean canGenerateReport()
{
boolean canGenerate = !constructSourceDirs().isEmpty();
if ( aggregate && !project.isExecutionRoot() )
if ( aggregate && !getProject().isExecutionRoot() )
{
canGenerate = false;
}
Expand Down Expand Up @@ -527,10 +495,10 @@ else if ( currentFile.isDirectory() )
*/
public List constructSourceDirs()
{
List dirs = new ArrayList( project.getCompileSourceRoots() );
List dirs = new ArrayList( getProject().getCompileSourceRoots() );
if ( !skipTestSources )
{
dirs.addAll( project.getTestCompileSourceRoots() );
dirs.addAll( getProject().getTestCompileSourceRoots() );
}

if ( aggregate )
Expand All @@ -554,16 +522,6 @@ public List constructSourceDirs()
return dirs;
}

/**
* Returns the character encoding of the source files.
*
* @return The character encoding of the source files.
*/
public String getEncoding()
{
return encoding;
}

/**
* Returns the Locale of the source files.
*
Expand Down Expand Up @@ -639,16 +597,6 @@ protected String getXMLOutputDirectory()
return xmlOutputDirectory.getAbsolutePath();
}

/**
* {@inheritDoc}
*
* @see org.apache.maven.reporting.AbstractMavenReport#getProject()
*/
public MavenProject getProject()
{
return project;
}

/**
* {@inheritDoc}
*
Expand Down Expand Up @@ -700,4 +648,9 @@ private ResourceBundle getBundle( Locale locale )
return ResourceBundle.getBundle( "taglist-report", locale, this.getClass().getClassLoader() );
}

@Override
protected String getInputEncoding()
{
return super.getInputEncoding();
}
}