Details
-
Bug
-
Status: Closed
-
Blocker
-
Resolution: Fixed
-
2.0-beta-5
-
None
-
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
Attachments
Issue Links
- is related to
-
MSITE-81 Site descriptor resolution never falls back to site.xml
- Closed
- is superceded by
-
MSHARED-18 Inheritance of elements from site descriptor quite broken
- Closed