DocumentationContext context, BoostedNode documentationParentOfNewArtifacts) throws Exception {
getLog().debug("documentProject ", createArtifactIdentifierForDocumentation(project));
BoostedModelDelegate model =null;
if (project.getModel() instanceof BoostedModelDelegate)
model =(BoostedModelDelegate) project.getModel();
//document Aggregator
Dependency moduleAggregator = model.getModuleAggregator();
if (model != null && moduleAggregator != null){
MavenProject parentProject = PomUtils.readMavenProjectFromRepository(moduleAggregator.getGroupId(), moduleAggregator.getArtifactId(), moduleAggregator.getVersion());
documentProjectIfNecessary(parentProject, type, documentationParent, context, documentationParentOfNewArtifacts, documentationParent);
}
//document parent
Parent parent = project.getModel().getParent();
if (parent instanceof BoostedParent){
BoostedParent par = (BoostedParent) parent;
MavenProject parentProject = PomUtils.readMavenProjectFromRepository(par.getGroupId(), par.getArtifactId(), par.getVersion());
if (Boolean.TRUE.equals( par.getAttributes().getFromMap(GeneralConstants.USE_IN_DOCUMENTATION))){
documentProjectIfNecessary(parentProject, type, documentationParent, context, documentationParentOfNewArtifacts, documentationParent);
}
}
//use enhanced description
if (DocumentationResourecesId.DOCUMENTATION_DEVELOPER.equals(type)){
//write description
if ( project.getDescription() != null){
String description = project.getDescription().trim();
if (! "".equals(description)){
BookUtils.createDiv(documentationParent, description);
}
}
//write additional developer documentation
if (model != null){
Map<String,String> develDoku = (Map<String,String>) model.getAttributes().getFromMap(DocumentationResourecesId.DOCUMENTATION_DEVELOPER);
if (develDoku != null)
{
if (develDoku.containsKey(GeneralConstants.DESCRIPTION)){
BookUtils.createDiv(documentationParent, develDoku.get(GeneralConstants.DESCRIPTION));
}
}
}
//write packaging type
BookUtils.createDiv(documentationParent, "This artifact is of type " + project.getPackaging() + ".");
//write aggregator artifact
if (moduleAggregator != null)
BookUtils.createDiv(documentationParent, "The module aggregator (the artifact in the parent directory) of this artifact is " + createArtifactIdentifierForDocumentation(moduleAggregator));
//write parent infos
if (parent instanceof BoostedParent){
BoostedParent par = (BoostedParent) parent;
if (Boolean.TRUE.equals( par.getAttributes().getFromMap(GeneralConstants.USE_IN_DOCUMENTATION))){
BookUtils.createDiv(documentationParent, "The parent of this artifact is " + createArtifactIdentifierForDocumentation(par));
}
}
//write plugin execution infos
String pluginHtml = model.getRuntimePluginExecutionHtmlTable();
if ( pluginHtml != null){
BoostedNode pluginInfo = BookUtils.createChapter(documentationParent, "Information about executed plugins");
BookUtils.createDivWithRawContent(pluginInfo, "<table><tbody>" + pluginHtml + "</tbody></table>");
}
}
getLog().info("documenting dependencies");
//document dependencies
for (Object dependency: project.getDependencies()){
if (dependency instanceof BoostedDependency){
BoostedDependency dep = (BoostedDependency) dependency;
MavenProject dependencyProject = PomUtils.readMavenProjectFromRepository(dep.getGroupId(), dep.getArtifactId(), dep.getVersion());
if (Boolean.TRUE.equals( dep.getAttributes().getFromMap(GeneralConstants.USE_IN_DOCUMENTATION))){
BookUtils.createDiv(documentationParent, "Add a dependency to the artifact " + createArtifactIdentifierForDocumentation(dep));
documentProjectIfNecessary(dependencyProject, type, documentationParent, context, documentationParentOfNewArtifacts, documentationParent);
}
}
}
//properties
if (project.getProperties() instanceof BoostedProperties){
BoostedProperties properties = (BoostedProperties) project.getProperties();
if (Boolean.TRUE.equals(properties.getAttributes().getFromMap(GeneralConstants.USE_IN_DOCUMENTATION))){
Object docu = properties.getAttributes().getFromMap(DocumentationResourecesId.DOCUMENTATION_DEVELOPER);
if (docu != null){
BookUtils.createDiv(documentationParent, "There are the following important properties: ");
BookUtils.createDiv(documentationParent, docu.toString());
}
}
}
getLog().info("documenting profile dependencies");
for (Profile profile: project.getModel().getProfiles()){
getLog().info("documenting profile " + profile.getId());
//dependencies of profile
for (Object dependency: profile.getDependencies()){
if (dependency instanceof BoostedDependency){
BoostedDependency dep = (BoostedDependency) dependency;
MavenProject dependencyProject = PomUtils.readMavenProjectFromRepository(dep.getGroupId(), dep.getArtifactId(), dep.getVersion());
if (Boolean.TRUE.equals( dep.getAttributes().getFromMap(GeneralConstants.USE_IN_DOCUMENTATION))){
BookUtils.createDiv(documentationParent, "In the profile " + profile.getId() + " add a dependency to the artifact " + createArtifactIdentifierForDocumentation(dep));
documentProjectIfNecessary(dependencyProject, type, documentationParent, context, documentationParentOfNewArtifacts, null);
}
}
}
//properties of profile
if (profile.getProperties() instanceof BoostedProperties){
BoostedProperties properties = (BoostedProperties) profile.getProperties();
if (Boolean.TRUE.equals(properties.getAttributes().getFromMap(GeneralConstants.USE_IN_DOCUMENTATION))){
Object docu = properties.getAttributes().getFromMap(DocumentationResourecesId.DOCUMENTATION_DEVELOPER);
if (docu != null){
BookUtils.createDiv(documentationParent, "In the profile " + profile.getId() + " there are the following important properties: ");
BookUtils.createDiv(documentationParent, docu.toString());
}
}
}
}
//plugins
if ( project.getBuild() != null && project.getBuild().getPlugins() != null)
for (Plugin plugin: project.getBuild().getPlugins()){
if (plugin.getExecutions() != null){
for (PluginExecution execution : plugin.getExecutions()){
if (execution instanceof BoostedPluginExecution){
BoostedPluginExecution exe = (BoostedPluginExecution) execution;
MavenProject dependencyProject = PomUtils.readMavenProjectFromRepository(plugin.getGroupId(), plugin.getArtifactId(), plugin.getVersion());
if (Boolean.TRUE.equals( exe.getAttributes().getFromMap(GeneralConstants.USE_IN_DOCUMENTATION))){
BookUtils.createDiv(documentationParent, "Executes " + exe.getId() + " with goals " + exe.getGoals() + " of plugin " + createArtifactIdentifierForDocumentation(plugin));
String pluginPath="/" + plugin.getGroupId()+ "/" + plugin.getArtifactId() + "/plugin.xml";
InputStream pluginXml = MavenDocumentationGenerator.class.getResourceAsStream(pluginPath);
if (pluginXml == null)
throw new FileNotFoundException(pluginPath + " not found in jars.");
PluginDescriptor pluginDescriptor = PomUtils.readPluginDescriptor(new InputStreamReader( pluginXml));
BookUtils.createDiv(documentationParent, "Move this part to a separate chapter " + pluginDescriptor.getDescription());
//documentProjectIfNecessary(dependencyProject, type, documentationParent, context, documentationParentOfNewArtifacts, null);
}
}
}
}
}
if (model != null){
String softwareDocuGeneratorClass = (String) model.getAttributes().getFromMap(GeneralConstants.SOFTWARE_DOCU_GENERATOR);
//optimization: generator may be string or class or instance
if (softwareDocuGeneratorClass != null){
HasDocumentation generator = (HasDocumentation) Class.forName(softwareDocuGeneratorClass).newInstance();
generator.fillDocumentation(type, documentationParent, context);
}