JavaDoc can't add custom stylesheet from src/main/resources - java

While executing mvn javadoc:javadoc i get this error:
An error has occurred in JavaDocs report generation: Option <stylesheet/> supports only "maven" or "java" value. -> [Help 1]"
But i read here http://maven.apache.org/plugins/maven-javadoc-plugin/examples/stylesheet-configuration.html that <stylesheetfile/> could be a resource in your project directory, i.e. src/main/java, src/main/resources or src/main/javadoc
so why i can not have in my pom:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version>
<configuration>
<stylesheet>src/main/resources/example.css</stylesheet>
</configuration>
</plugin>
?

If you like to configure a file which should be used you have to use the following configuration:
<project>
...
<reporting> (or <build>)
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version>
<configuration>
<stylesheetfile>${basedir}/path/to/your/stylesheetfile.css</stylesheetfile>
...
</configuration>
</plugin>
</plugins>
...
</reporting> (or </build>)
...
</project>

I had a typo not <stylesheet> but <stylesheetfile> should be used.

Related

Problem with building jar file with dependencies

I need to export a jar file which could be execute in server. I try many of answers in this site and other site, but I guess my main problem is :
[ERROR] Failed to parse plugin descriptor for mybot:energyBot:0.0.1-SNAPSHOT (/Users/narges/.m2/repository/bot/mBot/0.0.1-SNAPSHOT/energyBot-0.0.1-SNAPSHOT.jar): No plugin descriptor found at META-INF/maven/plugin.xml -> [Help 1]
Here is part of my pom.xml:
<plugins>
<plugin>
<groupId>mybot</groupId>
<artifactId>myBot</artifactId>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>$/Users/narges/eclipse-workspace/Bot/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
Use this in your pom.xml, plugin works fine with boot applications as well.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<outputDirectory>/your/path</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
You probably wrote myBot/energyBot yourself? You added it as a Maven plugin, but it seems like it is not a Maven plugin, but maybe just a plain jar.
If you want to put all dependencies into your jar, you need the assembly plugin or the shade plugin.

maven-surefire-report-plugin not generating report.html when build is failed

maven-surefire-report-plugin cannot generate HTML reports ,when commands like
mvn clean package site
mvn site
mvn clean deploy site
aren't able to generate successfull build and it does generate HTML reports on successfull build.
When mvn site command is used it gives following error
[WARNING] Error injecting: org.apache.maven.report.projectinfo.CiManagementRepor t
java.lang.NoClassDefFoundError: org/apache/maven/doxia/siterenderer/DocumentCont ent
The only time HTML reports are generated whether the build is failed or not is when i run
mvn surefire-report:report
This is my master POM.xml
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<configuration>
<argLine>-Dfile.encoding=UTF-8</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
</build>
</plugins>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.22.0</version>
<configuration>
<showSuccess>true</showSuccess>
<outputName>Reports</outputName>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.7.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.5</version>
</plugin>
</plugins>
</reporting>
even the site folder is not generated
If you want your maven build to succeed no matter the result of the unit tests than doing like #khmarbaise suggested it is correct:
mvn clean package -Dmaven.test.failure.ignore=true
If you want your tests to fail the build but still generate a report afterwards the following did the trick for me:
mvn clean test failsafe:integration-test
mvn -Dmaven.test.skip=true surefire-report:report
(Source: https://stackoverflow.com/a/4113187/9478795)

Empty directories are not copied during build from `scr/main/webapp`

This question prompted me to post a follow up question. During a maven build, empty directories are not copied from src/main/webapp, even though I have set the pom.xml to include empty directories:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<configuration>
<includeEmptyDirs>true</includeEmptyDirs>
</configuration>
</plugin>
How come empty directories are not copied?
I just met the same problem. This worked for me:
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<includeEmptyDirectories>true</includeEmptyDirectories> <!-- since 2.4 -->
</configuration>
</plugin>
Your method didn't work because that "src/main/webapp" was not a resource directory.
The reason is due to bug MWAR-128 in maven. The solution is to upgrade Maven to r1498124. Alternately, you can include a placeholder file (ex. empty.tmp) and filter it like so:
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>${maven.war.plugin.version}</version>
<configuration>
<packagingExcludes>**/empty.tmp</packagingExcludes>
</configuration>
</plugin>

Import FindBugs configuration from Sonar to Maven

How can I use a FindBugs configuration file from Sonar as the rule set in the Maven FindBugs plugin?
You can place your file, i.e. findbugs-sonar.xml in the src/main/resource folder and specify the path in your maven reporting settings like this:
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.5.3-SNAPSHOT</version>
<configuration>
<includeFilterFile>findbugs-sonar.xml</includeFilterFile>
</configuration>
</plugin>
</plugins>
</reporting>

How to view HTML coverage report using Cobertura Maven plugin?

I want to generate and view a coverage report for a Java-Maven project.
I've added the following to pom.xml:
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<formats>
<format>html</format>
</formats>
</configuration>
</plugin>
</plugins>
</reporting>
When I run mvn cobertura:cobertura it builds successfully and reports to the console that Cobertura Report generation was successful but I can't find the report.
If I cd into target/cobertura I find a file called cobertura.ser but I have no idea what to do with it.
Edit: After re-examining the docs, thanks to Andreas_D, I've added the <reporting> tag, but get the same result.
This in the Build section:
<build>
...
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.5.2</version>
</plugin>
...
</plugins>
...
</build>
And then this in the Reporting section:
<reporting>
...
<plugins>
...
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.5.2</version>
<configuration>
<check></check>
<formats>
<format>html</format>
<format>xml</format>
</formats>
</configuration>
</plugin>
...
</plugins>
...
</reporting>
Execute mvn cobertura:cobertura
Then look for index.html inside the target/site/cobertura/ folder.
Have a look at the plugin's documentation, there's an example. Pretty sure that you have to add a <reporting> element to actually produce the report.
I just tried here in my project, you can do the following also:
a) run mvn cobertura:cobertura
b) it should generate a folder called 'site'
c) you can open the index.html (inside site/sobertura folder) in whatever browser and inspect the results of coverage.
If nothing works - Try this
http://technikes.com/how-to-generate-code-coverage-report-in-java-jacoco-graphical-report/ you can get code coverage report in html and xml format
This is amazing as I publish my report in html and xml

Categories