Class SiteIndexMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- com.github.robtimus.maven.plugins.buildhelper.SiteIndexMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
@Mojo(name="site-index", defaultPhase=PRE_SITE, requiresProject=true, threadSafe=true) public class SiteIndexMojo extends org.apache.maven.plugin.AbstractMojoGenerate a Markdown site index based on another Markdown file. This goal will provide the following transformations:- Add an HTML title.
- Make any link that starts with the project's URL relative to that URL.
- Remove any badges that match any of a set of provided patterns. Badges will be removed if:
- They are preceded by a space. In this case, the leading space is removed as well.
- They are on a line of their own. In this case, the entire line is removed.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classSiteIndexMojo.RemoveBadgesVisitorprivate classSiteIndexMojo.RemoveProjectUrlVisitorprivate static classSiteIndexMojo.TextOnlyVisitor
-
Field Summary
Fields Modifier and Type Field Description (package private) java.lang.String[]badgePatternsA set of patterns to use to recognize badges, based on the URL.(package private) java.lang.StringencodingThe encoding to use for reading and writing the site index.private static org.commonmark.parser.ParserMARKDOWN_PARSER(package private) org.apache.maven.project.MavenProjectproject(package private) java.lang.StringsiteIndexTitleThe HTML title to add.(package private) booleanskipSiteIndexSet this totrueto skip generating a Markdown site index.(package private) java.io.FilesourceFileThe source Markdown file.(package private) java.io.FiletargetFileThe Markdown site index to generate.private static java.lang.StringURL_REGEX_QUERY
-
Constructor Summary
Constructors Constructor Description SiteIndexMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcreateTargetDir(java.nio.file.Path targetFile)voidexecute()(package private) voidgenerateSiteIndex(java.nio.file.Path baseDir, java.nio.file.Path sourceFile, java.nio.file.Path targetFile)(package private) java.nio.charset.CharsetgetCharset()(package private) java.lang.StringremoveBadges(java.lang.String content)(package private) java.lang.StringremoveProjectUrl(java.lang.String content, java.lang.String projectUrl)private voidwriteHeader(java.io.Writer output)
-
-
-
Field Detail
-
URL_REGEX_QUERY
private static final java.lang.String URL_REGEX_QUERY
- See Also:
- Constant Field Values
-
MARKDOWN_PARSER
private static final org.commonmark.parser.Parser MARKDOWN_PARSER
-
project
@Parameter(defaultValue="${project}", readonly=true) org.apache.maven.project.MavenProject project
-
sourceFile
@Parameter(defaultValue="${project.basedir}/README.md", required=true) java.io.File sourceFileThe source Markdown file. 1.0
-
targetFile
@Parameter(defaultValue="${project.basedir}/src/site/markdown/index.md", required=true) java.io.File targetFileThe Markdown site index to generate.- Since:
- 1.0
-
siteIndexTitle
@Parameter(defaultValue="Overview", required=true) java.lang.String siteIndexTitleThe HTML title to add.- Since:
- 1.0
-
badgePatterns
@Parameter java.lang.String[] badgePatterns
A set of patterns to use to recognize badges, based on the URL.- Since:
- 1.0
-
encoding
@Parameter(defaultValue="${project.build.sourceEncoding}") java.lang.String encodingThe encoding to use for reading and writing the site index.- Since:
- 1.0
-
skipSiteIndex
@Parameter(property="robtimus.site-index.skip", defaultValue="false") boolean skipSiteIndexSet this totrueto skip generating a Markdown site index.- Since:
- 1.0
-
-
Method Detail
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-
generateSiteIndex
void generateSiteIndex(java.nio.file.Path baseDir, java.nio.file.Path sourceFile, java.nio.file.Path targetFile) throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-
getCharset
java.nio.charset.Charset getCharset()
-
createTargetDir
private void createTargetDir(java.nio.file.Path targetFile) throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
writeHeader
private void writeHeader(java.io.Writer output) throws java.io.IOException- Throws:
java.io.IOException
-
removeProjectUrl
java.lang.String removeProjectUrl(java.lang.String content, java.lang.String projectUrl) throws java.io.IOException- Throws:
java.io.IOException
-
removeBadges
java.lang.String removeBadges(java.lang.String content) throws java.io.IOException- Throws:
java.io.IOException
-
-