@Component(role=SiteTool.class) public class DefaultSiteTool extends org.codehaus.plexus.logging.AbstractLogEnabled implements SiteTool
Modifier and Type | Field and Description |
---|---|
private org.apache.maven.artifact.factory.ArtifactFactory |
artifactFactory
The component used for creating artifact instances.
|
private org.apache.maven.artifact.resolver.ArtifactResolver |
artifactResolver
The component that is used to resolve additional artifacts required.
|
protected DecorationModelInheritanceAssembler |
assembler
The component for assembling inheritance.
|
protected org.codehaus.plexus.i18n.I18N |
i18n
Internationalization.
|
protected org.apache.maven.project.MavenProjectBuilder |
mavenProjectBuilder
Project builder (deprecated in Maven 3: should use ProjectBuilder, which will avoid
issues like DOXIASITETOOLS-166)
|
DEFAULT_LOCALE, ROLE
Constructor and Description |
---|
DefaultSiteTool() |
Modifier and Type | Method and Description |
---|---|
private void |
appendMenuItem(org.apache.maven.project.MavenProject project,
Menu menu,
java.lang.String name,
java.lang.String href,
java.lang.String defaultHref) |
private static java.lang.String |
buildRelativePath(java.lang.String toPath,
java.lang.String fromPath,
char separatorChar) |
private void |
checkNotNull(java.lang.String name,
java.lang.Object value) |
private java.util.Locale |
codeToLocale(java.lang.String localeCode)
Converts a locale code like "en", "en_US" or "en_US_win" to a
java.util.Locale
object. |
private MenuItem |
createCategoryMenu(java.lang.String name,
java.lang.String href,
java.util.List<org.apache.maven.reporting.MavenReport> categoryReports,
java.util.Locale locale) |
private java.lang.String |
decorationModelToString(DecorationModel decoration) |
DecorationModel |
getDecorationModel(java.io.File siteDirectory,
java.util.Locale locale,
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)
Get a decoration model for a project.
|
private java.util.Map.Entry<DecorationModel,org.apache.maven.project.MavenProject> |
getDecorationModel(int depth,
java.io.File siteDirectory,
java.util.Locale locale,
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) |
org.apache.maven.artifact.Artifact |
getDefaultSkinArtifact(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.
|
private static java.lang.String |
getDistMgmntSiteUrl(org.apache.maven.model.DistributionManagement distMgmnt) |
private static java.lang.String |
getDistMgmntSiteUrl(org.apache.maven.project.MavenProject project)
Return distributionManagement.site.url if defined, null otherwise.
|
java.lang.String |
getInterpolatedSiteDescriptorContent(java.util.Map<java.lang.String,java.lang.String> props,
org.apache.maven.project.MavenProject aProject,
java.lang.String siteDescriptorContent)
Interpolating several expressions in the site descriptor content.
|
private java.lang.String |
getInterpolatedSiteDescriptorContent(org.apache.maven.project.MavenProject aProject,
java.lang.String siteDescriptorContent,
boolean isEarly) |
private static java.lang.String |
getMavenVersion() |
private static org.apache.maven.project.MavenProject |
getModuleFromReactor(org.apache.maven.project.MavenProject project,
java.util.List<org.apache.maven.project.MavenProject> reactorProjects,
java.lang.String module) |
protected static java.lang.String |
getNormalizedPath(java.lang.String path) |
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.
|
private static java.lang.String |
getRelativeFilePath(java.lang.String oldPath,
java.lang.String newPath) |
java.lang.String |
getRelativePath(java.lang.String to,
java.lang.String from)
Calculate the relative path between two URLs or between two files.
|
java.io.File |
getSiteDescriptor(java.io.File siteDirectory,
java.util.Locale locale)
Get a site descriptor from the project's site directory.
|
(package private) 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)
Get a site descriptor from one of the repositories.
|
java.util.List<java.util.Locale> |
getSiteLocales(java.lang.String locales)
Extracts from a comma-separated list the locales that are available in
site-tool
resource bundle. |
org.apache.maven.artifact.Artifact |
getSkinArtifactFromRepository(org.apache.maven.artifact.repository.ArtifactRepository localRepository,
java.util.List<org.apache.maven.artifact.repository.ArtifactRepository> remoteArtifactRepositories,
DecorationModel decoration)
Get a skin artifact from one of the repositories.
|
private static boolean |
isEmptyList(java.util.List<?> list)
Convenience method.
|
private static boolean |
isMaven3OrMore()
Check the current Maven version to see if it's Maven 3.0 or newer.
|
private void |
populateModulesMenu(DecorationModel decorationModel,
java.util.Locale locale,
org.apache.maven.project.MavenProject project,
java.util.List<org.apache.maven.project.MavenProject> reactorProjects,
org.apache.maven.artifact.repository.ArtifactRepository localRepository,
boolean keepInheritedRefs)
Populate the pre-defined
modules menu of the decoration model,
if used through <menu ref="modules"/> . |
private void |
populateParentMenu(DecorationModel decorationModel,
java.util.Locale locale,
org.apache.maven.project.MavenProject project,
org.apache.maven.project.MavenProject parentProject,
boolean keepInheritedRefs)
Populate the pre-defined
parent menu of the decoration model,
if used through <menu ref="parent"/> . |
void |
populateReportsMenu(DecorationModel decorationModel,
java.util.Locale locale,
java.util.Map<java.lang.String,java.util.List<org.apache.maven.reporting.MavenReport>> categories)
Populate the pre-defined
reports menu of the decoration model,
if used through <menu ref="reports"/> . |
private DecorationModel |
readDecorationModel(java.lang.String siteDescriptorContent) |
private java.lang.String |
readSiteDescriptor(java.io.Reader reader,
java.lang.String projectId)
Read site descriptor content from Reader, adding support for deprecated
${reports} ,
${parentProject} and ${modules} tags. |
private java.io.File |
resolveSiteDescriptor(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) |
private static java.lang.String |
urlEncode(java.lang.String url) |
@Requirement private org.apache.maven.artifact.resolver.ArtifactResolver artifactResolver
@Requirement private org.apache.maven.artifact.factory.ArtifactFactory artifactFactory
@Requirement protected org.codehaus.plexus.i18n.I18N i18n
@Requirement protected DecorationModelInheritanceAssembler assembler
@Requirement protected org.apache.maven.project.MavenProjectBuilder mavenProjectBuilder
public org.apache.maven.artifact.Artifact getSkinArtifactFromRepository(org.apache.maven.artifact.repository.ArtifactRepository localRepository, java.util.List<org.apache.maven.artifact.repository.ArtifactRepository> remoteArtifactRepositories, DecorationModel decoration) throws SiteToolException
getSkinArtifactFromRepository
in interface SiteTool
localRepository
- the Maven local repository, not null.remoteArtifactRepositories
- the Maven remote repositories, not null.decoration
- the Doxia site descriptor model, not null.Skin
artifact defined in a DecorationModel
from a given project and a
local repositorySiteToolException
- if anypublic org.apache.maven.artifact.Artifact getDefaultSkinArtifact(org.apache.maven.artifact.repository.ArtifactRepository localRepository, java.util.List<org.apache.maven.artifact.repository.ArtifactRepository> remoteArtifactRepositories) throws SiteToolException
getDefaultSkinArtifact
in interface SiteTool
localRepository
- the Maven local repository, not null.remoteArtifactRepositories
- the Maven remote repositories, not null.Skin
artifact from a given project and a local repositorySiteToolException
- if anySkin.getDefaultSkin()
,
SiteTool.getSkinArtifactFromRepository(ArtifactRepository, List, DecorationModel)
public java.lang.String getRelativePath(java.lang.String to, java.lang.String from)
dav:https://dav.codehaus.org/
or
scm:svn:https://svn.apache.org/repos/asf
.getRelativePath
in interface SiteTool
to
- the to
url of file as stringfrom
- the from
url of file as stringfrom
to to
.private static java.lang.String getRelativeFilePath(java.lang.String oldPath, java.lang.String newPath)
public java.io.File getSiteDescriptor(java.io.File siteDirectory, java.util.Locale locale)
getSiteDescriptor
in interface SiteTool
siteDirectory
- the site directory, not nulllocale
- the locale wanted for the site descriptor. If not null, searching for
site_localeLanguage.xml
, otherwise searching for site.xml
.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 SiteToolException
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 for
site_localeLanguage.xml
, otherwise searching for site.xml
.SiteToolException
- if anyprivate java.lang.String readSiteDescriptor(java.io.Reader reader, java.lang.String projectId) throws java.io.IOException
${reports}
,
${parentProject}
and ${modules}
tags.reader
- java.io.IOException
public DecorationModel getDecorationModel(java.io.File siteDirectory, java.util.Locale locale, 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) throws SiteToolException
getDecorationModel
in interface SiteTool
siteDirectory
- the site directory, may be null if project from repositorylocale
- the locale used for the i18n in DecorationModel. If null, using the default locale in the jvm.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.DecorationModel
object corresponding to the site.xml
file with some
interpolations.SiteToolException
- if anypublic java.lang.String getInterpolatedSiteDescriptorContent(java.util.Map<java.lang.String,java.lang.String> props, org.apache.maven.project.MavenProject aProject, java.lang.String siteDescriptorContent) throws SiteToolException
encoding
.
For instance:
<project>
<name>myProjectName</name>
</project>
<properties>
<my.value>hello</my.value>
</properties>
getInterpolatedSiteDescriptorContent
in interface SiteTool
props
- a map used for interpolation, not null.aProject
- a Maven project, not null.siteDescriptorContent
- the site descriptor file, not null.SiteToolException
- if errors happened during the interpolation.private java.lang.String getInterpolatedSiteDescriptorContent(org.apache.maven.project.MavenProject aProject, java.lang.String siteDescriptorContent, boolean isEarly) throws SiteToolException
SiteToolException
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)
project.getParent()
, which is already
interpolated. But when called from Maven 2, attempts to source this value from the
reactorProjects
parameters if available (reactor env model attributes
are interpolated), or if the reactor is unavailable (-N) resorts to the
project.getParent().getUrl()
value which will NOT have been interpolated.getParentProject
in interface SiteTool
aProject
- a Maven project, not null.reactorProjects
- the Maven reactor projects, not null.localRepository
- the Maven local repository, not null.private void populateParentMenu(DecorationModel decorationModel, java.util.Locale locale, org.apache.maven.project.MavenProject project, org.apache.maven.project.MavenProject parentProject, boolean keepInheritedRefs)
parent
menu of the decoration model,
if used through <menu ref="parent"/>
.decorationModel
- the Doxia Sitetools 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.private void populateModulesMenu(DecorationModel decorationModel, java.util.Locale locale, org.apache.maven.project.MavenProject project, java.util.List<org.apache.maven.project.MavenProject> reactorProjects, org.apache.maven.artifact.repository.ArtifactRepository localRepository, boolean keepInheritedRefs) throws SiteToolException, java.io.IOException
modules
menu of the decoration model,
if used through <menu ref="modules"/>
.decorationModel
- the Doxia Sitetools 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.reactorProjects
- the Maven reactor projects, not null.localRepository
- the Maven local repository, not null.keepInheritedRefs
- used for inherited references.SiteToolException
- if anyjava.io.IOException
private static org.apache.maven.project.MavenProject getModuleFromReactor(org.apache.maven.project.MavenProject project, java.util.List<org.apache.maven.project.MavenProject> reactorProjects, java.lang.String module) throws java.io.IOException
java.io.IOException
public void populateReportsMenu(DecorationModel decorationModel, java.util.Locale locale, java.util.Map<java.lang.String,java.util.List<org.apache.maven.reporting.MavenReport>> categories)
reports
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".populateReportsMenu
in interface SiteTool
decorationModel
- the Doxia Sitetools DecorationModel, not null.locale
- the locale used for the i18n in DecorationModel. If null, using the default locale in the jvm.categories
- reports per category to put in "Reports" or "Information" menus, not null.MavenReport.CATEGORY_PROJECT_INFORMATION
,
MavenReport.CATEGORY_PROJECT_REPORTS
public java.util.List<java.util.Locale> getSiteLocales(java.lang.String locales)
site-tool
resource bundle. Notice that default
value will be changed to the default locale of
the JVM.getSiteLocales
in interface SiteTool
locales
- A comma separated list of localesLocale
, which at least contains the Maven default locale which is englishprivate java.util.Locale codeToLocale(java.lang.String localeCode)
java.util.Locale
object.
If localeCode = default
, return the current value of the default locale for this instance
of the Java Virtual Machine.
localeCode
- the locale code string.protected static java.lang.String getNormalizedPath(java.lang.String path)
path
- could be null.FilenameUtils.normalize(String)
private java.io.File resolveSiteDescriptor(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 java.io.IOException, org.apache.maven.artifact.resolver.ArtifactResolutionException, org.apache.maven.artifact.resolver.ArtifactNotFoundException
project
- not nulllocalRepository
- not nullrepositories
- not nulllocale
- not nulljava.io.IOException
- if anyorg.apache.maven.artifact.resolver.ArtifactResolutionException
- if anyorg.apache.maven.artifact.resolver.ArtifactNotFoundException
- if anyprivate java.util.Map.Entry<DecorationModel,org.apache.maven.project.MavenProject> getDecorationModel(int depth, java.io.File siteDirectory, java.util.Locale locale, 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) throws SiteToolException
depth
- depth of projectsiteDirectory,
- can be null if project.basedir is null, ie POM from repositorylocale
- not nullproject
- not nullreactorProjects
- not nulllocalRepository
- not nullrepositories
- not nullorigProps
- not nullSiteToolException
- if anyprivate DecorationModel readDecorationModel(java.lang.String siteDescriptorContent) throws SiteToolException
siteDescriptorContent
- not nullSiteToolException
- if anyprivate java.lang.String decorationModelToString(DecorationModel decoration) throws SiteToolException
SiteToolException
private static java.lang.String buildRelativePath(java.lang.String toPath, java.lang.String fromPath, char separatorChar)
private void appendMenuItem(org.apache.maven.project.MavenProject project, Menu menu, java.lang.String name, java.lang.String href, java.lang.String defaultHref)
project
- not nullmenu
- not nullname
- not nullhref
- could be nulldefaultHref
- not nullprivate MenuItem createCategoryMenu(java.lang.String name, java.lang.String href, java.util.List<org.apache.maven.reporting.MavenReport> categoryReports, java.util.Locale locale)
name
- not nullhref
- not nullcategoryReports
- not nulllocale
- not nullprivate static boolean isEmptyList(java.util.List<?> list)
list
- could be nullnull
or emptyprivate static java.lang.String getDistMgmntSiteUrl(org.apache.maven.project.MavenProject project)
project
- not nullprivate static java.lang.String getDistMgmntSiteUrl(org.apache.maven.model.DistributionManagement distMgmnt)
private static java.lang.String urlEncode(java.lang.String url)
private void checkNotNull(java.lang.String name, java.lang.Object value)
private static boolean isMaven3OrMore()
private static java.lang.String getMavenVersion()