diff --git a/linkcheck/plugin.jelly b/linkcheck/plugin.jelly index add250ca..2e8c5734 100644 --- a/linkcheck/plugin.jelly +++ b/linkcheck/plugin.jelly @@ -23,28 +23,35 @@ xmlns:define="jelly:define" xmlns:linkcheck="linkcheck" xmlns:maven="jelly:maven" + xmlns:ant="jelly:ant" xmlns:x="jelly:xml" xmlns:util="jelly:util" + xmlns:log="jelly:log" xmlns:doc="doc"> + org.apache.maven.plugin.linkcheck.Jelly + + LinkCheck report registred. + LinkCheck report unregistred. + LinkCheck taglib defined. @@ -56,28 +63,22 @@ --> - + + Fake LinkCheck report copied. + + + ${maven.mode.online} + + + + - - - - ${maven.mode.online} - - - - - - - - - - - + Begin to generate the linkcheck report. @@ -108,15 +109,21 @@ outputMode="xml" prettyPrint="true" /> - + + + + + + + + Cache cleared. - diff --git a/linkcheck/plugin.properties b/linkcheck/plugin.properties index 1b53180e..dcb6dfa9 100644 --- a/linkcheck/plugin.properties +++ b/linkcheck/plugin.properties @@ -20,3 +20,4 @@ maven.linkcheck.cache=${maven.build.dir}/linkcheck/linkcheck.cache maven.linkcheck.failonerror=false maven.linkcheck.exclude=${pom.repository.url} +maven.linkcheck.timeout=30000 diff --git a/linkcheck/project.properties b/linkcheck/project.properties index 4833d7d2..5bd71751 100644 --- a/linkcheck/project.properties +++ b/linkcheck/project.properties @@ -18,6 +18,15 @@ # P R O J E C T P R O P E R T I E S # ------------------------------------------------------------------- maven.junit.fork=yes +# Properties required for the unit tests +maven.junit.sysproperties = \ + maven.proxy.host \ + maven.proxy.port \ + maven.proxy.username \ + maven.proxy.password \ + maven.mode.online maven.jar.override = on maven.jar.maven = ${maven.home}/lib/maven.jar + +log4j.logger.org.apache.maven.plugin.linkcheck=INFO \ No newline at end of file diff --git a/linkcheck/project.xml b/linkcheck/project.xml index c47530b3..18ae664d 100644 --- a/linkcheck/project.xml +++ b/linkcheck/project.xml @@ -1,5 +1,4 @@ - - - + ../plugin-parent/project.xml 3 maven-linkcheck-plugin @@ -77,6 +74,15 @@ Java Developer + + Arnaud Heritier + aheritier + aheritier@apache.org + Octo Technology + + Java Developer + + Carlos Sanchez carlos @@ -111,7 +117,16 @@ commons-httpclient commons-httpclient - 2.0.2 + 3.0 + + This library is already loaded by maven's core. Be careful to use the same version number as in the core. + + + + commons-codec + commons-codec + 1.2 + http://jakarta.apache.org/commons/codec/ This library is already loaded by maven's core. Be careful to use the same version number as in the core. @@ -137,6 +152,11 @@ commons-jelly-tags-jsl 1.0 + + commons-jelly + commons-jelly-tags-log + 1.0 + commons-jelly commons-jelly-tags-xml diff --git a/linkcheck/src/main/org/apache/maven/linkcheck/FileToCheck.java b/linkcheck/src/main/org/apache/maven/linkcheck/FileToCheck.java deleted file mode 100644 index dd95dc04..00000000 --- a/linkcheck/src/main/org/apache/maven/linkcheck/FileToCheck.java +++ /dev/null @@ -1,317 +0,0 @@ -package org.apache.maven.linkcheck; - -/* ==================================================================== - * Copyright 2001-2004 The Apache Software Foundation. - * - * Licensed 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.BufferedInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.PrintWriter; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; -import java.util.TreeSet; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.maven.linkcheck.validation.LinkValidationItem; -import org.apache.maven.linkcheck.validation.LinkValidationResult; -import org.apache.maven.linkcheck.validation.LinkValidatorManager; -import org.dom4j.Document; -import org.dom4j.Node; -import org.dom4j.io.DOMReader; -import org.w3c.tidy.Tidy; - -/** - * @author Ben Walding - * @version $Id$ - */ -public class FileToCheck -{ - /** - * Log for debug output - */ - private static Log LOG = LogFactory.getLog(FileToCheck.class); - - private String base; - private File fileToCheck; - private String status = STATUS_OK; - private String message = ""; - private int successful; - private int unsuccessful; - private List links = new LinkedList(); - - public static final String STATUS_UNKNOWN = null; - public static final String STATUS_JTIDY_FAILURE = "Unable to tidy source"; - public static final String STATUS_OK = "OK"; - - public FileToCheck(File baseFile, File fileToCheck) - { - this.base = baseFile.getAbsolutePath(); - this.fileToCheck = fileToCheck; - - } - - private void addResult(LinkCheckResult lcr) - { - this.links.add(lcr); - } - - public void check(LinkValidatorManager lvm) throws Exception - { - successful = 0; - unsuccessful = 0; - status = STATUS_OK; - message = ""; - - try - { - final Set hrefs; - try - { - hrefs = getLinks(); - } - catch (Throwable e) - { - //We catch Throwable, because there is a chance that the domReader will throw - //a stack overflow exception for some files - LOG.info("Caught " + e.toString() + " processing " + getName()); - LOG.info("Exception Message: " + e.getLocalizedMessage()); - LinkCheckResult lcr = new LinkCheckResult(); - lcr.setStatus("PARSE FAILURE"); - lcr.setTarget("N/A"); - addResult(lcr); - return; - } - - for (Iterator iter = hrefs.iterator(); iter.hasNext(); ) - { - String href = (String) iter.next(); - - LOG.debug("Link Found: " + href); - - LinkCheckResult lcr = new LinkCheckResult(); - - LinkValidationItem lvi = new LinkValidationItem(fileToCheck, href); - LinkValidationResult result = lvm.validateLink(lvi); - lcr.setTarget(href); - - switch (result.getStatus()) - { - case LinkValidationResult.VALID : - successful++; - lcr.setStatus("OK"); - addResult(lcr); //At some point we won't want to store valid links. The tests require that we do at present - break; - case LinkValidationResult.UNKNOWN : - unsuccessful++; - lcr.setStatus("UNKNOWN REF"); - addResult(lcr); - break; - case LinkValidationResult.INVALID : - unsuccessful++; - lcr.setStatus("NOT FOUND"); - addResult(lcr); - break; - } - - } - } - catch (Exception e) - { - System.err.println(message); - throw (e); - } - } - - private Set getLinks() throws FileNotFoundException - { - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - PrintWriter errOut = new PrintWriter(baos); - BufferedInputStream bin = new BufferedInputStream(new FileInputStream(fileToCheck)); - try - { - Tidy tidy = getTidy(); - tidy.setErrout(errOut); - LOG.debug("Processing:" + fileToCheck); - org.w3c.dom.Document domDocument = tidy.parseDOM(bin, null); - - // now read a dom4j document from - // JTidy's W3C DOM object - final DOMReader domReader = new DOMReader(); - final Document doc = domReader.read(domDocument); - - LOG.debug(baos.toString()); - - return findUniqueLinks(doc); - } - finally - { - close(bin); - close(baos); - } - } - - private void close(InputStream is) - { - try - { - is.close(); - } - catch (Exception e) - { - //Don't really care. - } - } - - private void close(OutputStream os) - { - try - { - os.close(); - } - catch (Exception e) - { - //Don't really care. - } - } - - private Set findUniqueLinks(Document doc) - { - List xpathResults = new LinkedList(); - - xpathResults.addAll(doc.selectNodes("//a/@href")); - xpathResults.addAll(doc.selectNodes("//img/@src")); - - // - xpathResults.addAll(doc.selectNodes("//link/@href")); - - //