Here's a simple Java example:
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();
This traverses all html files found under target/site/
and writes the validation result into target/linkcheck/linkcheck.xml
.
The created linkcheck.xml
file has the following format:
<?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>