I'm trying to generate the Javadoc HTML files for my project. I'm generating them via the Maven Javadoc plugin (maven-javadoc-plugin). I am using Maven 2.2.1. Everything generates such that all the proper information is there, but the HTML looks just awful. So bad that I don't want to publish it that way. Here is a screenshot:
(NOTE: Yes, I see the 'JavaScript is disabled on your browser' message. Even if I click the IE 8 warning about active content and enable it, it makes no difference)
There are all kinds of unnecessary line breaks, and the basic formatting is just crap. Am I missing something? I was expecting to see generated Javadocs that look similar to what I see in Eclipse if I hover over a class or method and see the popup Javadoc panel.
I've tried adding setting in my POM file, but I really don't know what I'm doing when it comes to configuring the Javadoc generator. Here's what I have at the moment (inside the <reporting> element):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9</version>
<configuration>
<javadocExecutable>C:\Java\jdk1.7.0_05\bin\javadoc.exe</javadocExecutable>
<javadocVersion>1.7</javadocVersion>
<locale>en_US</locale>
<show>package</show>
<verbose />
</configuration>
</plugin>
Any suggestions?
UPDATE:
The solution provided by Paulius worked perfectly. I removed the section above from my <reporting> section, as it was totally unnecessary. I added the new <plugin> element as he specified below. My POM file now contains this new block:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
...
</plugins>
</build>
Here is what the fixed output looks like:
Try to remove maven-javadoc-plugin from reporting section. If you are using Maven 3, the reporting section is deprecated and should be removed.
Try to add the following:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8.1</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
to your maven plugins section and run it. I am using maven-javadoc-plugin like this and it generates normal javadocs.
Hope this helps.
Related
I would like to set up the maven java-docs plugin in my project to create an aggregated report that includes only some classes from some of the modules and output the report to a folder of choice.
I have already tried to work with the Maven documentation here however whats indicated there does not seem to work for me.
I have tried the following configuration in the past and ran it as:
mvn javadoc:javadoc, or even javadoc:aggregate with the following parent/child pom configurations:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.0</version>
<inherited>false</inherited>
<configuration>
<!-- Default configuration for all reports -->
</configuration>
<executions>
<execution>
<id>aggregate</id>
<goals>
<goal>aggregate</goal>
</goals>
<phase>package</phase>
<configuration>
</configuration>
</execution>
</executions>
</plugin>
I have used something like this in the past:
parent pom.xml
<pluginManagement>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</pluginManagement>
...
<build>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<!-- Default configuration for all reports -->
</configuration>
<executions>
<execution>
<id>aggregate</id>
<goals>
<goal>aggregate</goal>
</goals>
<phase>site</phase>
<configuration>
<skip>false</skip>
</configuration>
</execution>
</executions>
</plugin>
</build>
Desired child module pom.xml
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<skip>false</skip>
<noqualifier>all</noqualifier>
<sourceFileIncludes>
<include>**\/\Class1.java</include>
<include>**\/\Class2.java</include>
<include>**\/\Interface3.java</include>
<include>**\/\Class4.java</include>
</sourceFileIncludes>
<reportOutputDirectory>${project.parent.basedir}/..</reportOutputDirectory>
<destDir>java-docs</destDir>
</configuration>
</plugin>
</plugins>
</build>
This configuration works fine if I am only generating from one single module, however once another child module is picked and configured as the one shown before, running mvn javadoc:aggregate continues to generate the docs for module 1 only, and module 2 gets ignored(or maybe even overriden)
Has anyone worked with a similar scenario, a multi module project structured like so:
ParentFolder
. . . module1
pom.xml
. . . module3
pom.xml
. . . module4
pom.xml
pom.xml
and have succeeded generating an aggregated java docs report using the maven java docs plugin, while excluding some classes and outputting the results to a folder of their choice?
Any help with this would be greatly appreciated!
Do you have one parent POM that contains both plugin config for the child POMs, and module definitions? If so, you may want to consider separating this POM into a separate aggregator (module definitions) and parent (anything else in the current POM that should be shared with children).
This answer goes into a lot more detail about Maven build order and why the behavior occurs.
The aggregator POM will also hold the configuration for child module data that should be aggregated, such as Javadoc.
I am beginning to learn how to run migration with liquibase in hibernate and spring project. I have added dependency libraries in pom.xml but on adding this to the build properties of my pom.xml i have issues
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>3.0.5</version>
<configuration>
<propertyFile>src/main/resources/liquibase.properties</propertyFile>
</configuration>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>update</goal>
</goals>
</execution>
</executions>
</plugin>
this is the screen shot of the error
If you hover over it, you get this error
Plugin execution not covered by lifecycle configuration: org.liquibase:liquibase-maven-plugin:3.0.5:update (execution: default, phase: process-resources)
Kindly assist me. I am beginning to learn liquibase
I guess you are using Eclipse? And with it the maven plugin M2Eclipse for Eclipse.
If you are interested in details checkout this article about it:
https://www.eclipse.org/m2e/documentation/m2e-execution-not-covered.html
If you just want to get rid of the error message use one of the quick fix solutions offered by eclipse. I just set it to "Ignore Plugin Goal" and that will add a <pluginExecutionFilter> which tell m2eclipse to ignore it.
It can be fixed by using pluginManagement tag, like this:
<build>
<pluginManagement>
<plugins>
<plugin> ... </plugin>
<plugin> ... </plugin>
....
</plugins>
</pluginManagement>
</build>
I have an aggregator project built in jenkins and I want to publish javadocs. So I installed javadoc plugin and changed my parent pom as follows:
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<aggregate>true</aggregate>
<outputDirectory>${project.build.directory}/apidocs</outputDirectory>
</configuration>
I tried different configurations but this is the only one that won't fail the build. With this configuration the build doesn't fail but no javadocs are to be found. Am I missing something here? Does anyone has the same problem?
First you should use the aggregate goal instead of the parameter cause it's marked deprecated.
Furthermore you should configure javadoc plugin like the following in your root pom like this:
<project>
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9.1</version>
<configuration>
<!-- Default configuration for all reports -->
...
</configuration>
<executions>
<execution>
<id>aggregate</id>
<goals>
<goal>aggregate</goal>
</goals>
<phase>package</phase>
<configuration>
<!-- Specific configuration for the aggregate report -->
...
</configuration>
</execution>
...
</executions>
</plugin>
...
</plugins>
</build>
...
</project>
Afterwards you should be able just by:
mvn clean package
This will result in a folder in the root target/apidoc which contains the created aggregated javadocs.
I found a way to publish the javadocs as .jar. I used the above pom configuration with the small change:
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
It publishes javadocs as .jars for every sub-module. The javadocs are to be found in the sub-module directory not in the parent directory.
I'm using the following in my project's pom.xml file. Running a findbugs:check goal still fails on all errors, even when no High priority errors are present. What am I doing wrong?
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.4.0</version>
<executions>
<execution>
<id>failing-on-high</id>
<phase>process-test-resources</phase>
<goals>
<goal>check</goal>
</goals>
<configuration>
<threshold>High</threshold>
<onlyAnalyze>com.example.-</onlyAnalyze>
</configuration>
</execution>
</executions>
Looking at the documentation and trying it out on a sample codebase, it looks like findbugs:check goal
Fail the build if there were any FindBugs violations in the source
code.
This does not seem to depend on the value of threshold.
Also look at this blog entry which seems to describe a related problem.
I am trying to integrate FindBugs in a maven project. Does anyone have a sample pom.xml generating a simple findbug HTML report in target? Is it possible to generate this report without having to run site:site?
Findbugs jar contains 5 XSLT transformations that can be used to convert hard to read XML to easy to read HTML so we can use xml-maven-plugin plugin to execute transformation and here is the configuration:
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.4.0</version>
<executions>
<execution>
<id>findbug</id>
<phase>verify</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<findbugsXmlOutputDirectory>
${project.build.directory}/findbugs
</findbugsXmlOutputDirectory>
<failOnError>false</failOnError>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xml-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>transform</goal>
</goals>
</execution>
</executions>
<configuration>
<transformationSets>
<transformationSet>
<dir>${project.build.directory}/findbugs</dir>
<outputDir>${project.build.directory}/findbugs</outputDir>
<stylesheet>fancy-hist.xsl</stylesheet>
<!--<stylesheet>default.xsl</stylesheet>-->
<!--<stylesheet>plain.xsl</stylesheet>-->
<!--<stylesheet>fancy.xsl</stylesheet>-->
<!--<stylesheet>summary.xsl</stylesheet>-->
<fileMappers>
<fileMapper
implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
<targetExtension>.html</targetExtension>
</fileMapper>
</fileMappers>
</transformationSet>
</transformationSets>
</configuration>
<dependencies>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>findbugs</artifactId>
<version>2.0.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
To get the report just execute mvn clean install.
The above code snippet contains all 5 possible transformations so try them all and hopefully you will find one you like.
I tried it with maven 3 and Finbugs 2.0
Check out Sonar. It's an open-source, stand-alone, web service that you "submit" your code to and it produces beautiful HTML reports on all kinds of code metrics. It also keeps a history of builds. And best of all, you don't have to modify your builds or poms!
There is a maven goal for it too: sonar:sonar. Jenkins (previously Hudson) has a plugin for it, so it's totally painless if you use that for your CI.
Check it out - you won't be sorry!