@Component(role=SiteTool.class) public class DefaultSiteTool extends org.codehaus.plexus.logging.AbstractLogEnabled implements SiteTool
Modifier and Type | Field and Description |
---|---|
protected DecorationModelInheritanceAssembler |
assembler
The component for assembling inheritance.
|
protected I18N |
i18n
Internationalization.
|
protected MavenProjectBuilder |
mavenProjectBuilder
Project builder.
|
DEFAULT_LOCALE, ROLE
Constructor and Description |
---|
DefaultSiteTool() |
Modifier and Type | Method and Description |
---|---|
Locale |
codeToLocale(String localeCode)
Converts a locale code like "en", "en_US" or "en_US_win" to a
java.util.Locale
object. |
List<Locale> |
getAvailableLocales(String locales)
Init the
localesList variable. |
DecorationModel |
getDecorationModel(MavenProject project,
List<MavenProject> reactorProjects,
ArtifactRepository localRepository,
List<ArtifactRepository> repositories,
String siteDirectory,
Locale locale)
Get a decoration model for a project.
|
Artifact |
getDefaultSkinArtifact(ArtifactRepository localRepository,
List<ArtifactRepository> remoteArtifactRepositories)
Get the default skin artifact for a project from one of the repositories.
|
String |
getInterpolatedSiteDescriptorContent(Map<String,String> props,
MavenProject aProject,
String siteDescriptorContent)
Interpolating several expressions in the site descriptor content.
|
protected static String |
getNormalizedPath(String path) |
MavenProject |
getParentProject(MavenProject aProject,
List<MavenProject> reactorProjects,
ArtifactRepository localRepository)
Returns the parent POM with interpolated URLs.
|
String |
getRelativePath(String to,
String from)
Calculate the relative path between two URLs or between two files.
|
File |
getSiteDescriptorFromBasedir(String siteDirectory,
File basedir,
Locale locale)
Get a site descriptor from the project's base directory.
|
File |
getSiteDescriptorFromRepository(MavenProject project,
ArtifactRepository localRepository,
List<ArtifactRepository> repositories,
Locale locale)
Get a site descriptor from one of the repositories.
|
Artifact |
getSkinArtifactFromRepository(ArtifactRepository localRepository,
List<ArtifactRepository> remoteArtifactRepositories,
DecorationModel decoration)
Get a skin artifact from one of the repositories.
|
void |
populateModules(MavenProject project,
List<MavenProject> reactorProjects,
ArtifactRepository localRepository,
DecorationModel decorationModel,
Locale locale,
boolean keepInheritedRefs)
Deprecated.
|
void |
populateModulesMenu(MavenProject project,
List<MavenProject> reactorProjects,
ArtifactRepository localRepository,
DecorationModel decorationModel,
Locale locale,
boolean keepInheritedRefs)
Populate the modules menu part of the decoration model.
|
void |
populateParentMenu(DecorationModel decorationModel,
Locale locale,
MavenProject project,
MavenProject parentProject,
boolean keepInheritedRefs)
Populate the parent menu part of the decoration model.
|
void |
populateProjectParentMenu(DecorationModel decorationModel,
Locale locale,
MavenProject project,
MavenProject parentProject,
boolean keepInheritedRefs)
Deprecated.
|
void |
populateReportsMenu(DecorationModel decorationModel,
Locale locale,
Map<String,List<MavenReport>> categories)
Populate the reports menu part of the decoration model.
|
@Requirement protected I18N i18n
@Requirement protected DecorationModelInheritanceAssembler assembler
@Requirement protected MavenProjectBuilder mavenProjectBuilder
public Artifact getSkinArtifactFromRepository(ArtifactRepository localRepository, List<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 Artifact getDefaultSkinArtifact(ArtifactRepository localRepository, List<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 String getRelativePath(String to, String from)
getRelativePath
in interface SiteTool
to
- the to
url of file as stringfrom
- the from
url of file as stringfrom
to to
.public File getSiteDescriptorFromBasedir(String siteDirectory, File basedir, Locale locale)
getSiteDescriptorFromBasedir
in interface SiteTool
siteDirectory
- The path to the directory containing the site.xml
file, 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 for
site_localeLanguage.xml
, otherwise searching for site.xml
.src/site/site.xml
, depending on parameter values.public File getSiteDescriptorFromRepository(MavenProject project, ArtifactRepository localRepository, List<ArtifactRepository> repositories, Locale locale) throws SiteToolException
getSiteDescriptorFromRepository
in interface SiteTool
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 anypublic DecorationModel getDecorationModel(MavenProject project, List<MavenProject> reactorProjects, ArtifactRepository localRepository, List<ArtifactRepository> repositories, String siteDirectory, Locale locale) throws SiteToolException
getDecorationModel
in interface SiteTool
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 the site.xml
file, 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.DecorationModel
object corresponding to the site.xml
file with some
interpolations.SiteToolException
- if anypublic void populateReportsMenu(DecorationModel decorationModel, Locale locale, Map<String,List<MavenReport>> categories)
populateReportsMenu
in interface SiteTool
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.public String getInterpolatedSiteDescriptorContent(Map<String,String> props, MavenProject aProject, 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.site.xml
file with interpolated strings.SiteToolException
- if errors happened during the interpolation.public MavenProject getParentProject(MavenProject aProject, List<MavenProject> reactorProjects, ArtifactRepository localRepository)
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.
TODO: once bug is fixed in Maven proper, remove this.getParentProject
in interface SiteTool
aProject
- a Maven project, not null.reactorProjects
- the Maven reactor projects, not null.localRepository
- the Maven local repository, not null.public void populateParentMenu(DecorationModel decorationModel, Locale locale, MavenProject project, MavenProject parentProject, boolean keepInheritedRefs)
populateParentMenu
in interface SiteTool
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.public void populateProjectParentMenu(DecorationModel decorationModel, Locale locale, MavenProject project, MavenProject parentProject, boolean keepInheritedRefs)
populateParentMenu(DecorationModel, Locale, MavenProject, MavenProject, boolean)
insteadpopulateProjectParentMenu
in interface SiteTool
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.public void populateModules(MavenProject project, List<MavenProject> reactorProjects, ArtifactRepository localRepository, DecorationModel decorationModel, Locale locale, boolean keepInheritedRefs) throws SiteToolException
populateModulesMenu(MavenProject, List, ArtifactRepository, DecorationModel, Locale, boolean)
insteadpopulateModules
in interface SiteTool
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.SiteToolException
- if anypublic void populateModulesMenu(MavenProject project, List<MavenProject> reactorProjects, ArtifactRepository localRepository, DecorationModel decorationModel, Locale locale, boolean keepInheritedRefs) throws SiteToolException
populateModulesMenu
in interface SiteTool
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.SiteToolException
- if anypublic List<Locale> getAvailableLocales(String locales)
localesList
variable.
If the locales
variable is available, the first valid token will be the
defaultLocale
for this instance of the Java Virtual Machine.
getAvailableLocales
in interface SiteTool
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.Locale
public Locale codeToLocale(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.
codeToLocale
in interface SiteTool
localeCode
- the locale code string.protected static String getNormalizedPath(String path)
path
- could be null.FilenameUtils.normalize(String)
Copyright © 2005–2014 The Apache Software Foundation. All rights reserved.