Add the property "maven.linkcheck.method" to select the method to use to do the tests (head -by default-,or get).
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@374800 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -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? -->
|
||||
|
||||
@@ -26,3 +26,4 @@ maven.linkcheck.proxy.username=${maven.proxy.username}
|
||||
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
|
||||
|
||||
@@ -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 \
|
||||
|
||||
@@ -76,6 +76,8 @@ public final class LinkCheck
|
||||
|
||||
private String exclude;
|
||||
|
||||
private String method;
|
||||
|
||||
private List filesToCheck = null;
|
||||
|
||||
private LinkValidatorManager lvm = null;
|
||||
@@ -151,6 +153,22 @@ public final class LinkCheck
|
||||
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 @@ public final class LinkCheck
|
||||
{
|
||||
lvm
|
||||
.addLinkValidator( new OnlineHTTPLinkValidator(
|
||||
getMethod(),
|
||||
(String) ctx.getVariable( MAVEN_PROXY_HOST ),
|
||||
(String) ctx.getVariable( MAVEN_PROXY_PORT ),
|
||||
(String) ctx.getVariable( MAVEN_PROXY_USERNAME ),
|
||||
|
||||
@@ -18,6 +18,7 @@ import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
|
||||
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 @@ public final class OnlineHTTPLinkValidator
|
||||
/** 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 @@ public final class OnlineHTTPLinkValidator
|
||||
|
||||
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 @@ public final class OnlineHTTPLinkValidator
|
||||
{
|
||||
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
|
||||
|
||||
@@ -39,7 +39,7 @@ public class HTTPLinkValidatorTest
|
||||
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
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user