Class FixSiteAnchorsMojo

  • All Implemented Interfaces:
    org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

    @Mojo(name="fix-site-anchors",
          defaultPhase=SITE,
          requiresProject=true,
          threadSafe=true)
    public class FixSiteAnchorsMojo
    extends org.apache.maven.plugin.AbstractMojo
    Fixes anchors in URLs in site files.

    If a Markdown file contains a link to a method's Javadoc, in modern Java versions this link contains ( and ). Even if these are escaped, the site plugin replaces these with .28 and .29 respectively. This mojo can be used to fix these incorrect replacements.

    Since:
    2.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) java.lang.String encoding
      The encoding to use for reading and writing site files.
      (package private) java.io.File[] files
      The files to replace anchors in.
      (package private) org.apache.maven.project.MavenProject project  
      (package private) FixSiteAnchorsMojo.Replacement[] replacements
      The replacements to make.
      private static java.util.regex.Pattern TAG_PATTERN  
      • Fields inherited from interface org.apache.maven.plugin.Mojo

        ROLE
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void execute()  
      private java.lang.String fixSiteAnchors​(java.lang.String filePath, java.lang.String content)  
      (package private) void fixSiteAnchors​(java.nio.file.Path path, java.nio.charset.Charset charset)  
      private java.lang.String fixSiteAnchorsInUrl​(java.lang.String url)  
      (package private) java.nio.charset.Charset getCharset()  
      private java.lang.String readContent​(java.nio.file.Path file, java.nio.charset.Charset charset)  
      private void writeContent​(java.nio.file.Path file, java.lang.String content, java.nio.charset.Charset charset)  
      • 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

      • TAG_PATTERN

        private static final java.util.regex.Pattern TAG_PATTERN
      • project

        @Parameter(defaultValue="${project}",
                   readonly=true)
        org.apache.maven.project.MavenProject project
      • files

        @Parameter(required=true)
        java.io.File[] files
        The files to replace anchors in.
        Since:
        2.0
      • replacements

        @Parameter(required=false)
        FixSiteAnchorsMojo.Replacement[] replacements
        The replacements to make. If not specified this is equal to the following:
        
         <replacements>
           <replacement>
             <search>.28</search>
             <replace>(</replace>
           </replacement>
           <replacement>
             <search>.29</search>
             <replace>)</replace>
           </replacement>
           <replacement>
             <search>.25</search>
             <replace>%</replace>
           </replacement>
         </replacements>
         
        Since:
        2.0
      • encoding

        @Parameter(defaultValue="${project.build.sourceEncoding}")
        java.lang.String encoding
        The encoding to use for reading and writing site files.
        Since:
        2.0
    • Constructor Detail

      • FixSiteAnchorsMojo

        public FixSiteAnchorsMojo()
    • Method Detail

      • execute

        public void execute()
                     throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • getCharset

        java.nio.charset.Charset getCharset()
      • fixSiteAnchors

        void fixSiteAnchors​(java.nio.file.Path path,
                            java.nio.charset.Charset charset)
                     throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • readContent

        private java.lang.String readContent​(java.nio.file.Path file,
                                             java.nio.charset.Charset charset)
                                      throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • writeContent

        private void writeContent​(java.nio.file.Path file,
                                  java.lang.String content,
                                  java.nio.charset.Charset charset)
                           throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • fixSiteAnchors

        private java.lang.String fixSiteAnchors​(java.lang.String filePath,
                                                java.lang.String content)
      • fixSiteAnchorsInUrl

        private java.lang.String fixSiteAnchorsInUrl​(java.lang.String url)