Added maven.linkcheck.exclude property

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@115892 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
carlos committed 2004-07-26 16:16:35 +00:00
1 parent a9eb636a3d
commit d840bf4c2a
10 files changed
+101 -15

No files matched your search

+1 -1
View File
@@ -84,7 +84,7 @@
<linkcheck:linkcheck
project="${pom}"
cache="${maven.linkcheck.cache}"
exclude="${pom.repository.url}"
exclude="${maven.linkcheck.exclude}"
basedir="${maven.docs.dest}"
output="${maven.build.dir}/linkcheck/linkcheck-results.xml"
outputEncoding="${maven.docs.outputencoding}"
+1
View File
@@ -19,3 +19,4 @@
# -------------------------------------------------------------------
maven.linkcheck.cache=${maven.build.dir}/linkcheck/linkcheck.cache
maven.linkcheck.failonerror=false
maven.linkcheck.exclude=${pom.repository.url}
+1 -1
View File
@@ -23,7 +23,7 @@
<pomVersion>3</pomVersion>
<id>maven-linkcheck-plugin</id>
<name>Maven LinkCheck Plug-in</name>
<currentVersion>1.3.2</currentVersion>
<currentVersion>1.4-SNAPSHOT</currentVersion>
<description>Check xdoc links. Requires Maven 1.0 RC2.</description>
<shortDescription>Check xdoc links</shortDescription>
<url>http://maven.apache.org/reference/plugins/linkcheck/</url>
@@ -25,6 +25,7 @@ import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.StringTokenizer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -40,7 +41,8 @@ import org.apache.maven.project.Project;
* their links checked.
*
* @author <a href="mailto:bwalding@apache.org">Ben Walding</a>
* @version $Id: LinkCheck.java,v 1.12 2004/03/02 15:09:17 evenisse Exp $
* @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
* @version $Id: LinkCheck.java,v 1.13 2004/07/26 16:16:35 carlos Exp $
*/
public class LinkCheck
{
@@ -228,7 +230,14 @@ public class LinkCheck
if (lvm == null)
{
lvm = new LinkValidatorManager();
lvm.setExclude(exclude);
if (exclude != null) {
StringTokenizer st = new StringTokenizer(exclude, " ,\t\n\r\f");
String[] tokens = new String[st.countTokens()];
for (int i = 0; i < tokens.length; i++) {
tokens[i] = st.nextToken();
}
lvm.setExcludes(tokens);
}
lvm.addLinkValidator(new FileLinkValidator());
MavenJellyContext ctx;
if (getProject() == null) {
@@ -274,8 +283,12 @@ public class LinkCheck
}
/**
* Sets the exclude.
* @param exclude The exclude to set
* Sets the exclude, a string with exclude locations delimited by the space
* character, the comma character, the tab character, the newline character,
* the carriage-return character, and the form-feed character.
*
* @param exclude
* The exclude to set
*/
public void setExclude(String exclude)
{
@@ -30,7 +30,8 @@ import org.apache.commons.logging.LogFactory;
/**
* @author <a href="mailto:bwalding@apache.org">Ben Walding</a>
* @version $Id: LinkValidatorManager.java,v 1.5 2004/03/02 15:09:17 evenisse Exp $
* @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
* @version $Id: LinkValidatorManager.java,v 1.6 2004/07/26 16:16:34 carlos Exp $
*/
public class LinkValidatorManager {
@@ -41,7 +42,7 @@ public class LinkValidatorManager {
private List validators = new ArrayList();
private LinkValidatorCache cache = new LinkValidatorCache(this);
private String exclude;
private String[] excludes = new String[0];
public LinkValidatorManager() {
@@ -64,8 +65,13 @@ public class LinkValidatorManager {
}
}
if (exclude != null && lvi.getLink().startsWith(exclude)) {
return new LinkValidationResult(LinkValidationResult.VALID, false);
for (int i = 0; i < excludes.length; i++) {
if (excludes[i] != null && lvi.getLink().startsWith(excludes[i])) {
if (LOG.isDebugEnabled()) {
LOG.debug("Excluded " + lvi.getLink());
}
return new LinkValidationResult(LinkValidationResult.VALID, false);
}
}
Iterator iter = validators.iterator();
@@ -120,17 +126,35 @@ public class LinkValidatorManager {
/**
* Returns the exclude.
* @return String
* @deprecated use getExcludes()
*/
public String getExclude() {
return exclude;
return excludes[0];
}
/**
* Sets the exclude.
* @param exclude The exclude to set
* @deprecated use setExcludes()
*/
public void setExclude(String exclude) {
this.exclude = exclude;
this.excludes = new String[] {exclude};
}
/**
* Returns the excludes.
* @return String[]
*/
public String[] getExcludes() {
return excludes;
}
/**
* Sets the excludes.
* @param excludes The excludes to set
*/
public void setExcludes(String[] excludes) {
this.excludes = excludes;
}
}
@@ -0,0 +1,26 @@
<!--
/*
* 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.
*/
-->
<html>
<body>
<a href="http://cvs.apache.org/viewcvs.cgi/maven-pluginszz/">this will be excluded</a>
<a href="http://cvs.apache.org/viewcvs.cgi/mavenzz/">this will be excluded</a>
</body>
</html>
@@ -28,7 +28,7 @@ import junit.framework.TestCase;
/**
* @author Ben Walding
*
* @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
*/
public class LinkCheckTest extends TestCase
{
@@ -47,6 +47,8 @@ public class LinkCheckTest extends TestCase
lc.setOutput(new File(baseDir + "/target/linkcheck.xml"));
lc.setOutputEncoding("ISO8859-1");
lc.setCache(baseDir + "/target/linkcheck-cache.xml");
lc.setExclude("http://cvs.apache.org/viewcvs.cgi/maven-pluginszz/,"
+ "http://cvs.apache.org/viewcvs.cgi/mavenzz/");
lc.doExecute();
Iterator iter = lc.getFiles().iterator();
@@ -57,7 +59,7 @@ public class LinkCheckTest extends TestCase
map.put(ftc.getName(), ftc);
}
assertEquals("files.size()", 7, lc.getFiles().size());
assertEquals("files.size()", 8, lc.getFiles().size());
check(map, "nolink.html", 0);
check(map, "test-resources/nolink.html", 0);
@@ -65,6 +67,13 @@ public class LinkCheckTest extends TestCase
check(map, "test-resources/test1/test2.html", 0);
check(map, "test1/test1.html", 1);
check(map, "testA.html", 3);
/* test excludes */
String fileName = "testExcludes.html";
check(map, fileName, 2);
FileToCheck ftc = (FileToCheck) map.get(fileName);
assertEquals("Excluded links", 2, ftc.getSuccessful());
//index-all.html should get parsed, but is currently having problems.
//check(map, "index-all.html", 1);
+3
View File
@@ -25,6 +25,9 @@
<author email="vmassol@apache.org">Vincent Massol</author>
</properties>
<body>
<release version="1.4-SNAPSHOT" date="in CVS">
<action dev="carlos" type="add">Added <code>maven.linkcheck.exclude</code> property</action>
</release>
<release version="1.3.2" date="2004-07-10">
<action dev="brett" type="update" issue="MPLINKCHECK-14">Only log exception in debug mode on connection refused</action>
<action dev="brett" type="update">Update commons-*</action>
+2 -1
View File
@@ -26,7 +26,8 @@
<body>
<section name="Maven LinkCheck Plug-in">
<p>
This plug-in validates the HTML that is produced as part of the site
This plug-in validates the HTML that is produced as part of the site.
Just add the maven-linkcheck-plugin report to your project.
</p>
</section>
+9
View File
@@ -50,6 +50,15 @@
Defaults to <code>false</code>.
</td>
</tr>
<tr>
<td>maven.linkcheck.exclude</td>
<td>Yes</td>
<td>
List of urls to exclude from check, delimited by comma, space or tab.
Those urls in files that start with one of the excluded urls will be ignored.
Defaults to <code>pom.repository.url</code>.
</td>
</tr>
</table>
</section>
</body>