Class 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.AbstractMojo
    Generate 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.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) java.lang.String[] badgePatterns
      A set of patterns to use to recognize badges, based on the URL.
      (package private) java.lang.String encoding
      The encoding to use for reading and writing the site index.
      private static org.commonmark.parser.Parser MARKDOWN_PARSER  
      (package private) org.apache.maven.project.MavenProject project  
      (package private) java.lang.String siteIndexTitle
      The HTML title to add.
      (package private) boolean skipSiteIndex
      Set this to true to skip generating a Markdown site index.
      (package private) java.io.File sourceFile
      The source Markdown file.
      (package private) java.io.File targetFile
      The Markdown site index to generate.
      private static java.lang.String URL_REGEX_QUERY  
      • Fields inherited from interface org.apache.maven.plugin.Mojo

        ROLE
    • Constructor Summary

      Constructors 
      Constructor Description
      SiteIndexMojo()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void createTargetDir​(java.nio.file.Path targetFile)  
      void execute()  
      (package private) void generateSiteIndex​(java.nio.file.Path baseDir, java.nio.file.Path sourceFile, java.nio.file.Path targetFile)  
      (package private) java.nio.charset.Charset getCharset()  
      (package private) java.lang.String removeBadges​(java.lang.String content)  
      (package private) java.lang.String removeProjectUrl​(java.lang.String content, java.lang.String projectUrl)  
      private void writeHeader​(java.io.Writer output)  
      • Methods inherited from class org.apache.maven.plugin.AbstractMojo

        getLog, getPluginContext, setLog, setPluginContext
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • 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 sourceFile
        The source Markdown file. 1.0
      • targetFile

        @Parameter(defaultValue="${project.basedir}/src/site/markdown/index.md",
                   required=true)
        java.io.File targetFile
        The Markdown site index to generate.
        Since:
        1.0
      • siteIndexTitle

        @Parameter(defaultValue="Overview",
                   required=true)
        java.lang.String siteIndexTitle
        The 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 encoding
        The encoding to use for reading and writing the site index.
        Since:
        1.0
      • skipSiteIndex

        @Parameter(property="robtimus.site-index.skip",
                   defaultValue="false")
        boolean skipSiteIndex
        Set this to true to skip generating a Markdown site index.
        Since:
        1.0
    • Constructor Detail

      • SiteIndexMojo

        public SiteIndexMojo()
    • Method Detail

      • execute

        public void execute()
                     throws org.apache.maven.plugin.MojoExecutionException,
                            org.apache.maven.plugin.MojoFailureException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
        org.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.MojoExecutionException
        org.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