Author: hboutemy
Date: Thu Dec 17 18:33:15 2015
New Revision: 1720625
URL: http://svn.apache.org/viewvc?rev=1720625&view=rev
Log:
[DOXIASITETOOLS-125] fixed site directory propagation from project to parent
Modified:
maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java
maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/SiteTool.java
maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/SiteToolTest.java
Modified:
maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java
URL:
http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java?rev=1720625&r1=1720624&r2=1720625&view=diff
==============================================================================
---
maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java
(original)
+++
maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/DefaultSiteTool.java
Thu Dec 17 18:33:15 2015
@@ -325,6 +325,7 @@ public class DefaultSiteTool
/** {@inheritDoc} */
public File getSiteDescriptor( File siteDirectory, Locale locale )
{
+ checkNotNull( "siteDirectory", siteDirectory );
final Locale llocale = ( locale == null ) ? new Locale( "" ) : locale;
File siteDescriptor = new File( siteDirectory, "site_" +
llocale.getLanguage() + ".xml" );
@@ -391,6 +392,8 @@ public class DefaultSiteTool
final Locale llocale = ( locale == null ) ? Locale.getDefault() :
locale;
+ getLogger().debug( "Computing decoration model for locale " + llocale
);
+
Map<String, String> props = new HashMap<String, String>( 2 );
// This is to support the deprecated ${reports} and ${modules} tags.
@@ -404,6 +407,8 @@ public class DefaultSiteTool
if ( decorationModel == null )
{
+ getLogger().debug( "Using default site descriptor" );
+
String siteDescriptorContent;
InputStream in = null;
@@ -442,6 +447,11 @@ public class DefaultSiteTool
decorationModel.setBannerLeft( banner );
}
+ if ( decorationModel != null && decorationModel.getSkin() != null )
+ {
+ getLogger().debug( "Skin used: " + decorationModel.getSkin() );
+ }
+
return decorationModel;
}
@@ -1015,12 +1025,12 @@ public class DefaultSiteTool
}
/**
+ * @param siteDirectory, can be null if project.basedir is null, ie POM
from repository
+ * @param locale not null
* @param project not null
* @param reactorProjects not null
* @param localRepository not null
* @param repositories not null
- * @param siteDirectory may be null
- * @param locale not null
* @param origProps not null
* @return the decoration model depending the locale
* @throws SiteToolException if any
@@ -1064,6 +1074,10 @@ public class DefaultSiteTool
siteDescriptorContent = IOUtil.toString( siteDescriptorReader
);
siteDescriptorLastModified = siteDescriptor.lastModified();
}
+ else
+ {
+ getLogger().debug( "No site descriptor found for " +
project.getId() );
+ }
}
catch ( IOException e )
{
@@ -1085,12 +1099,25 @@ public class DefaultSiteTool
if ( parentProject != null && ( decoration == null ||
decoration.isMergeParent() ) )
{
- getLogger().debug( "Loading parent project site descriptor..." );
+ getLogger().debug( "Looking for parent project site descriptor: "
+ parentProject.getId() );
MavenProject parentParentProject = getParentProject(
parentProject, reactorProjects, localRepository );
- DecorationModel parent = getDecorationModel( null, locale,
parentProject, parentParentProject,
- reactorProjects,
localRepository, repositories, props );
+ File parentSiteDirectory = null;
+
+ if ( parentProject.getBasedir() != null )
+ {
+ String siteRelativePath = getRelativeFilePath(
project.getBasedir().getAbsolutePath(),
+
siteDescriptor.getParentFile().getAbsolutePath() );
+
+ parentSiteDirectory = new File( parentProject.getBasedir(),
siteRelativePath );
+ // notice: using same siteRelativePath for parent as current
project; may be wrong if site plugin
+ // has different configuration. But this is a rare case (this
only has impact if parent if from reactor)
+ }
+
+ DecorationModel parent =
+ getDecorationModel( parentSiteDirectory, locale,
parentProject, parentParentProject, reactorProjects,
+ localRepository, repositories, props );
// MSHARED-116 requires an empty decoration model (instead of a
null one)
// MSHARED-145 requires us to do this only if there is a parent to
merge it with
@@ -1111,18 +1138,13 @@ public class DefaultSiteTool
String parentDistMgmnt = getDistMgmntSiteUrl( parentProject );
if ( getLogger().isDebugEnabled() )
{
- getLogger().debug( "model inheritance
distributionManagement.site.url child = " + projectDistMgmnt
- + ", parent = " + parentDistMgmnt );
+ getLogger().debug( "assembling decoration model inheritance:
distributionManagement.site.url child = " + projectDistMgmnt
+ + " and parent = " + parentDistMgmnt );
}
assembler.assembleModelInheritance( name, decoration, parent,
projectDistMgmnt,
parentDistMgmnt == null ?
projectDistMgmnt : parentDistMgmnt );
}
- if ( decoration != null && decoration.getSkin() != null )
- {
- getLogger().debug( "Skin used: " + decoration.getSkin() );
- }
-
return decoration;
}
Modified:
maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/SiteTool.java
URL:
http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/SiteTool.java?rev=1720625&r1=1720624&r2=1720625&view=diff
==============================================================================
---
maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/SiteTool.java
(original)
+++
maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/main/java/org/apache/maven/doxia/tools/SiteTool.java
Thu Dec 17 18:33:15 2015
@@ -80,7 +80,7 @@ public interface SiteTool
/**
* Get a site descriptor from the project's site directory.
*
- * @param siteDirectory the site directory
+ * @param siteDirectory the site directory, not null
* @param locale the locale wanted for the site descriptor. If not null,
searching for
* <code>site_<i>localeLanguage</i>.xml</code>, otherwise searching for
<code>site.xml</code>.
* @return the site descriptor file
@@ -124,7 +124,7 @@ public interface SiteTool
/**
* Get a decoration model for a project.
*
- * @param siteDirectory the site directory, may be <code>null</code>
+ * @param siteDirectory the site directory, may be null if project from
repository
* @param locale the locale used for the i18n in DecorationModel. If null,
using the default locale in the jvm.
* @param project the Maven project, not null.
* @param reactorProjects the Maven reactor projects, not null.
Modified:
maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/SiteToolTest.java
URL:
http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/SiteToolTest.java?rev=1720625&r1=1720624&r2=1720625&view=diff
==============================================================================
---
maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/SiteToolTest.java
(original)
+++
maven/doxia/doxia-sitetools/trunk/doxia-integration-tools/src/test/java/org/apache/maven/doxia/tools/SiteToolTest.java
Thu Dec 17 18:33:15 2015
@@ -258,19 +258,34 @@ public class SiteToolTest
project.setVersion( "1.0" );
List<MavenProject> reactorProjects = new ArrayList<MavenProject>();
- project.setBasedir( null ); // get it from repo
-
- DecorationModel model = tool.getDecorationModel( null,
Locale.getDefault(), project, reactorProjects,
- getLocalRepo(),
project.getRemoteArtifactRepositories() );
+ // model from current local build
+ DecorationModel model =
+ tool.getDecorationModel( new File( project.getBasedir(),
"src/site" ), Locale.getDefault(), project,
+ reactorProjects, getLocalRepo(),
project.getRemoteArtifactRepositories() );
assertNotNull( model );
assertNotNull( model.getBannerLeft() );
- assertEquals( "Maven", model.getBannerLeft().getName() );
- assertEquals( "images/apache-maven-project-2.png",
model.getBannerLeft().getSrc() );
+ assertEquals( "Maven Site", model.getBannerLeft().getName() );
+ assertEquals(
"http://maven.apache.org/images/apache-maven-project.png",
model.getBannerLeft().getSrc() );
assertEquals( "http://maven.apache.org/",
model.getBannerLeft().getHref() );
assertNotNull( model.getBannerRight() );
assertNull( model.getBannerRight().getName() );
- assertEquals( "images/maven-logo-2.gif",
model.getBannerRight().getSrc() );
+ assertEquals( "http://maven.apache.org/images/maven-small.gif",
model.getBannerRight().getSrc() );
assertNull( model.getBannerRight().getHref() );
+
+ // model from repo:
http://repo1.maven.org/maven2/org/apache/maven/maven-site/1.0/maven-site-1.0-site.xml
+ project.setBasedir( null );
+ DecorationModel modelFromRepo =
+ tool.getDecorationModel( null, Locale.getDefault(), project,
reactorProjects, getLocalRepo(),
+ project.getRemoteArtifactRepositories() );
+ assertNotNull( modelFromRepo );
+ assertNotNull( modelFromRepo.getBannerLeft() );
+ assertEquals( "Maven", modelFromRepo.getBannerLeft().getName() );
+ assertEquals( "images/apache-maven-project-2.png",
modelFromRepo.getBannerLeft().getSrc() );
+ assertEquals( "http://maven.apache.org/",
modelFromRepo.getBannerLeft().getHref() );
+ assertNotNull( modelFromRepo.getBannerRight() );
+ assertNull( modelFromRepo.getBannerRight().getName() );
+ assertEquals( "images/maven-logo-2.gif",
modelFromRepo.getBannerRight().getSrc() );
+ assertNull( modelFromRepo.getBannerRight().getHref() );
}
/**