You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ah...@apache.org on 2006/02/04 01:59:39 UTC
svn commit: r374800 - in /maven/maven-1/plugins/trunk/linkcheck: ./
src/main/org/apache/maven/plugin/linkcheck/
src/main/org/apache/maven/plugin/linkcheck/validation/
src/test/org/apache/maven/plugin/linkcheck/validation/ xdocs/
Author: aheritier
Date: Fri Feb 3 16:59:13 2006
New Revision: 374800
URL: http://svn.apache.org/viewcvs?rev=374800&view=rev
Log:
Add the property "maven.linkcheck.method" to select the method to use to do the tests (head -by default-,or get).
Modified:
maven/maven-1/plugins/trunk/linkcheck/plugin.jelly
maven/maven-1/plugins/trunk/linkcheck/plugin.properties
maven/maven-1/plugins/trunk/linkcheck/project.properties
maven/maven-1/plugins/trunk/linkcheck/src/main/org/apache/maven/plugin/linkcheck/LinkCheck.java
maven/maven-1/plugins/trunk/linkcheck/src/main/org/apache/maven/plugin/linkcheck/validation/OnlineHTTPLinkValidator.java
maven/maven-1/plugins/trunk/linkcheck/src/test/org/apache/maven/plugin/linkcheck/validation/HTTPLinkValidatorTest.java
maven/maven-1/plugins/trunk/linkcheck/xdocs/changes.xml
maven/maven-1/plugins/trunk/linkcheck/xdocs/properties.xml
Modified: maven/maven-1/plugins/trunk/linkcheck/plugin.jelly
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/linkcheck/plugin.jelly?rev=374800&r1=374799&r2=374800&view=diff
==============================================================================
--- maven/maven-1/plugins/trunk/linkcheck/plugin.jelly (original)
+++ maven/maven-1/plugins/trunk/linkcheck/plugin.jelly Fri Feb 3 16:59:13 2006
@@ -89,6 +89,7 @@
basedir="${maven.docs.dest}"
output="${maven.build.dir}/linkcheck/linkcheck-results.xml"
outputEncoding="${maven.docs.outputencoding}"
+ method="${maven.linkcheck.method}"
/>
<!-- Do we want an error to be generated if there are link errors? -->
Modified: maven/maven-1/plugins/trunk/linkcheck/plugin.properties
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/linkcheck/plugin.properties?rev=374800&r1=374799&r2=374800&view=diff
==============================================================================
--- maven/maven-1/plugins/trunk/linkcheck/plugin.properties (original)
+++ maven/maven-1/plugins/trunk/linkcheck/plugin.properties Fri Feb 3 16:59:13 2006
@@ -26,3 +26,4 @@
maven.linkcheck.proxy.password=${maven.proxy.password}
maven.linkcheck.proxy.ntlm.host=${maven.proxy.ntlm.host}
maven.linkcheck.proxy.ntlm.domain=${maven.proxy.ntlm.domain}
+maven.linkcheck.method=head
Modified: maven/maven-1/plugins/trunk/linkcheck/project.properties
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/linkcheck/project.properties?rev=374800&r1=374799&r2=374800&view=diff
==============================================================================
--- maven/maven-1/plugins/trunk/linkcheck/project.properties (original)
+++ maven/maven-1/plugins/trunk/linkcheck/project.properties Fri Feb 3 16:59:13 2006
@@ -20,6 +20,7 @@
maven.junit.fork=yes
# Properties required for the unit tests
maven.junit.sysproperties = \
+ maven.linkcheck.method \
maven.linkcheck.proxy.host \
maven.linkcheck.proxy.port \
maven.linkcheck.proxy.username \
Modified: maven/maven-1/plugins/trunk/linkcheck/src/main/org/apache/maven/plugin/linkcheck/LinkCheck.java
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/linkcheck/src/main/org/apache/maven/plugin/linkcheck/LinkCheck.java?rev=374800&r1=374799&r2=374800&view=diff
==============================================================================
--- maven/maven-1/plugins/trunk/linkcheck/src/main/org/apache/maven/plugin/linkcheck/LinkCheck.java (original)
+++ maven/maven-1/plugins/trunk/linkcheck/src/main/org/apache/maven/plugin/linkcheck/LinkCheck.java Fri Feb 3 16:59:13 2006
@@ -76,6 +76,8 @@
private String exclude;
+ private String method;
+
private List filesToCheck = null;
private LinkValidatorManager lvm = null;
@@ -151,6 +153,22 @@
this.exclude = exclude;
}
+ /**
+ * @return the method
+ */
+ public String getMethod()
+ {
+ return method;
+ }
+
+ /**
+ * @param method the method to set
+ */
+ public void setMethod( String method )
+ {
+ this.method = method;
+ }
+
public List getFiles()
{
return filesToCheck;
@@ -182,6 +200,7 @@
{
lvm
.addLinkValidator( new OnlineHTTPLinkValidator(
+ getMethod(),
(String) ctx.getVariable( MAVEN_PROXY_HOST ),
(String) ctx.getVariable( MAVEN_PROXY_PORT ),
(String) ctx.getVariable( MAVEN_PROXY_USERNAME ),
Modified: maven/maven-1/plugins/trunk/linkcheck/src/main/org/apache/maven/plugin/linkcheck/validation/OnlineHTTPLinkValidator.java
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/linkcheck/src/main/org/apache/maven/plugin/linkcheck/validation/OnlineHTTPLinkValidator.java?rev=374800&r1=374799&r2=374800&view=diff
==============================================================================
--- maven/maven-1/plugins/trunk/linkcheck/src/main/org/apache/maven/plugin/linkcheck/validation/OnlineHTTPLinkValidator.java (original)
+++ maven/maven-1/plugins/trunk/linkcheck/src/main/org/apache/maven/plugin/linkcheck/validation/OnlineHTTPLinkValidator.java Fri Feb 3 16:59:13 2006
@@ -18,6 +18,7 @@
import org.apache.commons.httpclient.NTCredentials;
import org.apache.commons.httpclient.StatusLine;
import org.apache.commons.httpclient.UsernamePasswordCredentials;
+import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.HeadMethod;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -39,6 +40,12 @@
/** The maximum number of redirections for a link */
private final static int MAX_NB_REDIRECT = 10;
+ /** Use the get method to test pages. */
+ private final static String GET_METHOD = "GET";
+
+ /** Use the head method to test pages. */
+ private final static String HEAD_METHOD = "HEAD";
+
private String proxyHost;
private int proxyPort;
@@ -51,11 +58,16 @@
private String proxyNtlmDomain;
+ private String method = HEAD_METHOD;
+
private transient HttpClient cl;
- public OnlineHTTPLinkValidator( String proxyHost, String proxyPort, String proxyUser, String proxyPass,
- String proxyNtlmHost, String proxyNtlmDomain )
+ public OnlineHTTPLinkValidator( String method, String proxyHost, String proxyPort, String proxyUser,
+ String proxyPass, String proxyNtlmHost, String proxyNtlmDomain )
{
+ if ( LOG.isDebugEnabled() )
+ LOG.debug( "Will use method : [" + method + "]" );
+ this.method = method;
if ( proxyHost == null || proxyHost.trim().equals( "" ) )
{
this.proxyHost = null;
@@ -203,8 +215,11 @@
{
throw new HttpException( "Maximum number of redirections (" + MAX_NB_REDIRECT + ") exceeded" );
}
- // execute the HEAD (a GET without the body returned)
- HttpMethod hm = new HeadMethod( link );
+ HttpMethod hm;
+ if ( HEAD_METHOD.equals( method ) )
+ hm = new HeadMethod( link );
+ else
+ hm = new GetMethod( link );
try
{
// We want to do it manually
Modified: maven/maven-1/plugins/trunk/linkcheck/src/test/org/apache/maven/plugin/linkcheck/validation/HTTPLinkValidatorTest.java
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/linkcheck/src/test/org/apache/maven/plugin/linkcheck/validation/HTTPLinkValidatorTest.java?rev=374800&r1=374799&r2=374800&view=diff
==============================================================================
--- maven/maven-1/plugins/trunk/linkcheck/src/test/org/apache/maven/plugin/linkcheck/validation/HTTPLinkValidatorTest.java (original)
+++ maven/maven-1/plugins/trunk/linkcheck/src/test/org/apache/maven/plugin/linkcheck/validation/HTTPLinkValidatorTest.java Fri Feb 3 16:59:13 2006
@@ -39,7 +39,7 @@
System.err.println( "maven.mode.online : " + mavenOnline );
if ( mavenOnline )
{
- hlv = new OnlineHTTPLinkValidator( System.getProperty( "maven.linkcheck.proxy.host" ), System
+ hlv = new OnlineHTTPLinkValidator( System.getProperty( "maven.linkcheck.method" ), System.getProperty( "maven.linkcheck.proxy.host" ), System
.getProperty( "maven.linkcheck.proxy.port" ), System.getProperty( "maven.linkcheck.proxy.username" ),
System.getProperty( "maven.linkcheck.proxy.password" ), System
.getProperty( "maven.linkcheck.proxy.ntlm.host" ), System
Modified: maven/maven-1/plugins/trunk/linkcheck/xdocs/changes.xml
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/linkcheck/xdocs/changes.xml?rev=374800&r1=374799&r2=374800&view=diff
==============================================================================
--- maven/maven-1/plugins/trunk/linkcheck/xdocs/changes.xml (original)
+++ maven/maven-1/plugins/trunk/linkcheck/xdocs/changes.xml Fri Feb 3 16:59:13 2006
@@ -25,6 +25,7 @@
</properties>
<body>
<release version="1.4-SNAPSHOT" date="in SVN">
+ <action dev="aheritier" type="add">Add the property "maven.linkcheck.method" to select the method to use to do the tests (head -by default-,or get).</action>
<action dev="aheritier" type="add" issue="MPLINKCHECK-25">Display for each file the number of links and the number of errors.</action>
<action dev="aheritier" type="add" issue="MPLINKCHECK-25">New counters to report how many files and links are checked and how many errors are found.</action>
<action dev="aheritier" type="update" issue="MPLINKCHECK-25">Display a more verbose message than the "NOT FOUND" error.</action>
Modified: maven/maven-1/plugins/trunk/linkcheck/xdocs/properties.xml
URL: http://svn.apache.org/viewcvs/maven/maven-1/plugins/trunk/linkcheck/xdocs/properties.xml?rev=374800&r1=374799&r2=374800&view=diff
==============================================================================
--- maven/maven-1/plugins/trunk/linkcheck/xdocs/properties.xml (original)
+++ maven/maven-1/plugins/trunk/linkcheck/xdocs/properties.xml Fri Feb 3 16:59:13 2006
@@ -109,6 +109,15 @@
Defaults to <code>maven.proxy.ntlm.domain</code>.
</td>
</tr>
+ <tr>
+ <td>maven.linkcheck.method</td>
+ <td>Yes</td>
+ <td>
+ The method to use to test pages. The value should be 'head' or 'get'.
+ In some cases (particularly with some proxies) the head method doesn't work witl all servers.
+ The get method is slower but safe. Defaults to <code>head</code>.
+ </td>
+ </tr>
</table>
</section>
</body>