| <?xml version="1.0" encoding="UTF-8"?> |
| |
| <!-- |
| 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. |
| --> |
| |
| <document xmlns="http://maven.apache.org/XDOC/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/XDOC/2.0 http://maven.apache.org/xsd/xdoc-2.0.xsd"> |
| <properties> |
| <title>Usage</title> |
| <author email="ltheussl@apache.org">Lukas Theussl</author> |
| </properties> |
| |
| <body> |
| <section name="Usage"> |
| <p> |
| Here's a simple Java example: |
| </p> |
| |
| <source> |
| LinkCheck lc = new DefaultLinkCheck(); |
| /* |
| * If you are using Plexus: |
| * LinkCheck lc = (LinkCheck) lookup( LinkCheck.ROLE ); |
| */ |
| |
| lc.setOnline( true ); |
| |
| lc.setBasedir( new File( "target/site/" ) ); |
| |
| lc.setReportOutput( new File( "target/linkcheck/linkcheck.xml" ) ); |
| |
| lc.setLinkCheckCache( new File( "target/linkcheck/linkcheck.cache" ) ); |
| |
| String[] excludes = new String[] |
| { |
| "http://cvs.apache.org/viewcvs.cgi/maven-pluginszz/", |
| "http://cvs.apache.org/viewcvs.cgi/mavenzz/" |
| }; |
| lc.setExcludedLinks( excludes ); |
| |
| LinkcheckModel result = lc.execute(); |
| </source> |
| |
| <p> |
| This traverses all html files found under <code>target/site/</code> |
| and writes the validation result into <code>target/linkcheck/linkcheck.xml</code>. |
| </p> |
| |
| <subsection name="Format of linkcheck.xml"> |
| <p> |
| The created <code>linkcheck.xml</code> file has the following format: |
| </p> |
| |
| <source><![CDATA[ |
| <?xml version="1.0" encoding="UTF-8" ?> |
| <linkcheck> |
| <file> |
| <absolutePath>C:\apache.org\maven\src\target\site\nolink.html</absolutePath> |
| <relativePath>nolink.html</relativePath> |
| <successful>0</successful> |
| <unsuccessful>0</unsuccessful> |
| </file> |
| <file> |
| <absolutePath>C:\apache.org\maven\src\target\site\nolink.html</absolutePath> |
| <relativePath>testA.html</relativePath> |
| <successful>1</successful> |
| <unsuccessful>2</unsuccessful> |
| <results> |
| <result> |
| <target>#bumpkin</target> |
| <status>valid</status> |
| <errorMessage></errorMessage> |
| </result> |
| <result> |
| <target>style.css</target> |
| <status>error</status> |
| <errorMessage>doesn't exist.</errorMessage> |
| </result> |
| <result> |
| <target>testnothere.html</target> |
| <status>error</status> |
| <errorMessage>doesn't exist.</errorMessage> |
| </result> |
| </results> |
| </file> |
| </linkcheck> |
| ]]> |
| </source> |
| </subsection> |
| </section> |
| </body> |
| </document> |