Uploaded image for project: 'Maven Site Plugin'
  1. Maven Site Plugin
  2. MSITE-245

parent filesystem site.xml is never be found

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Blocker
    • Resolution: Fixed
    • 2.0-beta-5
    • None
    • inheritance
    • None
    • 2.0.7
    • Patch

    Description

      The current approach used by the getSiteDescriptorFile(File, Locale) is wrong as the basedir passed in to it is not just the project's own basedir, it's potentially a parent project's basedir and thus the previous code makes no sense as we would need to add on the parent's site.xml site directory and then try and find the relative path to it and as there's no way (that I know of) of a) finding that out from the parent project's object model (even if we passed it in) and b) the current code does not append anything to the passed in basedir so is always looking for a site.xml in the parents root directory. What's more the use of a relative path here is pointless too as we simply read in the descriptor file, not persist it into links where relativePaths are useful.

      Current code:

          protected File getSiteDescriptorFile( File basedir, Locale locale )
          {
             String relativePath = getRelativePath( siteDirectory.getAbsolutePath(), basedir.getAbsolutePath() );
      
              File siteDescriptor = new File( relativePath, "site_" + locale.getLanguage() + ".xml" );
      
              if ( !siteDescriptor.exists() )
              {
                  siteDescriptor = new File( relativePath, "site.xml" );
              }
              return siteDescriptor;
          }
      

      Fixed code

          protected File getSiteDescriptorFile( File basedir, Locale locale )
          {
              String sitePath;
              
              if ( basedir.equals( project.getBasedir() ))
              {
                  // it's this project's basedir so use our siteDirectory (allows this project
                  // to use a custom site location)
                  
                  sitePath = siteDirectory.getAbsolutePath();
              }
              else
              {
                  // it's not this project's basedir so it must be one of our parent's,
                  // so we'll just have to assume they store their site.xml in the
                  // standard location (src/site)
                  
                  sitePath = basedir.getAbsolutePath() + "/src/site";
              }
              
              File siteDescriptor = new File( sitePath, "site_" + locale.getLanguage() + ".xml" );
      
              if ( !siteDescriptor.exists() )
              {
                  siteDescriptor = new File( sitePath, "site.xml" );
              }
      
              return siteDescriptor;
      

      Attachments

        1. site-patch.txt
          2 kB
          skaze

        Issue Links

          Activity

            People

              ltheussl Lukas Theussl
              skaze skaze
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: