/* * 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 = "
" + MojoAggregatorTypeTaglet.HEADER + "
" + MojoConfiguratorTypeTaglet.HEADER + ":
roleHint
" + MojoExecuteTypeTaglet.HEADER + ":
phase:
validate
" + "
lifecycle:
default
" + MojoExecutionStrategyTypeTaglet.HEADER + ":
always
" + "
" + MojoGoalTypeTaglet.HEADER + ":
touch
" + "
" + MojoInheritByDefaultTypeTaglet.HEADER + ":
true
" + MojoInstantiationStrategyTypeTaglet.HEADER + ":
per-lookup
" + MojoPhaseTypeTaglet.HEADER + ":
phaseName
" + MojoRequiresDependencyResolutionTypeTaglet.HEADER + ":
compile
" + MojoRequiresDirectInvocationTypeTaglet.HEADER + ":
false
" + MojoRequiresOnLineTypeTaglet.HEADER + ":
true
" + MojoRequiresProjectTypeTaglet.HEADER + ":
true
" + MojoRequiresReportsTypeTaglet.HEADER + ":
false
"; 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("
" + MojoParameterFieldTaglet.HEADER + ":
" ) + "(" + Pattern.quote( "
expression:
${project.build.directory}
" ) + "|" + Pattern.quote( "
default-value:
value
" ) + "|" + Pattern.quote( "
alias:
myAlias
" ) + "){3}" + Pattern.quote("
" + MojoReadOnlyFieldTaglet.HEADER + "
" ) + Pattern.quote( "
" + MojoRequiredFieldTaglet.HEADER + "
"); if ( !Pattern.compile( mojoField, Pattern.CASE_INSENSITIVE ).matcher( html ).find() ) { System.out.println( mojoField ); throw new IllegalStateException( "Mojo field doc wrong!!!" ); } mojoField = "
" + MojoComponentFieldTaglet.HEADER + ":
role:" + "
org.apacha.maven.MyComponent
roleHint:
default
" + "
" + MojoReadOnlyFieldTaglet.HEADER + "
" + MojoRequiredFieldTaglet.HEADER + "
" + "
"; if ( html.toLowerCase( Locale.ENGLISH ).indexOf( ( mojoField ).toLowerCase( Locale.ENGLISH ) ) < 0 ) { throw new IllegalStateException( "Mojo field doc wrong" ); } return true;