Package org.apache.maven.doxia.tools
Class DefaultSiteTool
- java.lang.Object
-
- org.apache.maven.doxia.tools.DefaultSiteTool
-
- All Implemented Interfaces:
SiteTool
@Singleton @Named public class DefaultSiteTool extends Object implements SiteTool
Default implementation of the site tool.- Author:
- Vincent Siveton
-
-
Field Summary
Fields Modifier and Type Field Description protected DecorationModelInheritanceAssembler
assembler
The component for assembling inheritance.protected org.codehaus.plexus.i18n.I18N
i18n
Internationalization.protected org.apache.maven.project.ProjectBuilder
projectBuilder
Project builder.-
Fields inherited from interface org.apache.maven.doxia.tools.SiteTool
DEFAULT_LOCALE
-
-
Constructor Summary
Constructors Constructor Description DefaultSiteTool()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description DecorationModel
getDecorationModel(File siteDirectory, Locale locale, org.apache.maven.project.MavenProject project, List<org.apache.maven.project.MavenProject> reactorProjects, org.apache.maven.artifact.repository.ArtifactRepository localRepository, List<org.apache.maven.artifact.repository.ArtifactRepository> repositories)
Get a decoration model for a project.String
getInterpolatedSiteDescriptorContent(Map<String,String> props, org.apache.maven.project.MavenProject aProject, String siteDescriptorContent)
Interpolating several expressions in the site descriptor content.protected static String
getNormalizedPath(String path)
org.apache.maven.project.MavenProject
getParentProject(org.apache.maven.project.MavenProject aProject, List<org.apache.maven.project.MavenProject> reactorProjects, org.apache.maven.artifact.repository.ArtifactRepository localRepository)
Returns the parent POM with interpolated URLs.String
getRelativePath(String to, String from)
Deprecated.File
getSiteDescriptor(File siteDirectory, Locale locale)
Get a site descriptor from the project's site directory.List<Locale>
getSiteLocales(String locales)
Extracts from a comma-separated list the locales that are available insite-tool
resource bundle.org.apache.maven.artifact.Artifact
getSkinArtifactFromRepository(org.apache.maven.artifact.repository.ArtifactRepository localRepository, List<org.apache.maven.artifact.repository.ArtifactRepository> remoteArtifactRepositories, DecorationModel decoration)
Get a skin artifact from one of the repositories.void
populateReportsMenu(DecorationModel decorationModel, Locale locale, Map<String,List<org.apache.maven.reporting.MavenReport>> categories)
Populate the pre-definedreports
menu of the decoration model, if used through<menu ref="reports"/>
.
-
-
-
Field Detail
-
i18n
@Inject protected org.codehaus.plexus.i18n.I18N i18n
Internationalization.
-
assembler
@Inject protected DecorationModelInheritanceAssembler assembler
The component for assembling inheritance.
-
projectBuilder
@Inject protected org.apache.maven.project.ProjectBuilder projectBuilder
Project builder.
-
-
Method Detail
-
getSkinArtifactFromRepository
public org.apache.maven.artifact.Artifact getSkinArtifactFromRepository(org.apache.maven.artifact.repository.ArtifactRepository localRepository, List<org.apache.maven.artifact.repository.ArtifactRepository> remoteArtifactRepositories, DecorationModel decoration) throws SiteToolException
Description copied from interface:SiteTool
Get a skin artifact from one of the repositories.- Specified by:
getSkinArtifactFromRepository
in interfaceSiteTool
- Parameters:
localRepository
- the Maven local repository, not null.remoteArtifactRepositories
- the Maven remote repositories, not null.decoration
- the Doxia site descriptor model, not null.- Returns:
- the
Skin
artifact defined in aDecorationModel
from a given project and a local repository - Throws:
SiteToolException
- if any
-
getRelativePath
@Deprecated public String getRelativePath(String to, String from)
Deprecated.This method is not implemented according to the URI specification and has many weird corner cases where it doesn't do the right thing. Please consider using a better implemented method from a different library such as org.apache.http.client.utils.URIUtils#resolve.- Specified by:
getRelativePath
in interfaceSiteTool
- Parameters:
to
- theto
url of file as stringfrom
- thefrom
url of file as string- Returns:
- a relative path from
from
toto
.
-
getSiteDescriptor
public File getSiteDescriptor(File siteDirectory, Locale locale)
Get a site descriptor from the project's site directory.- Specified by:
getSiteDescriptor
in interfaceSiteTool
- Parameters:
siteDirectory
- the site directory, not nulllocale
- the locale wanted for the site descriptor, not null. Most specific to least specific lookup fromsite_language_country_variant.xml
,site_language_country.xml
,site_language.xml}
, tosite.xml
as last resort forLocale.ROOT
, if provided locale defines a variant and/or a country and/or a language.- Returns:
- the most specific site descriptor file for the given locale
-
getDecorationModel
public DecorationModel getDecorationModel(File siteDirectory, Locale locale, org.apache.maven.project.MavenProject project, List<org.apache.maven.project.MavenProject> reactorProjects, org.apache.maven.artifact.repository.ArtifactRepository localRepository, List<org.apache.maven.artifact.repository.ArtifactRepository> repositories) throws SiteToolException
Get a decoration model for a project.- Specified by:
getDecorationModel
in interfaceSiteTool
- Parameters:
siteDirectory
- the site directory, may be null if project from repositorylocale
- the locale used for the i18n in DecorationModel, not null. SeeSiteTool.getSiteDescriptor(File, Locale)
for details.project
- the Maven project, not null.reactorProjects
- the Maven reactor projects, not null.localRepository
- the Maven local repository, not null.repositories
- the Maven remote repositories, not null.- Returns:
- the
DecorationModel
object corresponding to thesite.xml
file with some interpolations. - Throws:
SiteToolException
- if any
-
getInterpolatedSiteDescriptorContent
public String getInterpolatedSiteDescriptorContent(Map<String,String> props, org.apache.maven.project.MavenProject aProject, String siteDescriptorContent) throws SiteToolException
Interpolating several expressions in the site descriptor content. Actually, the expressions can be in the project, the environment variables and the specific properties likeencoding
.For instance:
- ${project.name}
- The value from the POM of:
<project>
<name>myProjectName</name>
</project> - ${my.value}
- The value from the POM of:
<properties>
<my.value>hello</my.value>
</properties> - ${JAVA_HOME}
- The value of JAVA_HOME in the environment variables
- Specified by:
getInterpolatedSiteDescriptorContent
in interfaceSiteTool
- Parameters:
props
- a map used for interpolation, not null.aProject
- a Maven project, not null.siteDescriptorContent
- the site descriptor file, not null.- Returns:
- the interpolated site descriptor content.
- Throws:
SiteToolException
- if errors happened during the interpolation.
-
getParentProject
public org.apache.maven.project.MavenProject getParentProject(org.apache.maven.project.MavenProject aProject, List<org.apache.maven.project.MavenProject> reactorProjects, org.apache.maven.artifact.repository.ArtifactRepository localRepository)
Returns the parent POM with interpolated URLs. If called from Maven 3, just returnsproject.getParent()
, which is already interpolated. But when called from Maven 2, attempts to source this value from thereactorProjects
parameters if available (reactor env model attributes are interpolated), or if the reactor is unavailable (-N) resorts to theproject.getParent().getUrl()
value which will NOT have been interpolated.- Specified by:
getParentProject
in interfaceSiteTool
- Parameters:
aProject
- a Maven project, not null.reactorProjects
- the Maven reactor projects, not null.localRepository
- the Maven local repository, not null.- Returns:
- the parent project with interpolated URLs.
-
populateReportsMenu
public void populateReportsMenu(DecorationModel decorationModel, Locale locale, Map<String,List<org.apache.maven.reporting.MavenReport>> categories)
Populate the pre-definedreports
menu of the decoration model, if used through<menu ref="reports"/>
. Notice this menu reference is translated into 2 separate menus: "Project Information" and "Project Reports".- Specified by:
populateReportsMenu
in interfaceSiteTool
- Parameters:
decorationModel
- the Doxia Sitetools DecorationModel, not null.locale
- the locale used for the i18n in DecorationModel, not null. SeeSiteTool.getSiteDescriptor(File, Locale)
for details.categories
- reports per category to put in "Reports" or "Information" menus, not null.- See Also:
MavenReport.CATEGORY_PROJECT_INFORMATION
,MavenReport.CATEGORY_PROJECT_REPORTS
-
getSiteLocales
public List<Locale> getSiteLocales(String locales)
Extracts from a comma-separated list the locales that are available insite-tool
resource bundle.- Specified by:
getSiteLocales
in interfaceSiteTool
- Parameters:
locales
- A comma separated list of locales- Returns:
- a list of
Locale
s.
-
-