Class AntBuildWriterUtil


  • public class AntBuildWriterUtil
    extends java.lang.Object
    Utility class for the AntBuildWriter class.
    Version:
    $Id: AntBuildWriterUtil.java 1645084 2014-12-12 22:28:31Z khmarbaise $
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void addWrapAttribute​(org.codehaus.plexus.util.xml.XMLWriter writer, java.lang.String tag, java.lang.String name, java.lang.String value, int indent)
      Convenience method to wrap long element tags for a given attribute.
      static java.lang.String getMavenCompilerPluginBasicOption​(org.apache.maven.project.MavenProject project, java.lang.String optionName, java.lang.String defaultValue)
      Return the optionName value defined in a project for the "maven-compiler-plugin" plugin.
      static java.util.Map getMavenCompilerPluginOption​(org.apache.maven.project.MavenProject project, java.lang.String optionName, java.lang.String defaultValue)
      Return the map of optionName value defined in a project for the "maven-compiler-plugin" plugin.
      static java.util.Map[] getMavenCompilerPluginOptions​(org.apache.maven.project.MavenProject project, java.lang.String optionName, java.lang.String defaultValue)
      Return an array of map of optionName value defined in a project for the "maven-compiler-plugin" plugin.
      static java.lang.String getMavenEarPluginBasicOption​(org.apache.maven.project.MavenProject project, java.lang.String optionName, java.lang.String defaultValue)
      Return the optionName value defined in a project for the "maven-ear-plugin" plugin.
      static java.lang.String getMavenJarPluginBasicOption​(org.apache.maven.project.MavenProject project, java.lang.String optionName, java.lang.String defaultValue)
      Return the optionName value defined in a project for the "maven-jar-plugin" plugin.
      static java.lang.String getMavenJavadocPluginBasicOption​(org.apache.maven.project.MavenProject project, java.lang.String optionName, java.lang.String defaultValue)
      Return the optionName value defined in a project for the "maven-javadoc-plugin" plugin.
      static java.util.Map getMavenJavadocPluginOption​(org.apache.maven.project.MavenProject project, java.lang.String optionName, java.lang.String defaultValue)
      Return a map of optionName value defined in a project for the "maven-javadoc-plugin" plugin.
      static java.util.Map[] getMavenJavadocPluginOptions​(org.apache.maven.project.MavenProject project, java.lang.String optionName, java.lang.String defaultValue)
      Return an array of map of optionName value defined in a project for the "maven-javadoc-plugin" plugin.
      private static java.lang.String getMavenPluginBasicOption​(org.apache.maven.project.MavenProject project, java.lang.String pluginArtifactId, java.lang.String optionName, java.lang.String defaultValue)
      Return the value for the option optionName defined in a project with the given artifactId plugin.
      private static java.util.Map getMavenPluginConfigurationsImpl​(org.apache.maven.project.MavenProject project, java.lang.String pluginArtifactId, java.lang.String optionName, java.lang.String defaultValue)
      Return a Map for the option optionName defined in a project with the given artifactId plugin.
      private static java.util.Map getMavenPluginOption​(org.apache.maven.project.MavenProject project, java.lang.String pluginArtifactId, java.lang.String optionName, java.lang.String defaultValue)
      Return a Map for the option optionName defined in a project with the given artifactId plugin.
      private static java.util.Map[] getMavenPluginOptions​(org.apache.maven.project.MavenProject project, java.lang.String pluginArtifactId, java.lang.String optionName, java.lang.String defaultValue)
      Return an array of Map for the option optionName defined in a project with the given artifactId plugin.
      static java.lang.String getMavenSurefirePluginBasicOption​(org.apache.maven.project.MavenProject project, java.lang.String optionName, java.lang.String defaultValue)
      Return the optionName value defined in a project for the "maven-surefire-plugin" plugin.
      static java.util.Map getMavenSurefirePluginOption​(org.apache.maven.project.MavenProject project, java.lang.String optionName, java.lang.String defaultValue)
      Return the map of optionName value defined in a project for the "maven-surefire-plugin" plugin.
      static java.util.Map[] getMavenSurefirePluginOptions​(org.apache.maven.project.MavenProject project, java.lang.String optionName, java.lang.String defaultValue)
      Return an array of map of optionName value defined in a project for the "maven-surefire-plugin" plugin.
      static java.lang.String getMavenWarPluginBasicOption​(org.apache.maven.project.MavenProject project, java.lang.String optionName, java.lang.String defaultValue)
      Return the optionName value defined in a project for the "maven-war-plugin" plugin.
      (package private) static java.lang.String getSingularForm​(java.lang.String pluralForm)
      Gets the singular form of the specified (English) plural form.
      private static java.lang.String getTextContent​(org.w3c.dom.Node node)
      Gets the text content of the specified node.
      static boolean isBundlePackaging​(org.apache.maven.project.MavenProject mavenProject)  
      static boolean isEarPackaging​(org.apache.maven.project.MavenProject mavenProject)  
      static boolean isEjbPackaging​(org.apache.maven.project.MavenProject mavenProject)  
      private static boolean isElementContent​(org.w3c.dom.Node node)
      Checks whether the specified node has element content or consists only of character data.
      static boolean isJarPackaging​(org.apache.maven.project.MavenProject mavenProject)  
      private static boolean isList​(org.w3c.dom.Node node)
      Check if a given node is a list of nodes or not.
      static boolean isMavenPluginPackaging​(org.apache.maven.project.MavenProject mavenProject)  
      static boolean isPomPackaging​(org.apache.maven.project.MavenProject mavenProject)  
      static boolean isWarPackaging​(org.apache.maven.project.MavenProject mavenProject)  
      static java.util.List removeEmptyCompileSourceRoots​(java.util.List compileSourceRoots)  
      (package private) static java.lang.String toRelative​(java.io.File basedir, java.lang.String path)
      Relativizes the specified path against the given base directory (if possible).
      static void writeAntTask​(org.codehaus.plexus.util.xml.XMLWriter writer, org.apache.maven.project.MavenProject project, java.lang.String moduleSubPath, java.lang.String tasks)
      Convenience method to write XML ant task
      static void writeAntVersionHeader​(org.codehaus.plexus.util.xml.XMLWriter writer)
      Write comment for the Ant supported version
      private static void writeCopyLib​(org.codehaus.plexus.util.xml.XMLWriter writer, org.apache.maven.project.MavenProject project, ArtifactResolverWrapper artifactResolverWrapper, java.lang.String outputDir)
      Write copy tasks in an outputDir for EAR and WAR targets for project depencies without provided or test as scope
      static void writeEarTask​(org.codehaus.plexus.util.xml.XMLWriter writer, org.apache.maven.project.MavenProject project, ArtifactResolverWrapper artifactResolverWrapper)
      Convenience method to write XML Ant ear task
      static void writeHeader​(org.codehaus.plexus.util.xml.XMLWriter writer)
      Write comments in the Ant build file header
      static void writeIncludesExcludes​(org.codehaus.plexus.util.xml.XMLWriter writer, java.util.List includes, java.util.List excludes)
      Convenience method to write <include/> and <exclude/>
      static void writeJarTask​(org.codehaus.plexus.util.xml.XMLWriter writer, org.apache.maven.project.MavenProject project)
      Convenience method to write XML Ant jar task
      static void writeJavadocTask​(org.codehaus.plexus.util.xml.XMLWriter writer, org.apache.maven.project.MavenProject project, ArtifactResolverWrapper wrapper)
      Convenience method to write XML Ant javadoc task
      static void writeWarTask​(org.codehaus.plexus.util.xml.XMLWriter writer, org.apache.maven.project.MavenProject project, ArtifactResolverWrapper artifactResolverWrapper)
      Convenience method to write XML Ant war task
      • Methods inherited from class java.lang.Object

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

      • AntBuildWriterUtil

        public AntBuildWriterUtil()
    • Method Detail

      • removeEmptyCompileSourceRoots

        public static java.util.List removeEmptyCompileSourceRoots​(java.util.List compileSourceRoots)
        Parameters:
        compileSourceRoots - List
        Returns:
        not null list
      • writeIncludesExcludes

        public static void writeIncludesExcludes​(org.codehaus.plexus.util.xml.XMLWriter writer,
                                                 java.util.List includes,
                                                 java.util.List excludes)
        Convenience method to write <include/> and <exclude/>
        Parameters:
        writer - not null
        includes - List
        excludes - List
      • writeHeader

        public static void writeHeader​(org.codehaus.plexus.util.xml.XMLWriter writer)
        Write comments in the Ant build file header
        Parameters:
        writer - XMLWriter
      • writeAntVersionHeader

        public static void writeAntVersionHeader​(org.codehaus.plexus.util.xml.XMLWriter writer)
        Write comment for the Ant supported version
        Parameters:
        writer - the writer
      • writeAntTask

        public static void writeAntTask​(org.codehaus.plexus.util.xml.XMLWriter writer,
                                        org.apache.maven.project.MavenProject project,
                                        java.lang.String moduleSubPath,
                                        java.lang.String tasks)
        Convenience method to write XML ant task
        Parameters:
        writer - not null
        project - not null
        moduleSubPath - not null
        tasks - not null
      • writeJavadocTask

        public static void writeJavadocTask​(org.codehaus.plexus.util.xml.XMLWriter writer,
                                            org.apache.maven.project.MavenProject project,
                                            ArtifactResolverWrapper wrapper)
                                     throws java.io.IOException
        Convenience method to write XML Ant javadoc task
        Parameters:
        writer - not null
        project - not null
        wrapper - not null
        Throws:
        java.io.IOException - if any
      • writeJarTask

        public static void writeJarTask​(org.codehaus.plexus.util.xml.XMLWriter writer,
                                        org.apache.maven.project.MavenProject project)
                                 throws java.io.IOException
        Convenience method to write XML Ant jar task
        Parameters:
        writer - not null
        project - not null
        Throws:
        java.io.IOException - if any
      • writeEarTask

        public static void writeEarTask​(org.codehaus.plexus.util.xml.XMLWriter writer,
                                        org.apache.maven.project.MavenProject project,
                                        ArtifactResolverWrapper artifactResolverWrapper)
                                 throws java.io.IOException
        Convenience method to write XML Ant ear task
        Parameters:
        writer - not null
        project - not null
        artifactResolverWrapper - not null
        Throws:
        java.io.IOException - if any
      • writeWarTask

        public static void writeWarTask​(org.codehaus.plexus.util.xml.XMLWriter writer,
                                        org.apache.maven.project.MavenProject project,
                                        ArtifactResolverWrapper artifactResolverWrapper)
                                 throws java.io.IOException
        Convenience method to write XML Ant war task
        Parameters:
        writer - not null
        project - not null
        artifactResolverWrapper - not null
        Throws:
        java.io.IOException - if any
      • addWrapAttribute

        public static void addWrapAttribute​(org.codehaus.plexus.util.xml.XMLWriter writer,
                                            java.lang.String tag,
                                            java.lang.String name,
                                            java.lang.String value,
                                            int indent)
        Convenience method to wrap long element tags for a given attribute.
        Parameters:
        writer - not null
        tag - not null
        name - not null
        value - not null
        indent - positive value
      • isPomPackaging

        public static boolean isPomPackaging​(org.apache.maven.project.MavenProject mavenProject)
        Parameters:
        mavenProject - not null
        Returns:
        true if project packaging equals pom
      • isJarPackaging

        public static boolean isJarPackaging​(org.apache.maven.project.MavenProject mavenProject)
        Parameters:
        mavenProject - MavenProject
        Returns:
        true if project packaging equals one of several packaging types including jar, maven-plugin, ejb, or bundle
      • isBundlePackaging

        public static boolean isBundlePackaging​(org.apache.maven.project.MavenProject mavenProject)
        Parameters:
        mavenProject - MavenProject
        Returns:
        true if project packaging equals bundle
      • isEjbPackaging

        public static boolean isEjbPackaging​(org.apache.maven.project.MavenProject mavenProject)
        Parameters:
        mavenProject - MavenProject
        Returns:
        true if project packaging equals ejb
      • isMavenPluginPackaging

        public static boolean isMavenPluginPackaging​(org.apache.maven.project.MavenProject mavenProject)
        Parameters:
        mavenProject - MavenProject
        Returns:
        true if project packaging equals maven-plugin
      • isEarPackaging

        public static boolean isEarPackaging​(org.apache.maven.project.MavenProject mavenProject)
        Parameters:
        mavenProject - MavenProject
        Returns:
        true if project packaging equals ear
      • isWarPackaging

        public static boolean isWarPackaging​(org.apache.maven.project.MavenProject mavenProject)
        Parameters:
        mavenProject - MavenProject
        Returns:
        true if project packaging equals war
      • getMavenCompilerPluginBasicOption

        public static java.lang.String getMavenCompilerPluginBasicOption​(org.apache.maven.project.MavenProject project,
                                                                         java.lang.String optionName,
                                                                         java.lang.String defaultValue)
                                                                  throws java.io.IOException
        Return the optionName value defined in a project for the "maven-compiler-plugin" plugin.
        Parameters:
        project - MavenProject not null.
        optionName - the option name wanted
        defaultValue - a default value
        Returns:
        the value for the option name or the default value. Could be null if not found.
        Throws:
        java.io.IOException - if any
      • getMavenCompilerPluginOption

        public static java.util.Map getMavenCompilerPluginOption​(org.apache.maven.project.MavenProject project,
                                                                 java.lang.String optionName,
                                                                 java.lang.String defaultValue)
                                                          throws java.io.IOException
        Return the map of optionName value defined in a project for the "maven-compiler-plugin" plugin.
        Parameters:
        project - MavenProject not null.
        optionName - the option name wanted
        defaultValue - a default value
        Returns:
        the map for the option name or the default value. Could be null if not found.
        Throws:
        java.io.IOException - if any
      • getMavenCompilerPluginOptions

        public static java.util.Map[] getMavenCompilerPluginOptions​(org.apache.maven.project.MavenProject project,
                                                                    java.lang.String optionName,
                                                                    java.lang.String defaultValue)
                                                             throws java.io.IOException
        Return an array of map of optionName value defined in a project for the "maven-compiler-plugin" plugin.
        Parameters:
        project - not null
        optionName - the option name wanted
        defaultValue - a default value
        Returns:
        the array of option name or the default value. Could be null if not found.
        Throws:
        java.io.IOException - if any
      • getMavenSurefirePluginBasicOption

        public static java.lang.String getMavenSurefirePluginBasicOption​(org.apache.maven.project.MavenProject project,
                                                                         java.lang.String optionName,
                                                                         java.lang.String defaultValue)
                                                                  throws java.io.IOException
        Return the optionName value defined in a project for the "maven-surefire-plugin" plugin.
        Parameters:
        project - not null
        optionName - the option name wanted
        defaultValue - a default value
        Returns:
        the value for the option name or the default value. Could be null if not found.
        Throws:
        java.io.IOException - if any
      • getMavenSurefirePluginOption

        public static java.util.Map getMavenSurefirePluginOption​(org.apache.maven.project.MavenProject project,
                                                                 java.lang.String optionName,
                                                                 java.lang.String defaultValue)
                                                          throws java.io.IOException
        Return the map of optionName value defined in a project for the "maven-surefire-plugin" plugin.
        Parameters:
        project - not null
        optionName - the option name wanted
        defaultValue - a default value
        Returns:
        the map for the option name or the default value. Could be null if not found.
        Throws:
        java.io.IOException - if any
      • getMavenSurefirePluginOptions

        public static java.util.Map[] getMavenSurefirePluginOptions​(org.apache.maven.project.MavenProject project,
                                                                    java.lang.String optionName,
                                                                    java.lang.String defaultValue)
                                                             throws java.io.IOException
        Return an array of map of optionName value defined in a project for the "maven-surefire-plugin" plugin.
        Parameters:
        project - not null
        optionName - the option name wanted
        defaultValue - a default value
        Returns:
        the array of option name or the default value. Could be null if not found.
        Throws:
        java.io.IOException - if any
      • getMavenJavadocPluginBasicOption

        public static java.lang.String getMavenJavadocPluginBasicOption​(org.apache.maven.project.MavenProject project,
                                                                        java.lang.String optionName,
                                                                        java.lang.String defaultValue)
                                                                 throws java.io.IOException
        Return the optionName value defined in a project for the "maven-javadoc-plugin" plugin.
        Parameters:
        project - not null
        optionName - the option name wanted
        defaultValue - a default value
        Returns:
        the value for the option name or the default value. Could be null if not found.
        Throws:
        java.io.IOException - if any
      • getMavenJavadocPluginOption

        public static java.util.Map getMavenJavadocPluginOption​(org.apache.maven.project.MavenProject project,
                                                                java.lang.String optionName,
                                                                java.lang.String defaultValue)
                                                         throws java.io.IOException
        Return a map of optionName value defined in a project for the "maven-javadoc-plugin" plugin.
        Parameters:
        project - not null
        optionName - the option name wanted
        defaultValue - a default value
        Returns:
        the map for the option name or the default value. Could be null if not found.
        Throws:
        java.io.IOException - if any
      • getMavenJavadocPluginOptions

        public static java.util.Map[] getMavenJavadocPluginOptions​(org.apache.maven.project.MavenProject project,
                                                                   java.lang.String optionName,
                                                                   java.lang.String defaultValue)
                                                            throws java.io.IOException
        Return an array of map of optionName value defined in a project for the "maven-javadoc-plugin" plugin.
        Parameters:
        project - not null
        optionName - the option name wanted
        defaultValue - a default value
        Returns:
        an array of option name. Could be null if not found.
        Throws:
        java.io.IOException - if any
      • getMavenJarPluginBasicOption

        public static java.lang.String getMavenJarPluginBasicOption​(org.apache.maven.project.MavenProject project,
                                                                    java.lang.String optionName,
                                                                    java.lang.String defaultValue)
                                                             throws java.io.IOException
        Return the optionName value defined in a project for the "maven-jar-plugin" plugin.
        Parameters:
        project - not null
        optionName - the option name wanted
        defaultValue - a default value
        Returns:
        the value for the option name or the default value. Could be null if not found.
        Throws:
        java.io.IOException - if any
      • getMavenEarPluginBasicOption

        public static java.lang.String getMavenEarPluginBasicOption​(org.apache.maven.project.MavenProject project,
                                                                    java.lang.String optionName,
                                                                    java.lang.String defaultValue)
                                                             throws java.io.IOException
        Return the optionName value defined in a project for the "maven-ear-plugin" plugin.
        Parameters:
        project - not null
        optionName - the option name wanted
        defaultValue - a default value
        Returns:
        the value for the option name or the default value. Could be null if not found.
        Throws:
        java.io.IOException - if any
      • getMavenWarPluginBasicOption

        public static java.lang.String getMavenWarPluginBasicOption​(org.apache.maven.project.MavenProject project,
                                                                    java.lang.String optionName,
                                                                    java.lang.String defaultValue)
                                                             throws java.io.IOException
        Return the optionName value defined in a project for the "maven-war-plugin" plugin.
        Parameters:
        project - not null
        optionName - the option name wanted
        defaultValue - a default value
        Returns:
        the value for the option name or the default value. Could be null if not found.
        Throws:
        java.io.IOException - if any
      • getMavenPluginBasicOption

        private static java.lang.String getMavenPluginBasicOption​(org.apache.maven.project.MavenProject project,
                                                                  java.lang.String pluginArtifactId,
                                                                  java.lang.String optionName,
                                                                  java.lang.String defaultValue)
                                                           throws java.io.IOException
        Return the value for the option optionName defined in a project with the given artifactId plugin.
        Example:
        Configuration Result
        <option>value</option>
        value
        Parameters:
        project - not null
        pluginArtifactId - not null
        optionName - an Xpath expression from the plugin <configuration/>
        defaultValue - could be null
        Returns:
        the value for the option name or null if not found
        Throws:
        java.io.IOException - if any
      • getMavenPluginOption

        private static java.util.Map getMavenPluginOption​(org.apache.maven.project.MavenProject project,
                                                          java.lang.String pluginArtifactId,
                                                          java.lang.String optionName,
                                                          java.lang.String defaultValue)
                                                   throws java.io.IOException
        Return a Map for the option optionName defined in a project with the given artifactId plugin.
        Example:
        Configuration Result
         <option>
          <param1>value1</param1>
          <param2>value2</param2>
         </option>
         
        {param1=value1, param2=value2}
        Parameters:
        project - not null
        pluginArtifactId - not null
        optionName - an Xpath expression from the plugin <configuration/>
        defaultValue - could be null
        Returns:
        the value for the option name or null if not found
        Throws:
        java.io.IOException - if any
      • getMavenPluginOptions

        private static java.util.Map[] getMavenPluginOptions​(org.apache.maven.project.MavenProject project,
                                                             java.lang.String pluginArtifactId,
                                                             java.lang.String optionName,
                                                             java.lang.String defaultValue)
                                                      throws java.io.IOException
        Return an array of Map for the option optionName defined in a project with the given artifactId plugin.
        Example:
        Configuration Result
         <options>
           <option>
            <param1>value1</param1>
            <param2>value2</param2>
           </option>
           <option>
            <param1>value1</param1>
            <param2>value2</param2>
           </option>
         </options>
         
        [{option=[{param1=value1, param2=value2}]}, {option=[{param1=value1, param2=value2}]
        Parameters:
        project - not null
        pluginArtifactId - not null
        optionName - an Xpath expression from the plugin <configuration/>
        defaultValue - could be null
        Returns:
        the value for the option name or null if not found
        Throws:
        java.io.IOException - if any
      • getMavenPluginConfigurationsImpl

        private static java.util.Map getMavenPluginConfigurationsImpl​(org.apache.maven.project.MavenProject project,
                                                                      java.lang.String pluginArtifactId,
                                                                      java.lang.String optionName,
                                                                      java.lang.String defaultValue)
                                                               throws java.io.IOException
        Return a Map for the option optionName defined in a project with the given artifactId plugin.
        Example:
        Configuration Result
        <option>value</option>
        {option=value}
         <option>
          <param1>value1</param1>
          <param2>value2</param2>
         </option>
         
        {option={param1=value1, param2=value2}}
         <options>
           <option>
            <param1>value1</param1>
            <param2>value2</param2>
           </option>
           <option>
            <param1>value1</param1>
            <param2>value2</param2>
           </option>
         </options>
         
        {options=[{option=[{param1=value1, param2=value2}]}, {option=[{param1=value1, param2=value2}]}]
             
        Parameters:
        project - not null
        pluginArtifactId - not null
        optionName - an Xpath expression from the plugin <configuration/>
        defaultValue - could be null
        Returns:
        a map with the options found
        Throws:
        java.io.IOException - if any
      • writeCopyLib

        private static void writeCopyLib​(org.codehaus.plexus.util.xml.XMLWriter writer,
                                         org.apache.maven.project.MavenProject project,
                                         ArtifactResolverWrapper artifactResolverWrapper,
                                         java.lang.String outputDir)
        Write copy tasks in an outputDir for EAR and WAR targets for project depencies without provided or test as scope
        Parameters:
        writer - not null
        project - not null
        artifactResolverWrapper - not null
        outputDir - not null
      • isList

        private static boolean isList​(org.w3c.dom.Node node)
        Check if a given node is a list of nodes or not.
        For instance, the node options is a list of option in the following case:
         <options>
           <option>
            <param1>value1</param1>
            <param2>value2</param2>
           </option>
           <option>
            <param1>value1</param1>
            <param2>value2</param2>
           </option>
         </options>
         
        Parameters:
        node - a given node, may be null.
        Returns:
        true if the node is a list, false otherwise.
      • isElementContent

        private static boolean isElementContent​(org.w3c.dom.Node node)
        Checks whether the specified node has element content or consists only of character data.
        Parameters:
        node - The node to test, may be null.
        Returns:
        true if any child node is an element, false otherwise.
      • getTextContent

        private static java.lang.String getTextContent​(org.w3c.dom.Node node)
        Gets the text content of the specified node.
        Parameters:
        node - The node whose text contents should be retrieved, may be null.
        Returns:
        The text content of the node, can be empty but never null.
      • getSingularForm

        static java.lang.String getSingularForm​(java.lang.String pluralForm)
        Gets the singular form of the specified (English) plural form. For example:

         properties -> property
         branches   -> branch
         reports    -> report
         
        Parameters:
        pluralForm - The plural form for which to derive the singular form, may be null.
        Returns:
        The corresponding singular form or an empty string if the input string was not recognized as a plural form.
      • toRelative

        static java.lang.String toRelative​(java.io.File basedir,
                                           java.lang.String path)
        Relativizes the specified path against the given base directory (if possible). If the specified path is a subdirectory of the base directory, the base directory prefix will be chopped off. If the specified path is equal to the base directory, the path "." is returned. Otherwise, the path is returned as is. Examples:
        basedir path result
        /home /home/dir dir
        /home /home/dir/ dir/
        /home /home .
        /home /home/ ./
        /home dir dir
        The returned path will always use the forward slash ('/') as the file separator regardless of the current platform. Also, the result path will have a trailing slash if the input path has a trailing file separator.
        Parameters:
        basedir - The base directory to relativize the path against, must not be null.
        path - The path to relativize, must not be null.
        Returns:
        The relativized path, never null.