You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by vs...@apache.org on 2008/01/29 01:13:57 UTC
svn commit: r616119 - in
/maven/sandbox/trunk/plugins/maven-linkcheck-plugin: ./
src/main/java/org/apache/maven/plugins/linkcheck/ src/main/resources/
src/site/apt/
Author: vsiveton
Date: Mon Jan 28 16:13:56 2008
New Revision: 616119
URL: http://svn.apache.org/viewvc?rev=616119&view=rev
Log:
o major refactoring to bump to doxia:1.0-alpha-10
o included changes due to r616109
o added new clean goal
o updated doc
Added:
maven/sandbox/trunk/plugins/maven-linkcheck-plugin/src/main/java/org/apache/maven/plugins/linkcheck/CleanMojo.java (with props)
Modified:
maven/sandbox/trunk/plugins/maven-linkcheck-plugin/pom.xml
maven/sandbox/trunk/plugins/maven-linkcheck-plugin/src/main/java/org/apache/maven/plugins/linkcheck/LinkcheckReport.java
maven/sandbox/trunk/plugins/maven-linkcheck-plugin/src/main/resources/linkcheck-report.properties
maven/sandbox/trunk/plugins/maven-linkcheck-plugin/src/site/apt/index.apt
maven/sandbox/trunk/plugins/maven-linkcheck-plugin/src/site/apt/usage.apt
Modified: maven/sandbox/trunk/plugins/maven-linkcheck-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-linkcheck-plugin/pom.xml?rev=616119&r1=616118&r2=616119&view=diff
==============================================================================
--- maven/sandbox/trunk/plugins/maven-linkcheck-plugin/pom.xml (original)
+++ maven/sandbox/trunk/plugins/maven-linkcheck-plugin/pom.xml Mon Jan 28 16:13:56 2008
@@ -21,75 +21,120 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
+
<parent>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugins</artifactId>
<version>8</version>
</parent>
- <prerequisites>
- <maven>2.0.4</maven>
- </prerequisites>
-
<artifactId>maven-linkcheck-plugin</artifactId>
<packaging>maven-plugin</packaging>
<name>Maven Linkcheck Plugin</name>
<version>1.0-SNAPSHOT</version>
- <developers>
- <developer>
- <id>vsiveton</id>
- <name>Vincent Siveton</name>
- <email>vsiveton@apache.org</email>
- <organization>Apache Software Foundation</organization>
- <roles>
- <role>Java Developer</role>
- </roles>
- <timezone>-5</timezone>
- </developer>
- </developers>
+ <prerequisites>
+ <maven>2.0.6</maven>
+ </prerequisites>
<dependencies>
+ <!-- maven -->
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-project</artifactId>
+ <version>2.0.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-settings</artifactId>
+ <version>2.0.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-artifact</artifactId>
+ <version>2.0.6</version>
+ </dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
+ <version>2.0.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.reporting</groupId>
+ <artifactId>maven-reporting-api</artifactId>
<version>2.0.4</version>
- <exclusions>
- <!-- Using org.codehaus.plexus:plexus-utils instead of -->
- <exclusion>
- <groupId>plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- </exclusion>
- </exclusions>
</dependency>
<dependency>
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-impl</artifactId>
<version>2.0.4</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-doxia-tools</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+
+ <!-- doxia -->
+ <dependency>
+ <groupId>org.apache.maven.doxia</groupId>
+ <artifactId>doxia-module-xhtml</artifactId>
+ <version>${doxia.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.doxia</groupId>
+ <artifactId>doxia-sink-api</artifactId>
+ <version>${doxia.version}</version>
+ </dependency>
+
+ <!-- doxia-sitetools -->
+ <dependency>
+ <groupId>org.apache.maven.doxia</groupId>
+ <artifactId>doxia-decoration-model</artifactId>
+ <version>${doxia-sitetools.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.doxia</groupId>
+ <artifactId>doxia-site-renderer</artifactId>
+ <version>${doxia-sitetools.version}</version>
<exclusions>
- <!-- Using org.codehaus.plexus:plexus-utils instead of -->
<exclusion>
- <groupId>plexus</groupId>
- <artifactId>plexus-utils</artifactId>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-api</artifactId>
</exclusion>
</exclusions>
</dependency>
+
+ <!-- linkcheck -->
<dependency>
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-linkcheck</artifactId>
<version>1.0-beta-1-SNAPSHOT</version>
</dependency>
+
+ <!-- plexus -->
<dependency>
<groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- <version>1.4.5</version>
+ <artifactId>plexus-i18n</artifactId>
+ <version>1.0-beta-7</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-api</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
- <!-- test dependencies -->
+
+ <!-- misc -->
<dependency>
- <groupId>org.apache.maven.shared</groupId>
- <artifactId>maven-plugin-testing-harness</artifactId>
- <version>1.1</version>
- <scope>test</scope>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-utils</artifactId>
+ <version>1.4.6</version>
</dependency>
</dependencies>
@@ -97,9 +142,14 @@
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-plugin-plugin</artifactId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.3</version>
</plugin>
</plugins>
</build>
-</project>
\ No newline at end of file
+ <properties>
+ <doxia.version>1.0-alpha-10</doxia.version>
+ <doxia-sitetools.version>1.0-alpha-10</doxia-sitetools.version>
+ </properties>
+</project>
Added: maven/sandbox/trunk/plugins/maven-linkcheck-plugin/src/main/java/org/apache/maven/plugins/linkcheck/CleanMojo.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-linkcheck-plugin/src/main/java/org/apache/maven/plugins/linkcheck/CleanMojo.java?rev=616119&view=auto
==============================================================================
--- maven/sandbox/trunk/plugins/maven-linkcheck-plugin/src/main/java/org/apache/maven/plugins/linkcheck/CleanMojo.java (added)
+++ maven/sandbox/trunk/plugins/maven-linkcheck-plugin/src/main/java/org/apache/maven/plugins/linkcheck/CleanMojo.java Mon Jan 28 16:13:56 2008
@@ -0,0 +1,63 @@
+package org.apache.maven.plugins.linkcheck;
+
+/*
+ * 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.
+ */
+
+import java.io.File;
+
+import org.apache.maven.plugin.MojoExecutionException;
+
+/**
+ * Clean <code>Linkcheck</code> generated files by the report.
+ *
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version $Id$
+ * @since 1.0
+ * @goal clean
+ */
+public class CleanMojo
+ extends LinkcheckReport
+{
+ /** {@inheritDoc} */
+ public void execute()
+ throws MojoExecutionException
+ {
+ File cache = new File( linkcheckCache );
+ if ( cache.isFile() && cache.exists() )
+ {
+ cache.delete();
+
+ if ( getLog().isDebugEnabled() )
+ {
+ getLog().debug( "The file '" + cache.getAbsolutePath() + "' has been deleted." );
+ }
+ }
+
+ File output = new File( linkcheckOutput );
+ if ( output.isFile() && output.exists() )
+ {
+ output.delete();
+
+ if ( getLog().isDebugEnabled() )
+ {
+ getLog().debug( "The file '" + output.getAbsolutePath() + "' has been deleted." );
+ }
+ }
+ }
+}
Propchange: maven/sandbox/trunk/plugins/maven-linkcheck-plugin/src/main/java/org/apache/maven/plugins/linkcheck/CleanMojo.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/plugins/maven-linkcheck-plugin/src/main/java/org/apache/maven/plugins/linkcheck/CleanMojo.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Modified: maven/sandbox/trunk/plugins/maven-linkcheck-plugin/src/main/java/org/apache/maven/plugins/linkcheck/LinkcheckReport.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-linkcheck-plugin/src/main/java/org/apache/maven/plugins/linkcheck/LinkcheckReport.java?rev=616119&r1=616118&r2=616119&view=diff
==============================================================================
--- maven/sandbox/trunk/plugins/maven-linkcheck-plugin/src/main/java/org/apache/maven/plugins/linkcheck/LinkcheckReport.java (original)
+++ maven/sandbox/trunk/plugins/maven-linkcheck-plugin/src/main/java/org/apache/maven/plugins/linkcheck/LinkcheckReport.java Mon Jan 28 16:13:56 2008
@@ -20,35 +20,59 @@
*/
import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
+import java.util.Map;
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.doxia.linkcheck.HttpBean;
import org.apache.maven.doxia.linkcheck.LinkCheck;
import org.apache.maven.doxia.linkcheck.model.LinkcheckFile;
import org.apache.maven.doxia.linkcheck.model.LinkcheckFileResult;
import org.apache.maven.doxia.linkcheck.model.LinkcheckModel;
-import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.module.xhtml.decoration.render.RenderingContext;
+import org.apache.maven.doxia.site.decoration.Body;
+import org.apache.maven.doxia.site.decoration.DecorationModel;
+import org.apache.maven.doxia.site.decoration.LinkItem;
import org.apache.maven.doxia.siterenderer.Renderer;
+import org.apache.maven.doxia.siterenderer.RendererException;
+import org.apache.maven.doxia.siterenderer.SiteRenderingContext;
+import org.apache.maven.doxia.siterenderer.sink.SiteRendererSink;
+import org.apache.maven.doxia.tools.SiteTool;
+import org.apache.maven.doxia.tools.SiteToolException;
+import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
import org.apache.maven.reporting.AbstractMavenReport;
-import org.apache.maven.reporting.AbstractMavenReportRenderer;
import org.apache.maven.reporting.MavenReportException;
import org.apache.maven.settings.Proxy;
import org.apache.maven.settings.Settings;
import org.codehaus.plexus.i18n.I18N;
+import org.codehaus.plexus.util.StringUtils;
/**
- * Generates a link check report.
+ * Generates a <code>Linkcheck</code> report.
*
* @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
* @version $Id$
+ * @since 1.0
* @goal linkcheck
*/
public class LinkcheckReport
extends AbstractMavenReport
{
+ // ----------------------------------------------------------------------
+ // Report Parameters
+ // ----------------------------------------------------------------------
+
/**
* The Maven Project.
*
@@ -59,13 +83,79 @@
protected MavenProject project;
/**
+ * The reactor projects.
+ *
+ * @parameter expression="${reactorProjects}"
+ * @required
+ * @readonly
+ */
+ protected List reactorProjects;
+
+ /**
+ * Doxia Site Renderer.
+ *
+ * @component
+ */
+ protected Renderer siteRenderer;
+
+ /**
+ * Internationalization.
+ *
+ * @component
+ */
+ protected I18N i18n;
+
+ /**
+ * Local Repository.
+ *
+ * @parameter expression="${localRepository}"
+ * @required
+ * @readonly
+ */
+ protected ArtifactRepository localRepository;
+
+ /**
+ * Remote repositories used for the project.
+ *
+ * @parameter expression="${project.remoteArtifactRepositories}"
+ */
+ protected List repositories;
+
+ /**
+ * SiteTool component.
+ *
+ * @component
+ */
+ protected SiteTool siteTool;
+
+ /**
+ * Report output directory.
+ *
+ * @parameter expression="${project.reporting.outputDirectory}"
+ * @required
+ */
+ protected File outputDirectory;
+
+ /**
* The Maven Settings.
*
* @parameter default-value="${settings}"
* @required
* @readonly
*/
- private Settings settings;
+ protected Settings settings;
+
+ /**
+ * Directory containing the <code>site.xml</code> file.
+ *
+ * @parameter expression="${basedir}/src/site"
+ * @required
+ */
+ protected File siteDirectory;
+
+ // ----------------------------------------------------------------------
+ // Linkcheck parameters
+ // ----------------------------------------------------------------------
/**
* The settings offline paramater.
@@ -85,20 +175,12 @@
protected boolean httpFollowRedirect;
/**
- * Report output directory.
- *
- * @parameter expression="${project.reporting.outputDirectory}"
- * @required
- */
- protected File outputDirectory;
-
- /**
* The location of the linkcheck cache.
*
* @parameter expression="${project.build.directory}/linkcheck/linkcheck.cache"
* @required
*/
- private String linkcheckCache;
+ protected String linkcheckCache;
/**
* The location of the linkcheck report.
@@ -106,10 +188,10 @@
* @parameter expression="${project.build.directory}/linkcheck/linkcheck.xml"
* @required
*/
- private String linkcheckOutput;
+ protected String linkcheckOutput;
/**
- * The current report level. Defaults to {@link LinkCheckResult#WARNING}.
+ * The current report level. Defaults to {@link LinkcheckFileResult#WARNING_LEVEL}.
*
* @parameter default-value="2"
*/
@@ -122,19 +204,15 @@
* <dd>
* The HTTP GET method is defined in section 9.3 of
* <a HREF="http://www.ietf.org/rfc/rfc2616.txt">RFC2616</a>:
- * <blockquote>
* The GET method means retrieve whatever information (in the form of an
* entity) is identified by the Request-URI.
- * </blockquote>
* </dd>
* <dt>HTTP HEAD</dt>
* <dd>
* The HTTP HEAD method is defined in section 9.4 of
* <a HREF="http://www.ietf.org/rfc/rfc2616.txt">RFC2616</a>:
- * <blockquote>
* The HEAD method is identical to GET except that the server MUST NOT
* return a message-body in the response.
- * </blockquote>
* </dd>
* </dl>
*
@@ -143,101 +221,189 @@
protected String httpMethod;
/**
- * The list of links to exclude.
+ * The list of HTTP errors to ignored.
*
* @parameter
+ * @see {@link HttpStatus} for all defined values.
*/
- protected String[] exludedLinks;
+ protected int[] excludedHttpStatusErrors;
/**
- * Doxia Site Renderer.
+ * The list of HTTP warnings to ignored.
*
- * @component
+ * @parameter
+ * @see {@link HttpStatus} for all defined values.
*/
- protected Renderer siteRenderer;
+ protected int[] excludedHttpStatusWarnings;
/**
- * Internationalization.
+ * The list of pages to exclude.
*
- * @component
+ * @parameter
*/
- protected I18N i18n;
+ protected String[] excludedPages;
/**
- * @see org.apache.maven.reporting.AbstractMavenReport#getDescription(java.util.Locale)
+ * The list of links to exclude.
+ *
+ * @parameter
*/
+ protected String[] excludedLinks;
+
+ // ----------------------------------------------------------------------
+ // Public methods
+ // ----------------------------------------------------------------------
+
+ /** {@inheritDoc} */
public String getDescription( Locale locale )
{
return i18n.getString( "linkcheck-report", locale, "report.linkcheck.description" );
}
- /**
- * @see org.apache.maven.reporting.AbstractMavenReport#getName(java.util.Locale)
- */
+ /** {@inheritDoc} */
public String getName( Locale locale )
{
return i18n.getString( "linkcheck-report", locale, "report.linkcheck.name" );
}
- /**
- * @see org.apache.maven.reporting.AbstractMavenReport#getOutputDirectory()
- */
- protected String getOutputDirectory()
+ /** {@inheritDoc} */
+ public String getOutputName()
{
- return outputDirectory.getAbsolutePath();
+ return "linkcheck";
}
- /**
- * @see org.apache.maven.reporting.AbstractMavenReport#getOutputName()
- */
- public String getOutputName()
+ /** {@inheritDoc} */
+ public boolean canGenerateReport()
{
- return "linkcheck";
+ boolean can = outputDirectory.exists();
+
+ if ( !can )
+ {
+ if ( getLog().isWarnEnabled() )
+ {
+ getLog().warn( "Linkcheck report skipped. You need to call 'mvn site' before." );
+ }
+ }
+
+ return can;
}
- /**
- * @see org.apache.maven.reporting.AbstractMavenReport#getProject()
- */
+ /** {@inheritDoc} */
+ public void execute()
+ throws MojoExecutionException
+ {
+ if ( !canGenerateReport() )
+ {
+ return;
+ }
+
+ try
+ {
+ DecorationModel model = new DecorationModel();
+ model.setBody( new Body() );
+ Map attributes = new HashMap();
+ attributes.put( "outputEncoding", "UTF-8" );
+ attributes.put( "project", project );
+ Locale locale = Locale.getDefault();
+ Artifact skinArtifact = siteTool.getDefaultSkinArtifact( localRepository, repositories );
+ SiteRenderingContext siteContext = siteRenderer.createContextForSkin( skinArtifact.getFile(), attributes,
+ model, getName( locale ), locale );
+
+ RenderingContext context = new RenderingContext( outputDirectory, getOutputName() + ".html" );
+
+ SiteRendererSink sink = new SiteRendererSink( context );
+ generate( sink, locale );
+
+ outputDirectory.mkdirs();
+
+ Writer writer = new FileWriter( new File( outputDirectory, getOutputName() + ".html" ) );
+
+ siteRenderer.generateDocument( writer, sink, siteContext );
+
+ siteRenderer.copyResources( siteContext, new File( project.getBasedir(), "src/site/resources" ),
+ outputDirectory );
+ }
+ catch ( IOException e )
+ {
+ throw new MojoExecutionException( "An error has occurred in " + getName( Locale.ENGLISH )
+ + " report generation.", e );
+ }
+ catch ( SiteToolException e )
+ {
+ throw new MojoExecutionException( "An error has occurred in " + getName( Locale.ENGLISH )
+ + " report generation.", e );
+ }
+ catch ( RendererException e )
+ {
+ throw new MojoExecutionException( "An error has occurred in " + getName( Locale.ENGLISH )
+ + " report generation.", e );
+ }
+ catch ( MavenReportException e )
+ {
+ throw new MojoExecutionException( "An error has occurred in " + getName( Locale.ENGLISH )
+ + " report generation.", e );
+ }
+ }
+
+ // ----------------------------------------------------------------------
+ // Protected methods
+ // ----------------------------------------------------------------------
+
+ /** {@inheritDoc} */
+ protected String getOutputDirectory()
+ {
+ return outputDirectory.getAbsolutePath();
+ }
+
+ /** {@inheritDoc} */
protected MavenProject getProject()
{
return project;
}
- /**
- * @see org.apache.maven.reporting.AbstractMavenReport#getSiteRenderer()
- */
+ /** {@inheritDoc} */
protected Renderer getSiteRenderer()
{
return siteRenderer;
}
- /**
- * @see org.apache.maven.reporting.AbstractMavenReport#canGenerateReport()
- */
- public boolean canGenerateReport()
- {
- return outputDirectory.exists();
- }
-
- /**
- * @see org.apache.maven.reporting.AbstractMavenReport#executeReport(java.util.Locale)
- */
+ /** {@inheritDoc} */
protected void executeReport( Locale locale )
throws MavenReportException
{
- if ( !canGenerateReport() )
+ try
{
- return;
+ LinkCheck lc = executeLinkCheck( locale );
+
+ generateReport( locale, lc );
+ }
+ catch ( Exception e )
+ {
+ throw new MavenReportException( "IOException: " + e.getMessage(), e );
}
+ }
+
+ // ----------------------------------------------------------------------
+ // Private methods
+ // ----------------------------------------------------------------------
+ /**
+ * Execute the <code>Linkcheck</code> tool.
+ */
+ private LinkCheck executeLinkCheck( Locale locale )
+ throws Exception
+ {
// Wrap linkcheck
LinkCheck lc = new LinkCheck();
lc.setOnline( !offline );
lc.setBasedir( outputDirectory );
lc.setReportOutput( new File( linkcheckOutput ) );
lc.setLinkCheckCache( new File( linkcheckCache ) );
- lc.setExcludedLinks( exludedLinks );
+ lc.setExcludedLinks( getExcludedLinks( locale ) );
+ lc.setExcludedPages( getExcludedPages() );
lc.setReportLevel( reportLevel );
+ lc.setExcludedHttpStatusErrors( excludedHttpStatusErrors );
+ lc.setExcludedHttpStatusWarnings( excludedHttpStatusWarnings );
HttpBean bean = new HttpBean();
bean.setMethod( httpMethod );
@@ -255,300 +421,375 @@
lc.doExecute();
- // Render report
- LinkcheckRenderer r = new LinkcheckRenderer( getSink(), i18n, locale, lc.getModel() );
- r.render();
+ return lc;
}
- // ----------------------------------------------------------------------
- //
- // ----------------------------------------------------------------------
-
- private static class LinkcheckRenderer
- extends AbstractMavenReportRenderer
+ private String[] getExcludedLinks( Locale locale )
+ throws Exception
{
- private I18N i18n;
+ List linksToExclude = ( excludedLinks != null ? new ArrayList( Arrays.asList( excludedLinks ) ) : new ArrayList() );
- private Locale locale;
-
- private LinkcheckModel linkcheckModel;
-
- LinkcheckRenderer( Sink sink, I18N i18n, Locale locale, LinkcheckModel linkcheckModel )
+ if ( project.getUrl() != null )
{
- super( sink );
+ // Using interpolated references in the decoration model
+ DecorationModel site = siteTool.getDecorationModel( project, reactorProjects, localRepository,
+ repositories, siteDirectory, locale, "ISO-8859-1",
+ "ISO-8859-1" );
- this.i18n = i18n;
+ String baseUrl = project.getUrl();
+ if ( site.getBannerLeft() != null && StringUtils.isNotEmpty( site.getBannerLeft().getHref() ) )
+ {
+ linksToExclude.add( siteTool.getRelativePath( site.getBannerLeft().getHref(), baseUrl ) );
+ }
+ if ( site.getBannerRight() != null && StringUtils.isNotEmpty( site.getBannerRight().getHref() ) )
+ {
+ linksToExclude.add( siteTool.getRelativePath( site.getBannerRight().getHref(), baseUrl ) );
+ }
+ if ( site.getBody() != null && site.getBody().getLinks() != null )
+ {
+ for ( Iterator it = site.getBody().getLinks().iterator(); it.hasNext(); )
+ {
+ LinkItem link = (LinkItem) it.next();
+ linksToExclude.add( siteTool.getRelativePath( link.getHref(), baseUrl ) );
+ }
+ }
+ }
- this.locale = locale;
+ return (String[]) linksToExclude.toArray( new String[0] );
+ }
- this.linkcheckModel = linkcheckModel;
- }
+ private String[] getExcludedPages()
+ {
+ List linksToExclude;
- /**
- * @see org.apache.maven.reporting.AbstractMavenReportRenderer#getTitle()
- */
- public String getTitle()
+ if ( excludedPages != null )
{
- return i18n.getString( "linkcheck-report", locale, "report.linkcheck.title" );
+ linksToExclude = Arrays.asList( excludedPages );
}
-
- /**
- * @see org.apache.maven.reporting.AbstractMavenReportRenderer#renderBody()
- */
- public void renderBody()
+ else
{
- if ( linkcheckModel == null )
- {
- startSection( getTitle() );
+ linksToExclude = new ArrayList();
+ }
- paragraph( i18n.getString( "linkcheck-report", locale, "report.linkcheck.empty" ) );
+ // Exclude this report
+ linksToExclude.add( getOutputName() + ".html" );
- endSection();
+ return (String[]) linksToExclude.toArray( new String[0] );
+ }
- return;
- }
+ /**
+ * Generate the Linkcheck report.
+ *
+ * @param locale the wanted locale
+ * @param lc the lc object used
+ */
+ private void generateReport( Locale locale, LinkCheck lc )
+ {
+ LinkcheckModel linkcheckModel = lc.getModel();
- // Overview
- startSection( getTitle() );
+ getSink().head();
+ getSink().text( i18n.getString( "linkcheck-report", locale, "report.linkcheck.name" ) );
+ getSink().head_();
- paragraph( i18n.getString( "linkcheck-report", locale, "report.linkcheck.overview" ) );
+ getSink().body();
- //Statistics
- generateSummarySection();
+ if ( linkcheckModel == null )
+ {
+ getSink().section1();
+ getSink().sectionTitle1();
+ getSink().text( getName( locale ) );
+ getSink().sectionTitle1_();
- //Statistics
- generateDetailsSection();
+ getSink().paragraph();
+ getSink().rawText( i18n.getString( "linkcheck-report", locale, "report.linkcheck.empty" ) );
+ getSink().paragraph_();
- endSection();
- }
+ getSink().section1_();
- private void generateSummarySection()
- {
- // Calculus
- List linkcheckFiles = linkcheckModel.getFiles();
+ getSink().body_();
+ getSink().flush();
+ getSink().close();
- int totalFiles = linkcheckFiles.size();
+ return;
+ }
- int totalLinks = 0;
- int totalValidLinks = 0;
- int totalErrorLinks = 0;
- int totalWarningLinks = 0;
- for ( Iterator it = linkcheckFiles.iterator(); it.hasNext(); )
- {
- LinkcheckFile linkcheckFile = (LinkcheckFile) it.next();
+ // Overview
+ getSink().section1();
+ getSink().sectionTitle1();
+ getSink().text( getName( locale ) );
+ getSink().sectionTitle1_();
+
+ getSink().paragraph();
+ getSink().rawText( i18n.getString( "linkcheck-report", locale, "report.linkcheck.overview" ) );
+ getSink().paragraph_();
+
+ getSink().section1_();
+
+ //Statistics
+ generateSummarySection( locale, linkcheckModel );
+
+ //Statistics
+ generateDetailsSection( locale, linkcheckModel );
+
+ getSink().body_();
+ getSink().flush();
+ getSink().close();
+ }
- totalLinks += linkcheckFile.getNumberOfLinks();
- totalValidLinks += linkcheckFile.getNumberOfLinks( LinkcheckFileResult.VALID_LEVEL );
- totalErrorLinks += linkcheckFile.getNumberOfLinks( LinkcheckFileResult.ERROR_LEVEL );
- totalWarningLinks += linkcheckFile.getNumberOfLinks( LinkcheckFileResult.WARNING_LEVEL );
- }
+ private void generateSummarySection( Locale locale, LinkcheckModel linkcheckModel )
+ {
+ // Calculus
+ List linkcheckFiles = linkcheckModel.getFiles();
- startSection( i18n.getString( "linkcheck-report", locale, "report.linkcheck.summary" ) );
+ int totalFiles = linkcheckFiles.size();
- paragraph( i18n.getString( "linkcheck-report", locale, "report.linkcheck.summary.overview" ) );
+ int totalLinks = 0;
+ int totalValidLinks = 0;
+ int totalErrorLinks = 0;
+ int totalWarningLinks = 0;
+ for ( Iterator it = linkcheckFiles.iterator(); it.hasNext(); )
+ {
+ LinkcheckFile linkcheckFile = (LinkcheckFile) it.next();
+
+ totalLinks += linkcheckFile.getNumberOfLinks();
+ totalValidLinks += linkcheckFile.getNumberOfLinks( LinkcheckFileResult.VALID_LEVEL );
+ totalErrorLinks += linkcheckFile.getNumberOfLinks( LinkcheckFileResult.ERROR_LEVEL );
+ totalWarningLinks += linkcheckFile.getNumberOfLinks( LinkcheckFileResult.WARNING_LEVEL );
+ }
+
+ getSink().section1();
+ getSink().sectionTitle1();
+ getSink().text( i18n.getString( "linkcheck-report", locale, "report.linkcheck.summary" ) );
+ getSink().sectionTitle1_();
+
+ getSink().paragraph();
+ getSink().rawText( i18n.getString( "linkcheck-report", locale, "report.linkcheck.summary.overview" ) );
+ getSink().paragraph_();
+
+ getSink().table();
+
+ //Header
+ generateTableHeader( locale, false );
+
+ //Content
+ getSink().tableRow();
+
+ getSink().tableCell();
+ getSink().bold();
+ getSink().text( totalFiles + "" );
+ getSink().bold_();
+ getSink().tableCell_();
+ getSink().tableCell();
+ getSink().bold();
+ getSink().text( totalLinks + "" );
+ getSink().bold_();
+ getSink().tableCell_();
+ getSink().tableCell();
+ getSink().bold();
+ getSink().text( String.valueOf( totalValidLinks ) );
+ getSink().bold_();
+ getSink().tableCell_();
+ getSink().tableCell();
+ getSink().bold();
+ getSink().text( String.valueOf( totalWarningLinks ) );
+ getSink().bold_();
+ getSink().tableCell_();
+ getSink().tableCell();
+ getSink().bold();
+ getSink().text( String.valueOf( totalErrorLinks ) );
+ getSink().bold_();
+ getSink().tableCell_();
- startTable();
+ getSink().tableRow_();
- //Header
- generateTableHeader( false );
+ getSink().table_();
- //Content
- sink.tableRow();
+ getSink().section1_();
+ }
- sink.tableCell();
- sink.bold();
- sink.text( totalFiles + "" );
- sink.bold_();
- sink.tableCell_();
- sink.tableCell();
- sink.bold();
- sink.text( totalLinks + "" );
- sink.bold_();
- sink.tableCell_();
- sink.tableCell();
- sink.bold();
- sink.text( String.valueOf( totalValidLinks ) );
- sink.bold_();
- sink.tableCell_();
- sink.tableCell();
- sink.bold();
- sink.text( String.valueOf( totalWarningLinks ) );
- sink.bold_();
- sink.tableCell_();
- sink.tableCell();
- sink.bold();
- sink.text( String.valueOf( totalErrorLinks ) );
- sink.bold_();
- sink.tableCell_();
+ private void generateDetailsSection( Locale locale, LinkcheckModel linkcheckModel )
+ {
+ getSink().section1();
+ getSink().sectionTitle1();
+ getSink().text( i18n.getString( "linkcheck-report", locale, "report.linkcheck.detail" ) );
+ getSink().sectionTitle1_();
- sink.tableRow_();
+ getSink().paragraph();
+ getSink().rawText( i18n.getString( "linkcheck-report", locale, "report.linkcheck.detail.overview" ) );
+ getSink().paragraph_();
- endTable();
+ getSink().table();
- endSection();
- }
+ //Header
+ generateTableHeader( locale, true );
- private void generateDetailsSection()
+ // Content
+ List linkcheckFiles = linkcheckModel.getFiles();
+ for ( Iterator it = linkcheckFiles.iterator(); it.hasNext(); )
{
- startSection( i18n.getString( "linkcheck-report", locale, "report.linkcheck.detail" ) );
+ LinkcheckFile linkcheckFile = (LinkcheckFile) it.next();
- paragraph( i18n.getString( "linkcheck-report", locale, "report.linkcheck.detail.overview" ) );
+ getSink().tableRow();
- startTable();
+ getSink().tableCell();
+ if ( linkcheckFile.getUnsuccessful() == 0 )
+ {
+ iconValid( locale );
+ }
+ else
+ {
+ iconError( locale );
+ }
+ getSink().tableCell_();
- //Header
- generateTableHeader( true );
+ // tableCell( createLinkPatternedText( linkcheckFile.getRelativePath(), "./"
+ // + linkcheckFile.getRelativePath() ) );
+ getSink().tableCell();
+ getSink().link( linkcheckFile.getRelativePath() );
+ getSink().text( linkcheckFile.getRelativePath() );
+ getSink().link_();
+ getSink().tableCell_();
+ getSink().tableCell();
+ getSink().text( String.valueOf( linkcheckFile.getNumberOfLinks() ) );
+ getSink().tableCell_();
+ getSink().tableCell();
+ getSink().text( String.valueOf( linkcheckFile.getNumberOfLinks( LinkcheckFileResult.VALID_LEVEL ) ) );
+ getSink().tableCell_();
+ getSink().tableCell();
+ getSink().text( String.valueOf( linkcheckFile.getNumberOfLinks( LinkcheckFileResult.WARNING_LEVEL ) ) );
+ getSink().tableCell_();
+ getSink().tableCell();
+ getSink().text( String.valueOf( linkcheckFile.getNumberOfLinks( LinkcheckFileResult.ERROR_LEVEL ) ) );
+ getSink().tableCell_();
- // Content
- List linkcheckFiles = linkcheckModel.getFiles();
- for ( Iterator it = linkcheckFiles.iterator(); it.hasNext(); )
- {
- LinkcheckFile linkcheckFile = (LinkcheckFile) it.next();
+ getSink().tableRow_();
- sink.tableRow();
+ // Detail error
+ if ( linkcheckFile.getUnsuccessful() != 0 )
+ {
+ getSink().tableRow();
- sink.tableCell();
- if ( linkcheckFile.getUnsuccessful() == 0 )
- {
- iconValid();
- }
- else
- {
- iconError();
- }
- sink.tableCell_();
+ getSink().tableCell();
+ getSink().text( "" );
+ getSink().tableCell_();
- tableCell( createLinkPatternedText( linkcheckFile.getRelativePath(), "./"
- + linkcheckFile.getRelativePath() ) );
- tableCell( String.valueOf( linkcheckFile.getNumberOfLinks() ) );
- tableCell( String.valueOf( linkcheckFile.getNumberOfLinks( LinkcheckFileResult.VALID_LEVEL ) ) );
- tableCell( String.valueOf( linkcheckFile.getNumberOfLinks( LinkcheckFileResult.WARNING_LEVEL ) ) );
- tableCell( String.valueOf( linkcheckFile.getNumberOfLinks( LinkcheckFileResult.ERROR_LEVEL ) ) );
+ // TODO it is due to DOXIA-78
+ getSink().rawText( "<td colspan=\"5\">" );
- sink.tableRow_();
+ getSink().table();
- // Detail error
- if ( linkcheckFile.getUnsuccessful() != 0 )
+ for ( Iterator it2 = linkcheckFile.getResults().iterator(); it2.hasNext(); )
{
- sink.tableRow();
-
- sink.tableCell();
- sink.text( "" );
- sink.tableCell_();
+ LinkcheckFileResult linkcheckFileResult = (LinkcheckFileResult) it2.next();
- sink.tableCell( "5" );
+ if ( linkcheckFileResult.getStatusLevel() == LinkcheckFileResult.VALID_LEVEL )
+ {
+ continue;
+ }
- startTable();
+ getSink().tableRow();
- for ( Iterator it2 = linkcheckFile.getResults().iterator(); it2.hasNext(); )
+ getSink().tableCell();
+ if ( linkcheckFileResult.getStatusLevel() == LinkcheckFileResult.WARNING_LEVEL )
+ {
+ iconWarning( locale );
+ }
+ else if ( linkcheckFileResult.getStatusLevel() == LinkcheckFileResult.ERROR_LEVEL )
{
- LinkcheckFileResult linkcheckFileResult = (LinkcheckFileResult) it2.next();
+ iconError( locale );
+ }
+ getSink().tableCell_();
- if ( linkcheckFileResult.getStatusLevel() == LinkcheckFileResult.VALID_LEVEL )
- {
- continue;
- }
-
- sink.tableRow();
-
- sink.tableCell();
- if ( linkcheckFileResult.getStatusLevel() == LinkcheckFileResult.WARNING_LEVEL )
- {
- iconWarning();
- }
- else if ( linkcheckFileResult.getStatusLevel() == LinkcheckFileResult.ERROR_LEVEL )
- {
- iconError();
- }
- sink.tableCell_();
-
- sink.tableCell();
- sink.italic();
- sink.link( linkcheckFileResult.getTarget() );
- sink.text( linkcheckFileResult.getTarget() );
- sink.link_();
- sink.text( ": " );
- sink.text( linkcheckFileResult.getErrorMessage() );
- sink.italic_();
- sink.tableCell_();
+ getSink().tableCell();
+ getSink().italic();
+ getSink().link( linkcheckFileResult.getTarget() );
+ getSink().text( linkcheckFileResult.getTarget() );
+ getSink().link_();
+ getSink().text( ": " );
+ getSink().text( linkcheckFileResult.getErrorMessage() );
+ getSink().italic_();
+ getSink().tableCell_();
- sink.tableRow_();
- }
+ getSink().tableRow_();
+ }
- endTable();
+ getSink().table_();
- sink.tableCell_();
+ getSink().tableCell_();
- sink.tableRow_();
- }
+ getSink().tableRow_();
}
+ }
- sink.tableRow();
+ getSink().tableRow();
- endTable();
+ getSink().table_();
- endSection();
- }
+ getSink().section1_();
+ }
- private void generateTableHeader( boolean withImage )
+ private void generateTableHeader( Locale locale, boolean detail )
+ {
+ getSink().tableRow();
+ if ( detail )
{
- sink.tableRow();
- if ( withImage )
- {
- sink.rawText( "<th rowspan=\"2\">" );
- sink.text( "" );
- sink.tableHeaderCell_();
- }
- sink.rawText( "<th rowspan=\"2\">" );
- sink.text( i18n.getString( "linkcheck-report", locale, "report.linkcheck.table.documents" ) );
- sink.tableHeaderCell_();
- sink.tableHeaderCell( "4" );
- sink.text( i18n.getString( "linkcheck-report", locale, "report.linkcheck.table.links" ) );
- sink.tableHeaderCell_();
- sink.tableRow_();
-
- sink.tableRow();
- tableHeaderCell( i18n.getString( "linkcheck-report", locale, "report.linkcheck.table.totalLinks" ) );
- sink.tableHeaderCell();
- iconValid();
- sink.tableHeaderCell_();
- sink.tableHeaderCell();
- iconWarning();
- sink.tableHeaderCell_();
- sink.tableHeaderCell();
- iconError();
- sink.tableHeaderCell_();
- sink.tableRow_();
- }
-
- private void iconError()
- {
- sink.figure();
- sink.figureCaption();
- sink.text( i18n.getString( "linkcheck-report", locale, "report.linkcheck.icon.error" ) );
- sink.figureCaption_();
- sink.figureGraphics( "images/icon_error_sml.gif" );
- sink.figure_();
- }
-
- private void iconValid()
- {
- sink.figure();
- sink.figureCaption();
- sink.text( i18n.getString( "linkcheck-report", locale, "report.linkcheck.icon.valid" ) );
- sink.figureCaption_();
- sink.figureGraphics( "images/icon_success_sml.gif" );
- sink.figure_();
- }
-
- private void iconWarning()
- {
- sink.figure();
- sink.figureCaption();
- sink.text( i18n.getString( "linkcheck-report", locale, "report.linkcheck.icon.warning" ) );
- sink.figureCaption_();
- sink.figureGraphics( "images/icon_warning_sml.gif" );
- sink.figure_();
- }
+ getSink().rawText( "<th rowspan=\"2\">" );
+ getSink().text( "" );
+ getSink().tableHeaderCell_();
+ }
+ getSink().rawText( "<th rowspan=\"2\">" );
+ getSink().text( detail ? i18n.getString( "linkcheck-report", locale, "report.linkcheck.detail.table.documents" ) : i18n.getString( "linkcheck-report", locale, "report.linkcheck.table.summary.documents" ) );
+ getSink().tableHeaderCell_();
+ // TODO it is due to DOXIA-78
+ getSink().rawText( "<th colspan=\"4\" center>" );
+ getSink().text( i18n.getString( "linkcheck-report", locale, "report.linkcheck.table.links" ) );
+ getSink().tableHeaderCell_();
+ getSink().rawText( "</th>" );
+ getSink().tableRow_();
+
+ getSink().tableRow();
+ getSink().tableHeaderCell();
+ getSink().text( i18n.getString( "linkcheck-report", locale, "report.linkcheck.table.totalLinks" ) );
+ getSink().tableHeaderCell_();
+ getSink().tableHeaderCell();
+ iconValid( locale );
+ getSink().tableHeaderCell_();
+ getSink().tableHeaderCell();
+ iconWarning( locale );
+ getSink().tableHeaderCell_();
+ getSink().tableHeaderCell();
+ iconError( locale );
+ getSink().tableHeaderCell_();
+ getSink().tableRow_();
+ }
+
+ private void iconError( Locale locale )
+ {
+ getSink().figure();
+ getSink().figureCaption();
+ getSink().text( i18n.getString( "linkcheck-report", locale, "report.linkcheck.icon.error" ) );
+ getSink().figureCaption_();
+ getSink().figureGraphics( "images/icon_error_sml.gif" );
+ getSink().figure_();
+ }
+
+ private void iconValid( Locale locale )
+ {
+ getSink().figure();
+ getSink().figureCaption();
+ getSink().text( i18n.getString( "linkcheck-report", locale, "report.linkcheck.icon.valid" ) );
+ getSink().figureCaption_();
+ getSink().figureGraphics( "images/icon_success_sml.gif" );
+ getSink().figure_();
+ }
+
+ private void iconWarning( Locale locale )
+ {
+ getSink().figure();
+ getSink().figureCaption();
+ getSink().text( i18n.getString( "linkcheck-report", locale, "report.linkcheck.icon.warning" ) );
+ getSink().figureCaption_();
+ getSink().figureGraphics( "images/icon_warning_sml.gif" );
+ getSink().figure_();
}
}
Modified: maven/sandbox/trunk/plugins/maven-linkcheck-plugin/src/main/resources/linkcheck-report.properties
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-linkcheck-plugin/src/main/resources/linkcheck-report.properties?rev=616119&r1=616118&r2=616119&view=diff
==============================================================================
--- maven/sandbox/trunk/plugins/maven-linkcheck-plugin/src/main/resources/linkcheck-report.properties (original)
+++ maven/sandbox/trunk/plugins/maven-linkcheck-plugin/src/main/resources/linkcheck-report.properties Mon Jan 28 16:13:56 2008
@@ -22,14 +22,15 @@
report.linkcheck.overview=The Link Check tool will search the generated site, testing each link it finds. The report presents the status of each link tested.
report.linkcheck.summary=Summary
report.linkcheck.summary.overview=The following table presents the summary of all checked documents.
-report.linkcheck.table.documents=Documents
+report.linkcheck.table.summary.documents=Number Of Documents Analyzed
report.linkcheck.table.links=Links
report.linkcheck.table.totalLinks=Total
report.linkcheck.table.validLinks=Valid
report.linkcheck.table.errorLinks=Error
report.linkcheck.table.warningLinks=Warning
-report.linkcheck.detail=Detail
+report.linkcheck.detail=Details
report.linkcheck.detail.overview=The following table presents the detail of all checked documents.
+report.linkcheck.detail.table.documents=Documents Analyzed
report.linkcheck.icon.error=error
report.linkcheck.icon.valid=valid
-report.linkcheck.icon.warning=warning
\ No newline at end of file
+report.linkcheck.icon.warning=warning
Modified: maven/sandbox/trunk/plugins/maven-linkcheck-plugin/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-linkcheck-plugin/src/site/apt/index.apt?rev=616119&r1=616118&r2=616119&view=diff
==============================================================================
--- maven/sandbox/trunk/plugins/maven-linkcheck-plugin/src/site/apt/index.apt (original)
+++ maven/sandbox/trunk/plugins/maven-linkcheck-plugin/src/site/apt/index.apt Mon Jan 28 16:13:56 2008
@@ -3,7 +3,7 @@
------
Vincent Siveton
------
- 24 September 2007
+ January 2008
------
~~ Licensed to the Apache Software Foundation (ASF) under one
@@ -32,9 +32,11 @@
* Goals Overview
- The Linkcheck Plugin only has one goal.
+ The Linkcheck Plugin only has two goals.
* {{{./linkcheck-mojo.html}linkcheck:linkcheck}} Generates a Linkcheck report.
+
+ * {{{./clean-mojo.html}linkcheck:clean}} Delete Linkcheck files.
* Usage
Modified: maven/sandbox/trunk/plugins/maven-linkcheck-plugin/src/site/apt/usage.apt
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/plugins/maven-linkcheck-plugin/src/site/apt/usage.apt?rev=616119&r1=616118&r2=616119&view=diff
==============================================================================
--- maven/sandbox/trunk/plugins/maven-linkcheck-plugin/src/site/apt/usage.apt (original)
+++ maven/sandbox/trunk/plugins/maven-linkcheck-plugin/src/site/apt/usage.apt Mon Jan 28 16:13:56 2008
@@ -51,8 +51,11 @@
</project>
+-----
+ The Linkcheck plugin needs to call the <<<site>>> phase twice:
+
+-----
- mvn site
+ mvn site (to generate the site phase, i.e. the documentation)
+ mvn site (to analyze the result of the generated documentation)
+-----
Here is a simple report: