Use plexus-site-renderer for generate site with velocity templates.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@178887 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Emmanuel Venisse 2005-05-28 20:35:37 +00:00
parent fda1ed95c9
commit 27cbac3e16
78 changed files with 514 additions and 41 deletions

View File

@ -16,9 +16,9 @@
<version>2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>doxia</groupId>
<artifactId>doxia-core</artifactId>
<version>1.0-alpha-3-SNAPSHOT</version>
<groupId>plexus</groupId>
<artifactId>plexus-site-renderer</artifactId>
<version>1.0-alpha-1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.maven.wagon</groupId>

View File

@ -22,16 +22,22 @@ import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.reporting.MavenReport;
import org.apache.maven.reporting.MavenReportConfiguration;
import org.codehaus.doxia.module.xhtml.XhtmlSink;
import org.codehaus.doxia.site.renderer.SiteRenderer;
import org.apache.maven.reporting.MavenReportException;
import org.codehaus.plexus.siterenderer.Renderer;
import org.codehaus.plexus.siterenderer.RendererException;
import org.codehaus.plexus.siterenderer.sink.SiteRendererSink;
import org.codehaus.plexus.util.FileUtils;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.StringInputStream;
import org.codehaus.plexus.util.StringUtils;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@ -39,19 +45,19 @@ import java.util.List;
import java.util.Map;
/**
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
* @version $Id$
* @goal site
* @description Doxia plugin
* @requiresDependencyResolution test
*
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
* @version $Id$
*/
public class DoxiaMojo
extends AbstractMojo
{
/**
* @parameter expression="${basedir}"
* @required
*/
private String basedir;
private static final String RESOURCE_DIR = "org/apache/maven/doxia";
private static final String DEFAULT_TEMPLATE = RESOURCE_DIR + "/maven-site.vm";
/**
* @parameter expression="${basedir}/src/site"
@ -78,16 +84,21 @@ public class DoxiaMojo
private File resourcesDirectory;
/**
* @parameter alias="flavor"
* @parameterX expression="${template}
*/
private String flavour = "maven";
private String template = DEFAULT_TEMPLATE;
/**
* @parameter expression="${component.org.codehaus.doxia.site.renderer.SiteRenderer}"
* @parameterX expression="${attributes}
*/
private Map attributes;
/**
* @parameter expression="${component.org.codehaus.plexus.siterenderer.Renderer}"
* @required
* @readonly
*/
private SiteRenderer siteRenderer;
private Renderer siteRenderer;
/**
* @parameter expression="${project}"
@ -147,11 +158,21 @@ public class DoxiaMojo
report.setConfiguration( config );
XhtmlSink sink = siteRenderer.createSink( new File( siteDirectory ),
report.getOutputName() + ".html", outputDirectory,
getSiteDescriptor(), flavour );
String outputFileName = report.getOutputName() + ".html";
SiteRendererSink sink = siteRenderer.createSink( new File( siteDirectory ), outputFileName,
getSiteDescriptor() );
report.generate( sink );
File outputFile = new File( outputDirectory, outputFileName );
if ( !outputFile.getParentFile().exists() )
{
outputFile.getParentFile().mkdirs();
}
siteRenderer.generateDocument( new FileWriter( outputFile ), template, attributes, sink );
}
}
@ -193,13 +214,30 @@ public class DoxiaMojo
FileUtils.copyDirectory( imagesDirectory, new File( outputDirectory, "images" ) );
}
//Generate static site
siteRenderer.render( siteDirectory, generatedSiteDirectory, outputDirectory, flavour, getSiteDescriptor(),
resourcesDirectory );
// Generate static site
siteRenderer.render( new File( siteDirectory ), new File( outputDirectory ), getSiteDescriptor(), template,
attributes );
siteRenderer.render( new File( generatedSiteDirectory ), new File( outputDirectory ), getSiteDescriptor(),
template, attributes );
// Copy site resources
if ( resourcesDirectory != null )
{
FileUtils.copyDirectory( resourcesDirectory, new File( outputDirectory ) );
}
copyResources( outputDirectory );
}
catch ( MavenReportException e )
{
throw new MojoExecutionException( "Error during report generation", e );
}
catch ( RendererException e )
{
throw new MojoExecutionException( "Error during page generation", e );
}
catch ( Exception e )
{
// TODO: handle it better
throw new MojoExecutionException( "Error during site generation", e );
}
}
@ -220,8 +258,8 @@ public class DoxiaMojo
}
else
{
throw new MojoExecutionException( "'" + report.getCategoryName() + "' category define for " +
report.getName() + " mojo isn't valid." );
throw new MojoExecutionException( "'" + report.getCategoryName() + "' category define for "
+ report.getName() + " mojo isn't valid." );
}
}
}
@ -235,15 +273,14 @@ public class DoxiaMojo
if ( projectInfos.size() > 0 )
{
buffer.append( " <item name=\"" + MavenReport.CATEGORY_PROJECT_INFORMATION +
"\" href=\"/project-info.html\" collapse=\"true\">\n" );
buffer.append( " <item name=\"" + MavenReport.CATEGORY_PROJECT_INFORMATION
+ "\" href=\"/project-info.html\" collapse=\"true\">\n" );
for ( Iterator i = projectInfos.iterator(); i.hasNext(); )
{
MavenReport report = (MavenReport) i.next();
buffer.append(
" <item name=\"" + report.getName() + "\" href=\"/" + report.getOutputName() +
".html\"/>\n" );
buffer.append( " <item name=\"" + report.getName() + "\" href=\"/" + report.getOutputName()
+ ".html\"/>\n" );
}
buffer.append( " </item>\n" );
@ -251,15 +288,14 @@ public class DoxiaMojo
if ( projectReports.size() > 0 )
{
buffer.append( " <item name=\"" + MavenReport.CATEGORY_PROJECT_REPORTS +
"\" href=\"/maven-reports.html\" collapse=\"true\">\n" );
buffer.append( " <item name=\"" + MavenReport.CATEGORY_PROJECT_REPORTS
+ "\" href=\"/maven-reports.html\" collapse=\"true\">\n" );
for ( Iterator i = projectReports.iterator(); i.hasNext(); )
{
MavenReport report = (MavenReport) i.next();
buffer.append(
" <item name=\"" + report.getName() + "\" href=\"/" + report.getOutputName() +
".html\"/>\n" );
buffer.append( " <item name=\"" + report.getName() + "\" href=\"/" + report.getOutputName()
+ ".html\"/>\n" );
}
buffer.append( " </item>\n" );
@ -328,8 +364,10 @@ public class DoxiaMojo
private void generateProjectInfoPage( InputStream siteDescriptor )
throws Exception
{
XhtmlSink sink = siteRenderer.createSink( new File( siteDirectory ), "project-info.html", outputDirectory,
siteDescriptor, flavour );
String outputFileName = "project-info.html";
SiteRendererSink sink = siteRenderer
.createSink( new File( siteDirectory ), outputFileName, getSiteDescriptor() );
String title = "General Project Information";
@ -346,8 +384,8 @@ public class DoxiaMojo
sink.sectionTitle1_();
sink.paragraph();
sink.text( "This document provides an overview of the various documents and links that are part " +
"of this project's general information. All of this content is automatically generated by " );
sink.text( "This document provides an overview of the various documents and links that are part "
+ "of this project's general information. All of this content is automatically generated by " );
sink.link( "http://maven.apache.org" );
sink.text( "Maven" );
sink.link_();
@ -398,13 +436,18 @@ public class DoxiaMojo
sink.flush();
sink.close();
siteRenderer.generateDocument( new FileWriter( new File( outputDirectory, outputFileName ) ), template,
attributes, sink );
}
private void generateProjectReportsPage( InputStream siteDescriptor )
throws Exception
{
XhtmlSink sink = siteRenderer.createSink( new File( siteDirectory ), "maven-reports.html", outputDirectory,
siteDescriptor, flavour );
String outputFileName = "maven-reports.html";
SiteRendererSink sink = siteRenderer
.createSink( new File( siteDirectory ), outputFileName, getSiteDescriptor() );
String title = "Maven Generated Reports";
@ -468,5 +511,52 @@ public class DoxiaMojo
sink.section1_();
sink.body_();
siteRenderer.generateDocument( new FileWriter( new File( outputDirectory, outputFileName ) ), template,
attributes, sink );
}
private void copyResources( String outputDirectory )
throws Exception
{
InputStream resourceList = getStream( RESOURCE_DIR + "/resources.txt" );
if ( resourceList != null )
{
LineNumberReader reader = new LineNumberReader( new InputStreamReader( resourceList ) );
String line;
while ( ( line = reader.readLine() ) != null )
{
InputStream is = getStream( RESOURCE_DIR + "/" + line );
if ( is == null )
{
throw new IOException( "The resource " + line + " doesn't exists in " + DEFAULT_TEMPLATE + " template." );
}
File outputFile = new File( outputDirectory, line );
if ( !outputFile.getParentFile().exists() )
{
outputFile.getParentFile().mkdirs();
}
FileOutputStream w = new FileOutputStream( outputFile );
IOUtil.copy( is, w );
IOUtil.close( is );
IOUtil.close( w );
}
}
}
private InputStream getStream( String name )
throws Exception
{
return DoxiaMojo.class.getClassLoader().getResourceAsStream( name );
}
}

View File

@ -0,0 +1,140 @@
body {
margin: 0px;
padding: 0px 0px 10px 0px;
}
img {
border:none;
}
table {
padding:0px;
width: 100%;
margin-left: -2px;
margin-right: -2px;
}
acronym {
cursor: help;
border-bottom: 1px dotted #feb;
}
table.bodyTable th, table.bodyTable td {
padding: 2px 4px 2px 4px;
vertical-align: top;
}
div.clear{
clear:both;
visibility: hidden;
}
div.clear hr{
display: none;
}
#bannerLeft, #bannerRight {
font-size: xx-large;
font-weight: bold;
}
#bannerLeft img, #bannerRight img {
margin: 8px;
}
.xleft, #bannerLeft img {
float:left;
text-shadow: #7CFC00;
}
.xright, #bannerRight img {
float:right;
text-shadow: #7CFC00;
}
#banner {
border-bottom: 1px solid #fff;
}
#banner img {
border: none;
}
#footer, #breadcrumbs {
padding: 3px 10px 3px 10px;
}
#leftColumn {
width: 18%;
float:left;
}
#bodyColumn {
margin-left: 20%;
}
#legend {
padding: 8px 0 8px 0;
}
#navcolumn {
padding: 8px 4px 0 8px;
}
#navcolumn h5, #navcolumn ul {
margin: 0;
padding: 0;
font-size: small;
}
#navcolumn li {
list-style-type: none;
background-image: none;
background-repeat: no-repeat;
background-position: 0 0.4em;
padding-left: 16px;
list-style-position: ouside;
line-height: 1.2em;
font-size: smaller;
}
#navcolumn li.expanded {
background-image: url(../images/expanded.gif);
}
#navcolumn li.collapsed {
background-image: url(../images/collapsed.gif);
}
#poweredBy {
text-align: center;
}
#navcolumn img {
margin-top: 10px;
margin-bottom: 3px;
}
#poweredBy img {
display:block;
margin: 20px 0 20px 17px;
border: 1px solid black;
width: 90px;
height: 30px;
}
#search img {
margin: 0px;
display: block;
}
#search #q, #search #btnG {
border: 1px solid #999;
margin-bottom:10px;
}
#search form {
margin: 0px;
}
#lastPublished {
font-size: x-small;
}
.navSection {
margin-bottom: 2px;
padding: 8px;
}
.navSectionHead {
font-weight: bold;
font-size: x-small;
}
.section {
padding: 4px;
}
#footer {
font-size: x-small;
}
#breadcrumbs {
font-size: x-small;
margin: 0pt;
}
.source {
padding: 12px;
margin: 1em 7px 1em 7px;
}
.source pre {
margin: 0px;
padding: 0px;
}

View File

@ -0,0 +1,112 @@
body, td, select, input, li{
font-family: Verdana, Helvetica, Arial, sans-serif;
font-size: 13px;
}
a {
text-decoration: none;
}
a:link {
color:#36a;
}
a:visited {
color:#47a;
}
a:active, a:hover {
color:#69c;
}
#legend li.externalLink {
background: url(../images/external.png) left top no-repeat;
padding-left: 18px;
}
a.externalLink, a.externalLink:link, a.externalLink:visited, a.externalLink:active, a.externalLink:hover {
background: url(../images/external.png) right center no-repeat;
padding-right: 18px;
}
#legend li.newWindow {
background: url(../images/newwindow.png) left top no-repeat;
padding-left: 18px;
}
a.newWindow, a.newWindow:link, a.newWindow:visited, a.newWindow:active, a.newWindow:hover {
background: url(../images/newwindow.png) right center no-repeat;
padding-right: 18px;
}
h2 {
padding: 4px 4px 4px 6px;
border: 1px solid #999;
color: #900;
background-color: #ddd;
font-weight:900;
font-size: x-large;
}
h3 {
padding: 4px 4px 4px 6px;
border: 1px solid #aaa;
color: #900;
background-color: #eee;
font-weight: normal;
font-size: large;
}
h4 {
padding: 4px 4px 4px 6px;
border: 1px solid #bbb;
color: #900;
background-color: #fff;
font-weight: normal;
font-size: large;
}
h5 {
padding: 4px 4px 4px 6px;
color: #900;
font-size: normal;
}
p {
line-height: 1.3em;
font-size: small;
}
#breadcrumbs {
border-top: 1px solid #aaa;
border-bottom: 1px solid #aaa;
background-color: #ccc;
}
#leftColumn {
margin: 10px 0 0 5px;
border: 1px solid #999;
background-color: #eee;
}
#navcolumn h5 {
font-size: smaller;
border-bottom: 1px solid #aaaaaa;
padding-top: 2px;
color: #000;
}
table.bodyTable th {
color: white;
background-color: #bbb;
text-align: left;
font-weight: bold;
}
table.bodyTable th, table.bodyTable td {
font-size: 1em;
}
table.bodyTable tr.a {
background-color: #ddd;
}
table.bodyTable tr.b {
background-color: #eee;
}
.source {
border: 1px solid #999;
}
dl {
padding: 4px 4px 4px 6px;
border: 1px solid #aaa;
background-color: #ffc;
}
dt {
color: #900;
}

View File

@ -0,0 +1,7 @@
#banner, #footer, #leftcol, #breadcrumbs, .docs #toc, .docs .courtesylinks, #leftColumn, #navColumn {
display: none;
}
#bodyColumn, body.docs div.docs {
margin: 0 !important;
border: none !important
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 956 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 664 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 606 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 609 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 355 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1010 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 634 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1019 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 606 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1023 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 122 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 990 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 576 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 780 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 562 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 951 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 946 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 950 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 808 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 680 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 B

View File

@ -0,0 +1,50 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>$title</title>
<style type="text/css" media="all">
@import url("$relativePath/css/maven-base.css");
@import url("$relativePath/css/maven-theme.css");
@import url("$relativePath/css/site.css");
</style>
<link rel="stylesheet" href="$relativePath/style/print.css" type="text/css" media="print" />
#foreach( $author in $authors )
<meta name="author" content="$author" />
#end
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
</head>
<body class="composite">
<div id="banner">
$bannerLeft
$bannerRight
<div class="clear">
<hr/>
</div>
</div>
<div id="breadcrumbs">
<div class="xleft">$navBarLeft</div>
<div class="xright">$links</div>
<div class="clear">
<hr/>
</div>
</div>
<div id="leftColumn"><div id="navcolumn">$mainMenu<a href="http://maven.apache.org/" title="Built by Maven" id="poweredBy">
<img alt="Built by Maven" src="$relativePath/images/logos/maven-feather.png"></img>
</a>
</div></div>
<div id="bodyColumn">
<div id="contentBox">
$bodyContent
</div>
</div>
<div class="clear">
<hr/>
</div>
<div id="footer">
<div class="xright">&#169; 2002-2005, Apache Software Foundation</div>
<div class="clear">
<hr/>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,74 @@
images/nw_maj_rond.gif
images/expanded.gif
images/icon_arrowfolderopen2_sml.gif
images/se_maj_rond.gif
images/icon_folder_lrg.gif
images/icon_help_lrg.gif
images/sw_med_rond.gif
images/external.png
images/icon_waste_sml.gif
images/icon_sortup.gif
images/newwindow-classic.png
images/icon_error_sml.gif
images/icon_info_sml.gif
images/remove.gif
images/file.gif
images/folder-closed.gif
images/icon_infosml.gif
images/nw_med.gif
images/pdf.gif
images/icon_arrowfolderclosed1_sml.gif
images/nw_maj_hi.gif
images/icon_folder_sml.gif
images/product_logo.gif
images/icon_members_lrg.gif
images/collapsed.gif
images/nw_min_hi.gif
images/help_logo.gif
images/update.gif
images/none.png
images/icon_arrowmembers1_sml.gif
images/icon_sortleft.gif
images/icon_arrowmembers2_sml.gif
images/nw_maj.gif
images/icon_help_sml.gif
images/icon_alert.gif
images/nw_min_036.gif
images/external-classic.png
images/icon_warning_lrg.gif
images/icon_doc_lrg.gif
images/icon_success_lrg.gif
images/nw_min.gif
images/icon_arrowfolder1_sml.gif
images/icon_usergroups_lrg.gif
images/icon_arrowfolder2_sml.gif
images/nw_med_rond.gif
images/strich.gif
images/icon_sortright.gif
images/icon_arrowwaste1_sml.gif
images/sw_maj_rond.gif
images/icon_arrowwaste2_sml.gif
images/icon_members_sml.gif
images/icon_usergroups_sml.gif
images/icon_confirmsml.gif
images/fix.gif
images/icon_sortdown.gif
images/add.gif
images/icon_doc_sml.gif
images/poweredby_036.gif
images/icon_warning_sml.gif
images/nw_med_hi.gif
images/icon_success_sml.gif
images/icon_alertsml.gif
images/sw_min.gif
images/icon_waste_lrg.gif
images/logos/maven-feather.png
images/icon_arrowusergroups1_sml.gif
images/icon_arrowusergroups2_sml.gif
images/newwindow.png
images/icon_error_lrg.gif
images/icon_info_lrg.gif
images/folder-open.gif
css/maven-base.css
css/print.css
css/maven-theme.css