org.apache.maven.plugin.jxr.JxrReportUtil Maven / Gradle / Ivy
package org.apache.maven.plugin.jxr;
/*
* 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.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.PluginExecution;
import org.apache.maven.model.ReportPlugin;
import org.apache.maven.model.Site;
import org.apache.maven.project.MavenProject;
import org.apache.maven.wagon.repository.Repository;
import org.apache.xpath.XPathAPI;
import org.apache.xpath.objects.XObject;
import org.codehaus.plexus.util.StringInputStream;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
/**
* Utility class for the jxr report.
*
* @author Vincent Siveton
* @version $Id: JxrReportUtil.java 1634366 2014-10-26 17:53:17Z khmarbaise $
*/
public class JxrReportUtil
{
private static final String MAVEN_JAVADOC_PLUGIN_GROUP_ID = "org.apache.maven.plugins";
private static final String MAVEN_JAVADOC_PLUGIN_ARTIFACT_ID = "maven-javadoc-plugin";
/**
* Determine if javadoc is aggregated in this project, paying attention to both TODO: take cognizance of javadoc
* versus test-javadoc the old parameter and the new mojo.
*
* @param project
* @return
* @throws IOException
*/
protected static boolean isJavadocAggregated( MavenProject project )
throws IOException
{
// first check conf for obsolete aggregate param.
// CHECKSTYLE_OFF: LineLength
boolean javadocAggregate =
Boolean.valueOf( JxrReportUtil.getMavenJavadocPluginBasicOption( project, "aggregate", "false" ) ).booleanValue();
// CHECKSTYLE_ON: LineLength
if ( javadocAggregate )
{
return true;
}
for ( Object pluginObject : getMavenJavadocPlugins( project ) )
{
if ( pluginObject instanceof Plugin )
{
Plugin plugin = (Plugin) pluginObject;
List executions = plugin.getExecutions();
for ( PluginExecution pe : executions )
{
List goals = pe.getGoals();
for ( String goal : goals )
{
if ( "aggregate".equals( goal ) )
{
return true;
}
}
}
}
}
return false;
}
/**
* Return the optionName
value defined in a project for the "maven-javadoc-plugin" plugin.
*
* @param project not null
* @param optionName the option name wanted
* @param defaultValue a default value
* @return the value for the option name or the default value. Could be null if not found.
* @throws IOException if any
*/
protected static String getMavenJavadocPluginBasicOption( MavenProject project, String optionName,
String defaultValue )
throws IOException
{
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy