| /* |
| * 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. |
| */ |
| |
| import java.io.*; |
| import java.util.*; |
| import java.util.regex.*; |
| |
| import org.apache.maven.tools.plugin.javadoc.*; |
| |
| import org.codehaus.plexus.util.*; |
| |
| setAccessibility( true ); |
| |
| File docsDir = new File( basedir, "target/site/apidocs" ); |
| System.out.println( "Checking for existence of: " + docsDir ); |
| if ( !docsDir.exists() ) |
| { |
| throw new FileNotFoundException( docsDir + " was not created" ); |
| } |
| |
| File docFile = new File( docsDir, "org/apache/maven/plugin/my/MyMojo.html" ); |
| System.out.println( "Checking for existence of: " + docFile ); |
| if ( !docFile.isFile() ) |
| { |
| throw new FileNotFoundException( docFile + " was not created" ); |
| } |
| |
| String html = FileUtils.fileRead( docFile, "ISO-8859-1").replaceAll( "(\r\n)|(\r)|(\n)", "" ); |
| |
| System.out.println( "Checking for documentation of mojo type" ); |
| String mojoType = "<dl><dt><b>" + MojoAggregatorTypeTaglet.HEADER + "</b></dt><dd></dd><dt><b>" |
| + MojoConfiguratorTypeTaglet.HEADER + ":</b></dt><dd>roleHint</dd><dt><b>" + MojoExecuteTypeTaglet.HEADER |
| + ":</b></dt><dd><dl><dt><b>phase:</b></dt><dd>validate</dd>" |
| + "<dt><b>lifecycle:</b></dt><dd>default</dd></dl></dd><dt><b>" + MojoExecutionStrategyTypeTaglet.HEADER |
| + ":</b></dt><dd>always</dd>" + "<dt><b>" + MojoGoalTypeTaglet.HEADER + ":</b></dt><dd>touch</dd>" |
| + "<dt><b>" + MojoInheritByDefaultTypeTaglet.HEADER + ":</b></dt><dd>true</dd><dt><b>" |
| + MojoInstantiationStrategyTypeTaglet.HEADER + ":</b></dt><dd>per-lookup</dd><dt><b>" |
| + MojoPhaseTypeTaglet.HEADER + ":</b></dt><dd>phaseName</dd><dt><b>" |
| + MojoRequiresDependencyResolutionTypeTaglet.HEADER + ":</b></dt><dd>compile</dd><dt><b>" |
| + MojoRequiresDirectInvocationTypeTaglet.HEADER + ":</b></dt><dd>false</dd><dt><b>" |
| + MojoRequiresOnLineTypeTaglet.HEADER + ":</b></dt><dd>true</dd><dt><b>" |
| + MojoRequiresProjectTypeTaglet.HEADER + ":</b></dt><dd>true</dd><dt><b>" |
| + MojoRequiresReportsTypeTaglet.HEADER + ":</b></dt><dd>false</dd></dl>"; |
| if ( html.toLowerCase( Locale.ENGLISH ).indexOf( ( mojoType ).toLowerCase( Locale.ENGLISH ) ) < 0 ) |
| { |
| throw new IllegalStateException( "Mojo type doc wrong" ); |
| } |
| |
| System.out.println( "Checking for documentation of mojo fields" ); |
| // order has changed between JDK7 and JDK8 |
| String mojoField = Pattern.quote("<dl><dt><b>" + MojoParameterFieldTaglet.HEADER + ":</b></dt><dd><dl>" ) |
| + "(" + Pattern.quote( "<dt><b>expression:</b></dt><dd>${project.build.directory}</dd>" ) |
| + "|" + Pattern.quote( "<dt><b>default-value:</b></dt><dd>value</dd>" ) |
| + "|" + Pattern.quote( "<dt><b>alias:</b></dt><dd>myAlias</dd>" ) |
| + "){3}" + Pattern.quote("</dl></dd><dt><b>" + MojoReadOnlyFieldTaglet.HEADER + "</b></dt><dd>" ) |
| + Pattern.quote( "</dd><dt><b>" + MojoRequiredFieldTaglet.HEADER + "</b></dt><dd></dd></dl>"); |
| if ( !Pattern.compile( mojoField, Pattern.CASE_INSENSITIVE ).matcher( html ).find() ) |
| { |
| System.out.println( mojoField ); |
| throw new IllegalStateException( "Mojo field doc wrong!!!" ); |
| } |
| |
| mojoField = "<dl><dt><b>" + MojoComponentFieldTaglet.HEADER + ":</b></dt><dd><dl><dt><b>role:</b>" |
| + "</dt><dd>org.apacha.maven.MyComponent</dd><dt><b>roleHint:</b></dt><dd>default</dd></dl></dd>" |
| + "<dt><b>" + MojoReadOnlyFieldTaglet.HEADER + "</b></dt><dd></dd><dt><b>" + MojoRequiredFieldTaglet.HEADER |
| + "</b></dt><dd>" + "</dd></dl>"; |
| if ( html.toLowerCase( Locale.ENGLISH ).indexOf( ( mojoField ).toLowerCase( Locale.ENGLISH ) ) < 0 ) |
| { |
| throw new IllegalStateException( "Mojo field doc wrong" ); |
| } |
| |
| return true; |