org.apache.maven.doxia.tools
Interface SiteTool

All Known Implementing Classes:
DefaultSiteTool

public interface SiteTool

Tool to play with Doxia objects like DecorationModel.

Version:
$Id: SiteTool.java 1098159 2011-04-30 21:07:49Z dennisl $
Author:
Vincent Siveton

Field Summary
static Locale DEFAULT_LOCALE
          The locale by default for all default bundles
static String ROLE
          Plexus Role
 
Method Summary
 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, String inputEncoding, String outputEncoding)
          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, String inputEncoding, String outputEncoding)
          Interpolating several expressions in the site descriptor content.
 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. Please use populateModulesMenu(MavenProject, List, ArtifactRepository, DecorationModel, Locale, boolean) instead
 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. Please use populateParentMenu(DecorationModel, Locale, MavenProject, MavenProject, boolean) instead
 void populateReportsMenu(DecorationModel decorationModel, Locale locale, Map<String,List<MavenReport>> categories)
          Populate the reports menu part of the decoration model.
 

Field Detail

ROLE

static final String ROLE
Plexus Role


DEFAULT_LOCALE

static final Locale DEFAULT_LOCALE
The locale by default for all default bundles

See Also:
Locale.ENGLISH
Method Detail

getSkinArtifactFromRepository

Artifact getSkinArtifactFromRepository(ArtifactRepository localRepository,
                                       List<ArtifactRepository> remoteArtifactRepositories,
                                       DecorationModel decoration)
                                       throws SiteToolException
Get a skin artifact from one of the repositories.

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 a DecorationModel from a given project and a local repository
Throws:
SiteToolException - if any

getDefaultSkinArtifact

Artifact getDefaultSkinArtifact(ArtifactRepository localRepository,
                                List<ArtifactRepository> remoteArtifactRepositories)
                                throws SiteToolException
Get the default skin artifact for a project from one of the repositories.

Parameters:
localRepository - the Maven local repository, not null.
remoteArtifactRepositories - the Maven remote repositories, not null.
Returns:
the default Skin artifact from a given project and a local repository
Throws:
SiteToolException - if any
See Also:
Skin.getDefaultSkin(), getSkinArtifactFromRepository(ArtifactRepository, List, DecorationModel)

getRelativePath

String getRelativePath(String to,
                       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"
Note: The file separator depends on the system.

Parameters:
to - the to url of file as string
from - the from url of file as string
Returns:
a relative path from from to to.

getSiteDescriptorFromBasedir

File getSiteDescriptorFromBasedir(String siteDirectory,
                                  File basedir,
                                  Locale locale)
Get a site descriptor from the project's base directory.

Parameters:
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.
Returns:
the site descriptor relative file, i.e. src/site/site.xml, depending on parameter values.

getSiteDescriptorFromRepository

File getSiteDescriptorFromRepository(MavenProject project,
                                     ArtifactRepository localRepository,
                                     List<ArtifactRepository> repositories,
                                     Locale locale)
                                     throws SiteToolException
Get a site descriptor from one of the repositories.

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 for site_localeLanguage.xml, otherwise searching for site.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

DecorationModel getDecorationModel(MavenProject project,
                                   List<MavenProject> reactorProjects,
                                   ArtifactRepository localRepository,
                                   List<ArtifactRepository> repositories,
                                   String siteDirectory,
                                   Locale locale,
                                   String inputEncoding,
                                   String outputEncoding)
                                   throws SiteToolException
Get a decoration model for a project.

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 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.
inputEncoding - the input encoding of the site descriptor, not null.
outputEncoding - the output encoding wanted, not null.
Returns:
the DecorationModel object corresponding to the site.xml file with some interpolations.
Throws:
SiteToolException - if any

populateReportsMenu

void populateReportsMenu(DecorationModel decorationModel,
                         Locale locale,
                         Map<String,List<MavenReport>> categories)
Populate the reports menu part of the decoration model.

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

String getInterpolatedSiteDescriptorContent(Map<String,String> props,
                                            MavenProject aProject,
                                            String siteDescriptorContent,
                                            String inputEncoding,
                                            String outputEncoding)
                                            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 like encoding.

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

Parameters:
props - a map used for interpolation, not null.
aProject - a Maven project, not null.
inputEncoding - the input encoding of the site descriptor, not null.
outputEncoding - the output encoding wanted, not null.
siteDescriptorContent - the site descriptor file, not null.
Returns:
the site descriptor content based on the site.xml file with interpolated strings.
Throws:
SiteToolException - if errors happened during the interpolation.

getParentProject

MavenProject getParentProject(MavenProject aProject,
                              List<MavenProject> reactorProjects,
                              ArtifactRepository localRepository)
Returns the parent POM with interpolated URLs. 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.

TODO: once bug is fixed in Maven proper, remove this.

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

void populateParentMenu(DecorationModel decorationModel,
                        Locale locale,
                        MavenProject project,
                        MavenProject parentProject,
                        boolean keepInheritedRefs)
Populate the parent menu part of the decoration model.

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

void populateProjectParentMenu(DecorationModel decorationModel,
                               Locale locale,
                               MavenProject project,
                               MavenProject parentProject,
                               boolean keepInheritedRefs)
Deprecated. Please use populateParentMenu(DecorationModel, Locale, MavenProject, MavenProject, boolean) instead

Populate the parent menu part of the decoration model.

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

void populateModules(MavenProject project,
                     List<MavenProject> reactorProjects,
                     ArtifactRepository localRepository,
                     DecorationModel decorationModel,
                     Locale locale,
                     boolean keepInheritedRefs)
                     throws SiteToolException
Deprecated. Please use populateModulesMenu(MavenProject, List, ArtifactRepository, DecorationModel, Locale, boolean) instead

Populate the modules menu part of the decoration model.

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

void populateModulesMenu(MavenProject project,
                         List<MavenProject> reactorProjects,
                         ArtifactRepository localRepository,
                         DecorationModel decorationModel,
                         Locale locale,
                         boolean keepInheritedRefs)
                         throws SiteToolException
Populate the modules menu part of the decoration model.

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

List<Locale> getAvailableLocales(String locales)
Init the localesList variable.

If the locales variable is available, the first valid token will be the defaultLocale for this instance of the Java Virtual Machine.

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

Locale codeToLocale(String localeCode)
Converts a locale code like "en", "en_US" or "en_US_win" to a java.util.Locale object.

If localeCode = default, return the current value of the default locale for this instance of the Java Virtual Machine.

Parameters:
localeCode - the locale code string.
Returns:
a java.util.Locale object instanced or null if errors occurred
See Also:
java.util.Locale#getDefault()


Copyright © 2005-2012 The Apache Software Foundation. All Rights Reserved.