------ Guide to creating a site ------ Brett Porter Jason van Zyl ------ 2005-05-13 ------ ~~ Licensed to the Apache Software Foundation (ASF) under one ~~ or more contributor license agreements. See the NOTICE file ~~ distributed with this work for additional information ~~ regarding copyright ownership. The ASF licenses this file ~~ to you under the Apache License, Version 2.0 (the ~~ "License"); you may not use this file except in compliance ~~ with the License. You may obtain a copy of the License at ~~ ~~ http://www.apache.org/licenses/LICENSE-2.0 ~~ ~~ Unless required by applicable law or agreed to in writing, ~~ software distributed under the License is distributed on an ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~~ KIND, either express or implied. See the License for the ~~ specific language governing permissions and limitations ~~ under the License. ~~ NOTE: For help with the syntax of this file, see: ~~ http://maven.apache.org/doxia/references/apt-format.html Creating a site * Creating Content The first step to creating your site is to create some content. In Maven 2.0, the site content is separated by format, as there are several available. ------------------- +- src/ +- site/ +- apt/ | +- index.apt | +- xdoc/ | +- other.xml | +- fml/ | +- general.fml | +- faq.fml | +- site.xml -------------------- You will notice there is now a <<<$\{basedir\}/src/site>>> directory within which is contained a site descriptor along with various directories corresponding to the supported document types. Let's take a look at site descriptor and the examples of the various document types. The Xdoc format is the same as {{{http://maven.apache.org/maven-1.x/using/site.html} used in Maven 1.x}}. However, <<>> has been replaced by the site descriptor (see below). The APT format, "Almost Plain Text", is a wiki-like format that allows you to write simple, structured documents (like this one) very quickly. A full reference of the {{{http://maven.apache.org/doxia/references/apt-format.html} APT Format}} is available. The FML format is the FAQ format, also used in Maven 1.x. Other formats are available, but at this point these 3 are the best tested. There are also several possible output formats, but as of 2.0, only XHTML is available. Note that all of the above is optional - just one index file is required in one of the input trees. Each of the paths will be merged together to form the root directory of the site. * Customizing the Look & Feel If you want to tune the way your site looks, you can use a custom skin to provide your own CSS styles. If that is still not enough, you can even tweak the output templates that Maven uses to generate the site documentation. You can visit the {{{http://maven.apache.org/skins/}Skins site}} to have a look at some of the skins that you can use to change the look of your site. ~~ TODO: The following link is currently not available. Restore it when it becomes available again. ~~ For an in-depth discussion of site customization, please have a look at the ~~ {{{http://www.sonatype.com/book/site-generation.html} Maven User Guide, Chapter 9, "Site Generation"}}. * Generating the Site Generating the site is very simple, and fast! --------------- mvn site --------------- By default, the resulting site will be in <<>> For more information on the Maven Site Plugin, see its {{{../../plugins/maven-site-plugin/} plugin reference}}. * Deploying the Site To be able to deploy the site, you must first declare a location to distribute to in your <<>>, similar to the repository for deployment. --------------- ... website scp://www.mycompany.com/www/docs/project/ ... --------------- The <<<\>>> element identifies the repository, so that you can attach credentials to it in your <<>> file using the {{{../../settings.html#Servers} <<<\>>> element}} as you would for any other repository. The <<<\>>> gives the location to deploy to. Currently, only SSH is supported, as above which copies to the host <<>> in the path <<>>. If subprojects inherit the site URL from a parent POM, they will automatically append their <<<\>>> to form their effective deployment location. Deploying the site is done by using the <<>> phase of the site lifecycle. --------------- mvn site-deploy --------------- * Creating a Site Descriptor The <<>> file is used to describe the layout of the site, and replaces the <<>> file used in Maven 1.x. A sample is given below: -------------------- Maven http://maven.apache.org/images/apache-maven-project.png http://maven.apache.org/ http://maven.apache.org/images/maven-small.gif ... -------------------- ~~TODO: deserves more explanation. <> The <<<\>>> element above. When building the site, this is replaced by a menu with links to all the reports that you have configured. More information about the site descriptor is available at the site for the {{{http://maven.apache.org/plugins/maven-site-plugin/examples/sitedescriptor.html}Maven Site Plugin}}. * Adding Extra Resources You can add any arbitrary resource to your site by including them in a <<>> directory as shown below. Additional CSS files will be picked up when they are placed in the <<>> directory within the <<>> directory. ------------------- +- src/ +- site/ +- resources/ +- css/ | +- site.css | +- images/ +- pic1.jpg -------------------- The file <<>> will be added to the default XHTML output, so it can be used to adjust the default Maven stylesheets if desired. The file <<>> will be available via a relative reference to the <<>> directory from any page in your site. * Configuring Reports Maven has several reports that you can add to your web site to display the current state of the project. These reports take the form of plugins, just like those used to build the project. There are many standard reports that are available by gleaning information from the POM. Currently what is provided by default are: * Dependencies Report * Mailing Lists * Continuous Integration * Source Repository * Issue Tracking * Project Team * License [] To find out more please refer to the {{{../../plugins/maven-project-info-reports-plugin/}Project Info Reports Plugin}}. To add these reports to your site, you must add the plugins to a special <<<\>>> section in the POM. The following example shows how to configure the standard project information reports that display information from the POM in a friendly format: ------------------- ... org.apache.maven.plugins maven-project-info-reports-plugin 2.6 ... ------------------- If you have included the appropriate <<<\>>> tag in your <<>> descriptor, then when you regenerate the site those items will appear in the menu. <> Many report plugins provide a parameter called <<>> or similar to specify the destination for their report outputs. This parameter is only relevant if the report plugin is run standalone, i.e. by invocation directly from the command line. In constrast, when reports are generated as part of the site, the configuration of the Maven Site Plugin will determine the effective output directory to ensure that all reports end up in a central location. ~~TODO: explain report sets * Internationalization Internationalization in Maven is very simple, as long as the reports you are using have that particular locale defined. For an overview of supported languages and instructions on how to add further languages, please see the related article {{{../../plugins/maven-site-plugin/i18n.html} Internationalization}} from the Maven Site Plugin. To enable multiple locales, add a configuration similar to the following to your POM: ------------------- ... org.apache.maven.plugins maven-site-plugin 3.2 en,fr ... ------------------- This will generate both an English and a French version of the site. If <<>> is your current locale, then it will be generated at the root of the site, with a copy of the French translation of the site in the <<>> subdirectory. To add your own content for that translation instead of using the default, place a subdirectory with that locale name in your site directory and create a new site descriptor with the locale in the file name. For example: ------------------- +- src/ +- site/ +- apt/ | +- index.apt (Default version) | +- fr/ | +- apt/ | +- index.apt (French version) | +- site.xml (Default site descriptor) +- site_fr.xml (French site descriptor) -------------------- With one site descriptor per language, the translated site(s) can evolve independently.