PageRenderTime 107ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/maven-shared-components-15/maven-doxia-tools/src/main/java/org/apache/maven/doxia/tools/SiteTool.java

#
Java | 289 lines | 45 code | 20 blank | 224 comment | 0 complexity | c2dafccad5eb2bc1c165d4861bea0e8d MD5 | raw file
Possible License(s): Apache-2.0
  1. package org.apache.maven.doxia.tools;
  2. /*
  3. * Licensed to the Apache Software Foundation (ASF) under one
  4. * or more contributor license agreements. See the NOTICE file
  5. * distributed with this work for additional information
  6. * regarding copyright ownership. The ASF licenses this file
  7. * to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance
  9. * with the License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing,
  14. * software distributed under the License is distributed on an
  15. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16. * KIND, either express or implied. See the License for the
  17. * specific language governing permissions and limitations
  18. * under the License.
  19. */
  20. import java.io.File;
  21. import java.util.List;
  22. import java.util.Locale;
  23. import java.util.Map;
  24. import org.apache.maven.artifact.Artifact;
  25. import org.apache.maven.artifact.repository.ArtifactRepository;
  26. import org.apache.maven.doxia.site.decoration.DecorationModel;
  27. import org.apache.maven.project.MavenProject;
  28. /**
  29. * Tool to play with <a href="http://maven.apache.org/doxia/">Doxia</a> objects
  30. * like <code>DecorationModel</code>.
  31. *
  32. * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
  33. * @version $Id: SiteTool.java 763760 2009-04-09 18:14:48Z ltheussl $
  34. */
  35. public interface SiteTool
  36. {
  37. /** Plexus Role */
  38. String ROLE = SiteTool.class.getName();
  39. /**
  40. * The locale by default for all default bundles
  41. * @see Locale#ENGLISH
  42. */
  43. Locale DEFAULT_LOCALE = Locale.ENGLISH;
  44. /**
  45. * Get a skin artifact from one of the repositories.
  46. *
  47. * @param localRepository the Maven local repository, not null.
  48. * @param remoteArtifactRepositories the Maven remote repositories, not null.
  49. * @param decoration the Doxia site descriptor model, not null.
  50. * @return the <code>Skin</code> artifact defined in a <code>DecorationModel</code> from a given project and a
  51. * local repository
  52. * @throws SiteToolException if any
  53. */
  54. Artifact getSkinArtifactFromRepository( ArtifactRepository localRepository, List remoteArtifactRepositories,
  55. DecorationModel decoration )
  56. throws SiteToolException;
  57. /**
  58. * Get the default skin artifact for a project from one of the repositories.
  59. *
  60. * @param localRepository the Maven local repository, not null.
  61. * @param remoteArtifactRepositories the Maven remote repositories, not null.
  62. * @return the default <code>Skin</code> artifact from a given project and a local repository
  63. * @throws SiteToolException if any
  64. * @see org.apache.maven.doxia.site.decoration.Skin#getDefaultSkin()
  65. * @see #getSkinArtifactFromRepository(ArtifactRepository, List, DecorationModel)
  66. */
  67. Artifact getDefaultSkinArtifact( ArtifactRepository localRepository, List remoteArtifactRepositories )
  68. throws SiteToolException;
  69. /**
  70. * Calculate the relative path between two URLs or between two files.
  71. *
  72. * For example:
  73. * <dl>
  74. * <dt>to = "http://maven.apache.org" and from = "http://maven.apache.org"</dt>
  75. * <dd>return ""</dd>
  76. * <dt>to = "http://maven.apache.org" and from = "http://maven.apache.org/plugins/maven-site-plugin/"</dt>
  77. * <dd>return "../.."</dd>
  78. * <dt>to = "http://maven.apache.org/plugins/maven-site-plugin/" and from = "http://maven.apache.org"</dt>
  79. * <dd>return "plugins/maven-site-plugin"</dd>
  80. * <dt>to = "/myproject/myproject-module1" and from = "/myproject/myproject"</dt>
  81. * <dd>return "../myproject-module1"</dd>
  82. * </dl>
  83. * <b>Note</b>: The file separator depends on the system.
  84. *
  85. * @param to the <code>to</code> url of file as string
  86. * @param from the <code>from</code> url of file as string
  87. * @return a relative path from <code>from</code> to <code>to</code>.
  88. */
  89. String getRelativePath( String to, String from );
  90. /**
  91. * Get a site descriptor from the project's base direcory.
  92. *
  93. * @param siteDirectory The path to the directory containing the <code>site.xml</code> file, relative to the
  94. * project base directory. If null, using by default "src/site".
  95. * @param basedir not null.
  96. * @param locale the locale wanted for the site descriptor. If not null, searching for
  97. * <code>site_<i>localeLanguage</i>.xml</code>, otherwise searching for <code>site.xml</code>.
  98. * @return the site descriptor relative file, i.e. <code>src/site/site.xml</code>, depending on parameter values.
  99. */
  100. File getSiteDescriptorFromBasedir( String siteDirectory, File basedir, Locale locale );
  101. /**
  102. * Get a site descriptor from one of the repositories.
  103. *
  104. * @param project the Maven project, not null.
  105. * @param localRepository the Maven local repository, not null.
  106. * @param repositories the Maven remote repositories, not null.
  107. * @param locale the locale wanted for the site descriptor. If not null, searching for
  108. * <code>site_<i>localeLanguage</i>.xml</code>, otherwise searching for <code>site.xml</code>.
  109. * @return the site descriptor into the local repository after download of it from repositories or null if not
  110. * found in repositories.
  111. * @throws SiteToolException if any
  112. */
  113. File getSiteDescriptorFromRepository( MavenProject project, ArtifactRepository localRepository, List repositories,
  114. Locale locale )
  115. throws SiteToolException;
  116. /**
  117. * Get a decoration model for a project.
  118. *
  119. * @param project the Maven project, not null.
  120. * @param reactorProjects the Maven reactor projects, not null.
  121. * @param localRepository the Maven local repository, not null.
  122. * @param repositories the Maven remote repositories, not null.
  123. * @param siteDirectory The path to the directory containing the <code>site.xml</code> file, relative to the
  124. * project base directory. If null, using by default "src/site".
  125. * @param locale the locale used for the i18n in DecorationModel. If null, using the default locale in the jvm.
  126. * @param inputEncoding the input encoding of the site descriptor, not null.
  127. * @param outputEncoding the output encoding wanted, not null.
  128. * @return the <code>DecorationModel</code> object corresponding to the <code>site.xml</code> file with some
  129. * interpolations.
  130. * @throws SiteToolException if any
  131. */
  132. DecorationModel getDecorationModel( MavenProject project, List reactorProjects, ArtifactRepository localRepository,
  133. List repositories, String siteDirectory, Locale locale, String inputEncoding,
  134. String outputEncoding )
  135. throws SiteToolException;
  136. /**
  137. * Populate the reports menu part of the decoration model.
  138. *
  139. * @param decorationModel the Doxia DecorationModel, not null.
  140. * @param locale the locale used for the i18n in DecorationModel. If null, using the default locale in the jvm.
  141. * @param categories a map to put on the decoration model, not null.
  142. */
  143. void populateReportsMenu( DecorationModel decorationModel, Locale locale, Map categories );
  144. /**
  145. * Interpolating several expressions in the site descriptor content. Actually, the expressions can be in
  146. * the project, the environment variables and the specific properties like <code>encoding</code>.
  147. * <p/>
  148. * For instance:
  149. * <dl>
  150. * <dt>${project.name}</dt>
  151. * <dd>The value from the POM of:
  152. * <p>
  153. * &lt;project&gt;<br>
  154. * &nbsp;&nbsp;&lt;name&gt;myProjectName&lt;/name&gt;<br>
  155. * &lt;/project&gt;
  156. * </p></dd>
  157. * <dt>${my.value}</dt>
  158. * <dd>The value from the POM of:
  159. * <p>
  160. * &lt;properties&gt;<br>
  161. * &nbsp;&nbsp;&lt;my.value&gt;hello&lt;/my.value&gt;<br>
  162. * &lt;/properties&gt;
  163. * </p></dd>
  164. * <dt>${JAVA_HOME}</dt>
  165. * <dd>The value of JAVA_HOME in the environment variables</dd>
  166. * </dl>
  167. *
  168. * @param props a map used for interpolation, not null.
  169. * @param aProject a Maven project, not null.
  170. * @param inputEncoding the input encoding of the site descriptor, not null.
  171. * @param outputEncoding the output encoding wanted, not null.
  172. * @param siteDescriptorContent the site descriptor file, not null.
  173. * @return the site descriptor content based on the <code>site.xml</code> file with interpolated strings.
  174. * @throws SiteToolException if errors happened during the interpolation.
  175. */
  176. String getInterpolatedSiteDescriptorContent( Map props, MavenProject aProject, String siteDescriptorContent,
  177. String inputEncoding, String outputEncoding )
  178. throws SiteToolException;
  179. /**
  180. * Returns the parent POM with interpolated URLs. Attempts to source this value from the
  181. * <code>reactorProjects</code> parameters if available (reactor env model attributes
  182. * are interpolated), or if the reactor is unavailable (-N) resorts to the
  183. * <code>project.getParent().getUrl()</code> value which will NOT have been interpolated.
  184. * <p/>
  185. * TODO: once bug is fixed in Maven proper, remove this.
  186. *
  187. * @param aProject a Maven project, not null.
  188. * @param reactorProjects the Maven reactor projects, not null.
  189. * @param localRepository the Maven local repository, not null.
  190. * @return the parent project with interpolated URLs.
  191. */
  192. MavenProject getParentProject( MavenProject aProject, List reactorProjects, ArtifactRepository localRepository );
  193. /**
  194. * Populate the parent menu part of the decoration model.
  195. *
  196. * @param decorationModel the Doxia DecorationModel, not null.
  197. * @param locale the locale used for the i18n in DecorationModel. If null, using the default locale in the jvm.
  198. * @param project a Maven project, not null.
  199. * @param parentProject a Maven parent project, not null.
  200. * @param keepInheritedRefs used for inherited references.
  201. */
  202. void populateParentMenu( DecorationModel decorationModel, Locale locale, MavenProject project,
  203. MavenProject parentProject, boolean keepInheritedRefs );
  204. /**
  205. * Populate the parent menu part of the decoration model.
  206. *
  207. * @param decorationModel the Doxia DecorationModel, not null.
  208. * @param locale the locale used for the i18n in DecorationModel. If null, using the default locale in the jvm.
  209. * @param project a Maven project, not null.
  210. * @param parentProject a Maven parent project, not null.
  211. * @param keepInheritedRefs used for inherited references.
  212. * @deprecated Please use
  213. * {@link #populateParentMenu(DecorationModel, Locale, MavenProject, MavenProject, boolean)} instead
  214. */
  215. void populateProjectParentMenu( DecorationModel decorationModel, Locale locale, MavenProject project,
  216. MavenProject parentProject, boolean keepInheritedRefs );
  217. /**
  218. * Populate the modules menu part of the decoration model.
  219. *
  220. * @param project a Maven project, not null.
  221. * @param reactorProjects the Maven reactor projects, not null.
  222. * @param localRepository the Maven local repository, not null.
  223. * @param decorationModel the Doxia site descriptor model, not null.
  224. * @param locale the locale used for the i18n in DecorationModel. If null, using the default locale in the jvm.
  225. * @param keepInheritedRefs used for inherited references.
  226. * @throws SiteToolException if any
  227. * @deprecated Please use
  228. * {@link #populateModulesMenu(MavenProject, List, ArtifactRepository, DecorationModel, Locale, boolean)}
  229. * instead
  230. */
  231. void populateModules( MavenProject project, List reactorProjects, ArtifactRepository localRepository,
  232. DecorationModel decorationModel, Locale locale, boolean keepInheritedRefs )
  233. throws SiteToolException;
  234. /**
  235. * Populate the modules menu part of the decoration model.
  236. *
  237. * @param project a Maven project, not null.
  238. * @param reactorProjects the Maven reactor projects, not null.
  239. * @param localRepository the Maven local repository, not null.
  240. * @param decorationModel the Doxia site descriptor model, not null.
  241. * @param locale the locale used for the i18n in DecorationModel. If null, using the default locale in the jvm.
  242. * @param keepInheritedRefs used for inherited references.
  243. * @throws SiteToolException if any
  244. */
  245. void populateModulesMenu( MavenProject project, List reactorProjects, ArtifactRepository localRepository,
  246. DecorationModel decorationModel, Locale locale, boolean keepInheritedRefs )
  247. throws SiteToolException;
  248. /**
  249. * Init the <code>localesList</code> variable.
  250. * <p>If the <code>locales</code> variable is available, the first valid token will be the
  251. * <code>defaultLocale</code> for this instance of the Java Virtual Machine.</p>
  252. *
  253. * @param locales A comma separated list of locales supported by Maven. The first valid token will be the
  254. * default Locale for this instance of the Java Virtual Machine.
  255. * @return a list of <code>Locale</code>
  256. */
  257. List getAvailableLocales( String locales );
  258. /**
  259. * Converts a locale code like "en", "en_US" or "en_US_win" to a <code>java.util.Locale</code>
  260. * object.
  261. * <p>If localeCode = <code>default</code>, return the current value of the default locale for this instance
  262. * of the Java Virtual Machine.</p>
  263. *
  264. * @param localeCode the locale code string.
  265. * @return a java.util.Locale object instancied or null if errors occurred
  266. * @see <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/util/Locale.html">java.util.Locale#getDefault()</a>
  267. */
  268. Locale codeToLocale( String localeCode );
  269. }