Package org.apache.maven.doxia.tools
Class DefaultSiteTool
- java.lang.Object
-
- org.codehaus.plexus.logging.AbstractLogEnabled
-
- org.apache.maven.doxia.tools.DefaultSiteTool
-
- All Implemented Interfaces:
SiteTool,org.codehaus.plexus.logging.LogEnabled
public class DefaultSiteTool extends org.codehaus.plexus.logging.AbstractLogEnabled implements SiteTool
Default implementation of the site tool.- Version:
- $Id: DefaultSiteTool.java 1098159 2011-04-30 21:07:49Z dennisl $
- Author:
- Vincent Siveton
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.maven.doxia.site.decoration.inheritance.DecorationModelInheritanceAssemblerassemblerThe component for assembling inheritance.protected org.codehaus.plexus.i18n.I18Ni18nInternationalization.protected org.apache.maven.project.MavenProjectBuildermavenProjectBuilderProject builder.-
Fields inherited from interface org.apache.maven.doxia.tools.SiteTool
DEFAULT_LOCALE, ROLE
-
-
Constructor Summary
Constructors Constructor Description DefaultSiteTool()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description java.util.LocalecodeToLocale(java.lang.String localeCode)Converts a locale code like "en", "en_US" or "en_US_win" to ajava.util.Localeobject.java.util.List<java.util.Locale>getAvailableLocales(java.lang.String locales)Init thelocalesListvariable.org.apache.maven.doxia.site.decoration.DecorationModelgetDecorationModel(org.apache.maven.project.MavenProject project, java.util.List<org.apache.maven.project.MavenProject> reactorProjects, org.apache.maven.artifact.repository.ArtifactRepository localRepository, java.util.List<org.apache.maven.artifact.repository.ArtifactRepository> repositories, java.lang.String siteDirectory, java.util.Locale locale, java.lang.String inputEncoding, java.lang.String outputEncoding)Get a decoration model for a project.org.apache.maven.artifact.ArtifactgetDefaultSkinArtifact(org.apache.maven.artifact.repository.ArtifactRepository localRepository, java.util.List<org.apache.maven.artifact.repository.ArtifactRepository> remoteArtifactRepositories)Get the default skin artifact for a project from one of the repositories.java.lang.StringgetInterpolatedSiteDescriptorContent(java.util.Map<java.lang.String,java.lang.String> props, org.apache.maven.project.MavenProject aProject, java.lang.String siteDescriptorContent, java.lang.String inputEncoding, java.lang.String outputEncoding)Interpolating several expressions in the site descriptor content.protected static java.lang.StringgetNormalizedPath(java.lang.String path)org.apache.maven.project.MavenProjectgetParentProject(org.apache.maven.project.MavenProject aProject, java.util.List<org.apache.maven.project.MavenProject> reactorProjects, org.apache.maven.artifact.repository.ArtifactRepository localRepository)Returns the parent POM with interpolated URLs.java.lang.StringgetRelativePath(java.lang.String to, java.lang.String from)Calculate the relative path between two URLs or between two files.java.io.FilegetSiteDescriptorFromBasedir(java.lang.String siteDirectory, java.io.File basedir, java.util.Locale locale)Get a site descriptor from the project's base directory.java.io.FilegetSiteDescriptorFromRepository(org.apache.maven.project.MavenProject project, org.apache.maven.artifact.repository.ArtifactRepository localRepository, java.util.List<org.apache.maven.artifact.repository.ArtifactRepository> repositories, java.util.Locale locale)Get a site descriptor from one of the repositories.org.apache.maven.artifact.ArtifactgetSkinArtifactFromRepository(org.apache.maven.artifact.repository.ArtifactRepository localRepository, java.util.List<org.apache.maven.artifact.repository.ArtifactRepository> remoteArtifactRepositories, org.apache.maven.doxia.site.decoration.DecorationModel decoration)Get a skin artifact from one of the repositories.voidpopulateModules(org.apache.maven.project.MavenProject project, java.util.List<org.apache.maven.project.MavenProject> reactorProjects, org.apache.maven.artifact.repository.ArtifactRepository localRepository, org.apache.maven.doxia.site.decoration.DecorationModel decorationModel, java.util.Locale locale, boolean keepInheritedRefs)Deprecated.voidpopulateModulesMenu(org.apache.maven.project.MavenProject project, java.util.List<org.apache.maven.project.MavenProject> reactorProjects, org.apache.maven.artifact.repository.ArtifactRepository localRepository, org.apache.maven.doxia.site.decoration.DecorationModel decorationModel, java.util.Locale locale, boolean keepInheritedRefs)Populate the modules menu part of the decoration model.voidpopulateParentMenu(org.apache.maven.doxia.site.decoration.DecorationModel decorationModel, java.util.Locale locale, org.apache.maven.project.MavenProject project, org.apache.maven.project.MavenProject parentProject, boolean keepInheritedRefs)Populate the parent menu part of the decoration model.voidpopulateProjectParentMenu(org.apache.maven.doxia.site.decoration.DecorationModel decorationModel, java.util.Locale locale, org.apache.maven.project.MavenProject project, org.apache.maven.project.MavenProject parentProject, boolean keepInheritedRefs)Deprecated.voidpopulateReportsMenu(org.apache.maven.doxia.site.decoration.DecorationModel decorationModel, java.util.Locale locale, java.util.Map<java.lang.String,java.util.List<org.apache.maven.reporting.MavenReport>> categories)Populate the reports menu part of the decoration model.
-
-
-
Field Detail
-
i18n
protected org.codehaus.plexus.i18n.I18N i18n
Internationalization.
-
assembler
protected org.apache.maven.doxia.site.decoration.inheritance.DecorationModelInheritanceAssembler assembler
The component for assembling inheritance.
-
mavenProjectBuilder
protected org.apache.maven.project.MavenProjectBuilder mavenProjectBuilder
Project builder.
-
-
Method Detail
-
getSkinArtifactFromRepository
public org.apache.maven.artifact.Artifact getSkinArtifactFromRepository(org.apache.maven.artifact.repository.ArtifactRepository localRepository, java.util.List<org.apache.maven.artifact.repository.ArtifactRepository> remoteArtifactRepositories, org.apache.maven.doxia.site.decoration.DecorationModel decoration) throws SiteToolExceptionGet a skin artifact from one of the repositories.- Specified by:
getSkinArtifactFromRepositoryin 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
Skinartifact defined in aDecorationModelfrom a given project and a local repository - Throws:
SiteToolException- if any
-
getDefaultSkinArtifact
public org.apache.maven.artifact.Artifact getDefaultSkinArtifact(org.apache.maven.artifact.repository.ArtifactRepository localRepository, java.util.List<org.apache.maven.artifact.repository.ArtifactRepository> remoteArtifactRepositories) throws SiteToolExceptionGet the default skin artifact for a project from one of the repositories.- Specified by:
getDefaultSkinArtifactin interfaceSiteTool- Parameters:
localRepository- the Maven local repository, not null.remoteArtifactRepositories- the Maven remote repositories, not null.- Returns:
- the default
Skinartifact from a given project and a local repository - Throws:
SiteToolException- if any- See Also:
Skin.getDefaultSkin(),SiteTool.getSkinArtifactFromRepository(ArtifactRepository, List, DecorationModel)
-
getRelativePath
public java.lang.String getRelativePath(java.lang.String to, java.lang.String from)Calculate the relative path between two URLs or between two files. For example:- to = "http://maven.apache.org" and from = "http://maven.apache.org"
- return ""
- to = "http://maven.apache.org" and from = "http://maven.apache.org/plugins/maven-site-plugin/"
- return "../.."
- to = "http://maven.apache.org/plugins/maven-site-plugin/" and from = "http://maven.apache.org"
- return "plugins/maven-site-plugin"
- to = "/myproject/myproject-module1" and from = "/myproject/myproject"
- return "../myproject-module1"
- Specified by:
getRelativePathin interfaceSiteTool- Parameters:
to- thetourl of file as stringfrom- thefromurl of file as string- Returns:
- a relative path from
fromtoto.
-
getSiteDescriptorFromBasedir
public java.io.File getSiteDescriptorFromBasedir(java.lang.String siteDirectory, java.io.File basedir, java.util.Locale locale)Get a site descriptor from the project's base directory.- Specified by:
getSiteDescriptorFromBasedirin interfaceSiteTool- Parameters:
siteDirectory- The path to the directory containing thesite.xmlfile, relative to the project base directory. If null, using by default "src/site".basedir- not null.locale- the locale wanted for the site descriptor. If not null, searching forsite_localeLanguage.xml, otherwise searching forsite.xml.- Returns:
- the site descriptor relative file, i.e.
src/site/site.xml, depending on parameter values.
-
getSiteDescriptorFromRepository
public java.io.File getSiteDescriptorFromRepository(org.apache.maven.project.MavenProject project, org.apache.maven.artifact.repository.ArtifactRepository localRepository, java.util.List<org.apache.maven.artifact.repository.ArtifactRepository> repositories, java.util.Locale locale) throws SiteToolExceptionGet a site descriptor from one of the repositories.- Specified by:
getSiteDescriptorFromRepositoryin interfaceSiteTool- Parameters:
project- the Maven project, not null.localRepository- the Maven local repository, not null.repositories- the Maven remote repositories, not null.locale- the locale wanted for the site descriptor. If not null, searching forsite_localeLanguage.xml, otherwise searching forsite.xml.- Returns:
- the site descriptor into the local repository after download of it from repositories or null if not found in repositories.
- Throws:
SiteToolException- if any
-
getDecorationModel
public org.apache.maven.doxia.site.decoration.DecorationModel getDecorationModel(org.apache.maven.project.MavenProject project, java.util.List<org.apache.maven.project.MavenProject> reactorProjects, org.apache.maven.artifact.repository.ArtifactRepository localRepository, java.util.List<org.apache.maven.artifact.repository.ArtifactRepository> repositories, java.lang.String siteDirectory, java.util.Locale locale, java.lang.String inputEncoding, java.lang.String outputEncoding) throws SiteToolExceptionGet a decoration model for a project.- Specified by:
getDecorationModelin interfaceSiteTool- Parameters:
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.siteDirectory- The path to the directory containing thesite.xmlfile, relative to the project base directory. If null, using by default "src/site".locale- the locale used for the i18n in DecorationModel. If null, using the default locale in the jvm.inputEncoding- the input encoding of the site descriptor, not null.outputEncoding- the output encoding wanted, not null.- Returns:
- the
DecorationModelobject corresponding to thesite.xmlfile with some interpolations. - Throws:
SiteToolException- if any
-
populateReportsMenu
public void populateReportsMenu(org.apache.maven.doxia.site.decoration.DecorationModel decorationModel, java.util.Locale locale, java.util.Map<java.lang.String,java.util.List<org.apache.maven.reporting.MavenReport>> categories)Populate the reports menu part of the decoration model.- Specified by:
populateReportsMenuin interfaceSiteTool- Parameters:
decorationModel- the Doxia DecorationModel, not null.locale- the locale used for the i18n in DecorationModel. If null, using the default locale in the jvm.categories- a map to put on the decoration model, not null.
-
getInterpolatedSiteDescriptorContent
public java.lang.String getInterpolatedSiteDescriptorContent(java.util.Map<java.lang.String,java.lang.String> props, org.apache.maven.project.MavenProject aProject, java.lang.String siteDescriptorContent, java.lang.String inputEncoding, java.lang.String outputEncoding) throws SiteToolExceptionInterpolating 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:
getInterpolatedSiteDescriptorContentin interfaceSiteTool- Parameters:
props- a map used for interpolation, not null.aProject- a Maven project, not null.siteDescriptorContent- the site descriptor file, not null.inputEncoding- the input encoding of the site descriptor, not null.outputEncoding- the output encoding wanted, not null.- Returns:
- the site descriptor content based on the
site.xmlfile with interpolated strings. - Throws:
SiteToolException- if errors happened during the interpolation.
-
getParentProject
public org.apache.maven.project.MavenProject getParentProject(org.apache.maven.project.MavenProject aProject, java.util.List<org.apache.maven.project.MavenProject> reactorProjects, org.apache.maven.artifact.repository.ArtifactRepository localRepository)Returns the parent POM with interpolated URLs. Attempts to source this value from thereactorProjectsparameters 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. TODO: once bug is fixed in Maven proper, remove this.- Specified by:
getParentProjectin 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.
-
populateParentMenu
public void populateParentMenu(org.apache.maven.doxia.site.decoration.DecorationModel decorationModel, java.util.Locale locale, org.apache.maven.project.MavenProject project, org.apache.maven.project.MavenProject parentProject, boolean keepInheritedRefs)Populate the parent menu part of the decoration model.- Specified by:
populateParentMenuin interfaceSiteTool- Parameters:
decorationModel- the Doxia DecorationModel, not null.locale- the locale used for the i18n in DecorationModel. If null, using the default locale in the jvm.project- a Maven project, not null.parentProject- a Maven parent project, not null.keepInheritedRefs- used for inherited references.
-
populateProjectParentMenu
public void populateProjectParentMenu(org.apache.maven.doxia.site.decoration.DecorationModel decorationModel, java.util.Locale locale, org.apache.maven.project.MavenProject project, org.apache.maven.project.MavenProject parentProject, boolean keepInheritedRefs)Deprecated.Populate the parent menu part of the decoration model.- Specified by:
populateProjectParentMenuin interfaceSiteTool- Parameters:
decorationModel- the Doxia DecorationModel, not null.locale- the locale used for the i18n in DecorationModel. If null, using the default locale in the jvm.project- a Maven project, not null.parentProject- a Maven parent project, not null.keepInheritedRefs- used for inherited references.
-
populateModules
public void populateModules(org.apache.maven.project.MavenProject project, java.util.List<org.apache.maven.project.MavenProject> reactorProjects, org.apache.maven.artifact.repository.ArtifactRepository localRepository, org.apache.maven.doxia.site.decoration.DecorationModel decorationModel, java.util.Locale locale, boolean keepInheritedRefs) throws SiteToolExceptionDeprecated.Populate the modules menu part of the decoration model.- Specified by:
populateModulesin interfaceSiteTool- Parameters:
project- a Maven project, not null.reactorProjects- the Maven reactor projects, not null.localRepository- the Maven local repository, not null.decorationModel- the Doxia site descriptor model, not null.locale- the locale used for the i18n in DecorationModel. If null, using the default locale in the jvm.keepInheritedRefs- used for inherited references.- Throws:
SiteToolException- if any
-
populateModulesMenu
public void populateModulesMenu(org.apache.maven.project.MavenProject project, java.util.List<org.apache.maven.project.MavenProject> reactorProjects, org.apache.maven.artifact.repository.ArtifactRepository localRepository, org.apache.maven.doxia.site.decoration.DecorationModel decorationModel, java.util.Locale locale, boolean keepInheritedRefs) throws SiteToolExceptionPopulate the modules menu part of the decoration model.- Specified by:
populateModulesMenuin interfaceSiteTool- Parameters:
project- a Maven project, not null.reactorProjects- the Maven reactor projects, not null.localRepository- the Maven local repository, not null.decorationModel- the Doxia site descriptor model, not null.locale- the locale used for the i18n in DecorationModel. If null, using the default locale in the jvm.keepInheritedRefs- used for inherited references.- Throws:
SiteToolException- if any
-
getAvailableLocales
public java.util.List<java.util.Locale> getAvailableLocales(java.lang.String locales)
Init thelocalesListvariable.If the
localesvariable is available, the first valid token will be thedefaultLocalefor this instance of the Java Virtual Machine.- Specified by:
getAvailableLocalesin interfaceSiteTool- Parameters:
locales- A comma separated list of locales supported by Maven. The first valid token will be the default Locale for this instance of the Java Virtual Machine.- Returns:
- a list of
Locale
-
codeToLocale
public java.util.Locale codeToLocale(java.lang.String localeCode)
Converts a locale code like "en", "en_US" or "en_US_win" to ajava.util.Localeobject.If localeCode =
default, return the current value of the default locale for this instance of the Java Virtual Machine.- Specified by:
codeToLocalein interfaceSiteTool- Parameters:
localeCode- the locale code string.- Returns:
- a java.util.Locale object instanced or null if errors occurred
- See Also:
- java.util.Locale#getDefault()
-
getNormalizedPath
protected static java.lang.String getNormalizedPath(java.lang.String path)
- Parameters:
path- could be null.- Returns:
- the path normalized, i.e. by eliminating "/../" and "/./" in the path.
- See Also:
FilenameUtils.normalize(String)
-
-