ChangeLog Plugin Maven - configuration in POM - maven

I want to configure the changelog plugin in my pom.xml...
but there is a reportSets section, so I wonder where I have to put the plugin?
Maybe into the configuration part of the scm plugin (reportPlugins, ...)

The plugin goes in the reporting section of your pom.xml.
The example in their documentation shows how to configure the reportSets:
https://maven.apache.org/plugins/maven-changelog-plugin/examples/selecting-reports.html
Unlike build plugins which are configured under <build>, reporting plugins are nested inside a <reporting> element directly under your root <project> element like so:
<project>
<reporting>
<plugins>
<!-- one or more reporting plugins go here -->
</plugins>
<reporting>
</project>

a bit more particularised:
`
org.apache.maven.plugins
maven-site-plugin
3.3
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-changelog-plugin</artifactId>
<version>2.2</version>
<reportSets>
<reportSet>
<id> file-report </id>
<configuration>
<type> range </type>
<range> 30</range>
</configuration>
<reports>
<report>file-activity</report>
</reports>
</reportSet>
</reportSets>
</plugin>
And then... it should work!

Related

Jenkins SonarQube plugin Multi Module Code Coverage Not Displaying

so we have a Spring Boot maven based project, which we split into multi modules which all works perfectly fine in unit tests and Jenkins, but coverage is not showing up in Sonar at all.
This is the structure of our application:
ApplicationRoot
-SharedCommonModule
--main
---java
-----com...(SomeModule.java)
--test
----com....(SomeModuleTest.java)
-ApplicationModule
--main
---java
-----com...(Application.java)
--test
----com....(ApplicationTest.java)
Parent pom file config:
<properties>
<!-- Sonar -->
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.jacoco.reportPath>${project.basedir}/../target/jacoco.exec</sonar.jacoco.reportPath>
<sonar.language>java</sonar.language>
<jacoco.destFile>${sonar.jacoco.reportPath}</jacoco.destFile>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.5.201505241946</version>
<configuration>
<destFile>${sonar.jacoco.reportPath}</destFile>
<append>true</append>
</configuration>
<executions>
<execution>
<id>agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
SharedCommonModule pom:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
Main ApplicationModule pom file:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.org.Application</mainClass>
</configuration>
</plugin>
</plugins>
</build>
Jenkins SonarQube plugin configuration:
sonar.projectKey=com.Application
sonar.projectName=ApplicationModule
sonar.projectVersion=1.0.0.${BUILD_NUMBER}
sonar.sources=src/main
sonar.tests=src/test
sonar.java.binaries=target/classes
sonar.jacoco.reportPaths=target/jacoco.exec
sonar.modules=ApplicationModule,SharedCommonModule
ApplicationModule.sonar.projectName=ApplicationModule
SharedCommonModule.sonar.projectName=SharedCommonModule
We have researched and tried to hack it together from multiple examples, but nothing seems to work - closest we've got, is for Sonar to show some coverage, while some classes would show 0% coverage even though we know for sure we have UTs that used those classes (tested via IntelliJ).
So, without without the added properties and build xml sections above, we get partial coverage, only for ApplicaitonModule, I think all reported uncovered classes, belong to SharedCommonModule
EDIT: I want to clarify, the combined jacoco.exec file does show coverage for classes when loaded in IntelliJ Coverage tool, but Sonar does not show coverage for the very same classes in its report (which is generated only when I remove the build and properties xml elements in the parent pom).
Please help :)
You have Maven projects, so you should start using Sonar Scanner for Maven.
It is smart enough to generate all parameters for you.
If you remove:
<sonar.jacoco.reportPath>${project.basedir}/../target/jacoco.exec</sonar.jacoco.reportPath>
<jacoco.destFile>${sonar.jacoco.reportPath}</jacoco.destFile>
<destFile>${sonar.jacoco.reportPath}</destFile>
Jenkins SonarQube plugin configuration
add to parent pom file:
<name>ApplicationModule</name>
<properties>
<sonar.sources>src/main</sonar.sources>
<sonar.tests>src/test</sonar.tests>
<sonar.projectKey>com.Application</sonar.projectKey>
</properties>
add to SharedCommonModule pom file:
<name>SharedCommonModule</name>
add to ApplicationModule.pom file:
<name>ApplicationModule</name>
and finally execute:
mvn sonar:sonar -Dsonar.projectVersion="1.0.0.${BUILD_NUMBER}"
After that you should see missing coverage data.
Btw. it is not recomended to set sonar.projectKey for Maven projects. I set it to the same value, so your project will be accessible under the same link.

Maven not outputting junit CHECKSTYLE report

After default config, maven is only outputting the Checkstyle report for source classes, not Junit test classes. Note I'm not looking for the surefire test report output.
from pom.xml:
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version>
<reportSets>
<reportSet>
<reports>
<report>checkstyle</report>
</reports>
</reportSet>
</reportSets>
<configuration>
<configLocation>src/main/resources/apcheckstyle.xml</configLocation>
<module name="LineLength">
<property name="max" value="120"/>
</module>
</configuration>
</plugin>
</plugins>
I changed dependency scope for junit from test to compile:
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>compile</scope>
</dependency>
Maven is configured to generate the checkstyle reports using the mvn site plugin.
I tried adding a user property includeTestResources as true, but this did not help. The documentation states that the default value is true, so I took it out.
Here is the maven output during checkstyle generation.
from javadocs:
Generating C:\Users\Administrator\Projects\lht657aws\target\site\testapidocs\help-doc.html...
checkstyle plugin runs:
[INFO] Generating "Checkstyle" report --- maven-checkstyle-plugin:2.17
[INFO] There are 210 errors reported by Checkstyle 6.11.2 with src/main/resources/apcheckstyle.xml ruleset.
is following the problem-? all the java under src is getting processed, just java under test is being skipped:
[WARNING] Unable to locate Source XRef to link to - DISABLED
after checkstyle, maven project info report starts
[INFO] Generating "Dependencies" report --- maven-project-info-reports-plugin:2.9
Add the Maven Surefire Report plugin to your pom XML
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<outputDirectory>path/to/the/report</outputDirectory>
</configuration>
</plugin>
And add the goal surefire-report:report to your maven call
See the documentation here: Maven Surefire Report Plugin
EDIT
I've misunderstood the question, try to add this section with desired configurations to your pom.
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.17</version>
<reportSets>
<reportSet>
<id>main_checks</id>
<reports>
<report>checkstyle</report>
</reports>
<configuration>
<sourceDirectory>${project.build.sourceDirectory}</sourceDirectory>
<includeTestSourceDirectory>false</includeTestSourceDirectory>
<configLocation>config/maven_checks.xml</configLocation>
<outputDirectory>${project.reporting.outputDirectory}/main-checks/</outputDirectory>
</configuration>
</reportSet>
<reportSet>
<id>test_checks</id>
<reports>
<report>checkstyle</report>
</reports>
<configuration>
<sourceDirectory></sourceDirectory>
<testSourceDirectory>${project.build.testSourceDirectory}</testSourceDirectory>
<includeTestSourceDirectory>true</includeTestSourceDirectory>
<configLocation>config/sun_checks.xml</configLocation>
<outputDirectory>${project.reporting.outputDirectory}/test-checks/</outputDirectory>
</configuration>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
Maven sure fire plugin is used for generating the Test reports. See the additional documentation here:
http://maven.apache.org/surefire/maven-surefire-report-plugin/
You need to include this plugin in your POM.xml and provide path to create reports (generally a directory in project). While making the build make sure you are including goal for this.

findbugs maven plugin site vs check

I'm just trying to wrap my head around a couple of things.
If I have this in my masterpom:
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.5.2</version>
<configuration>
<failOnError>false</failOnError>
<threshold>High</threshold>
<effort>Default</effort>
<xmlOutput>true</xmlOutput>
<skip>${skipFindBugs}</skip>
<xmlOutputDirectory>target/reports/findbugs</xmlOutputDirectory>
<excludeFilterFile>
src/main/resources/findbugs-exclude-filters.xml
</excludeFilterFile>
</configuration>
</plugin>
</plugins>
</reporting>
My findbugs-exclude-filters.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter>
<Match>
<Bug category="I18N" />
</Match>
</FindBugsFilter>
QUESTIONS
Why does clean verify site report 2 warnings, but clean verify findbugs:check return 14 bugs? I don't understand what the difference is.
Why does my site report warn about I18N:DM_DEFAULT_ENCODING
The findbugs-maven-plugin plugin needs to be configured in BOTH the <reporting><plugins/></reporting> and <build><plugins/></build> section. Have experimented with this all sorts of ways and the only way I have been able to get it to work is to duplicate findbugs-maven-plugin configuration.
So try adding something like the following in your pom.xml:
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.5.2</version>
<configuration>
<failOnError>false</failOnError>
<threshold>High</threshold>
<effort>Default</effort>
<xmlOutput>true</xmlOutput>
<skip>${skipFindBugs}</skip>
<xmlOutputDirectory>target/reports/findbugs</xmlOutputDirectory>
<excludeFilterFile>
src/main/resources/findbugs-exclude-filters.xml
</excludeFilterFile>
</configuration>
</plugin>
</plugins>
</build>
Note that it's a cut and paste of what you posted inside of the <reporting/> block. I have not tested the above. I'm just trying to give you a general idea here.
The Reporting section of the POM Reference states that:
And the subtler difference is that a plugin configuration under the reporting element works as build plugin configuration, although the opposite is not true (a build plugin configuration does not affect a reporting plugin).
I have been able to make this work with Maven 3.0.5. I have not tried it on 3.1.0 yet.

UmlGraph not automatic integrated in JavaDoc

I'm using maven and the maven-javadoc-plugin with the umlgraph-doclet to create javadoc for my project. The part from my pom:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<inherited>false</inherited>
<configuration>
<reportPlugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.8</version>
<configuration>
<show>public</show>
<quiet>true</quiet>
<doclet>org.umlgraph.doclet.UmlGraphDoc</doclet>
<docletArtifact>
<groupId>org.umlgraph</groupId>
<artifactId>doclet</artifactId>
<version>5.1</version>
</docletArtifact>
<useStandardDocletOptions>true</useStandardDocletOptions>
<additionalparam>
-inferrel -inferdep -quiet -hide java.* -hide org.eclipse.* -collpackages java.util.* -postfixpackage
-nodefontsize 9 -nodefontpackagesize 7 -attributes -types -visibility -operations -constructors
-enumerations -enumconstants -views
</additionalparam>
</configuration>
<reportSets>
<reportSet>
<reports>
<report>aggregate</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</reportPlugins>
</configuration>
</plugin>
</plugins>
</build>
The images are generated and look fine, when building the javadoc with jdk1.6 they get automatically integrated into all javadoc pages. But when building with jdk1.7, the images still get created but are not inside the javadoc pages. Even when using the v5.4 from the official website, the javadoc is imageless. And the debug output of maven also don't give any clue. On top of that, there is no way of contacting one of the UmlGraph devs by mail.
Can anyone give me some advice here, or have some ideas how to fix that?
Update: version 5.6.6 is now on maven central. I built with JDK 7 and diagrams look ok.
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.7</version>
<configuration>
<aggregate>true</aggregate>
<show>private</show>
<doclet>org.umlgraph.doclet.UmlGraphDoc</doclet>
<docletArtifact>
<groupId>org.umlgraph</groupId>
<artifactId>umlgraph</artifactId>
<version>5.6.6</version>
</docletArtifact>
</configuration>
</plugin>
I checked the possibilities, and the situation is following:.
relevant bug in the UmlGraph has been already fixed: https://github.com/dspinellis/UMLGraph/pull/8
problem is however that no stable version of UmlGraph has been released yet that would include the fix
However good news is that there exists snapshot repository containing the fix: https://oss.sonatype.org/content/repositories/snapshots/org/umlgraph/umlgraph/5.5.8-SNAPSHOT/
Therefor you need to get the jar file to your local repository (depending on your infrastructure setup):
either by adding reffered repository to your environment
or by importing to your local repo (http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html)
afterwards update:
<doclet>org.umlgraph.doclet.UmlGraphDoc</doclet>
<docletArtifact>
<groupId>org.umlgraph</groupId>
<artifactId>doclet</artifactId>
<version>5.1</version>
</docletArtifact>
to the following (naming convention has been changed):
<doclet>org.umlgraph.doclet.UmlGraphDoc</doclet>
<docletArtifact>
<groupId>org.umlgraph</groupId>
<artifactId>umlgraph</artifactId>
<version>5.5.8-SNAPSHOT</version>
</docletArtifact>
UmlGraphDoc version 5.4, altering javadocs
Warning, could not find a line that matches the pattern '/H2'
The HTML is simply different.
Java7 JavaDocs
START OF CLASS DATA
h2 title="blah blah
Java6 JavaDocs
START OF CLASS DATA
H2
You can decompile and modify UmlGraphDoc.java
I have the same problem. My guess is that it's this bug:
https://issues.jboss.org/browse/APIVIZ-10

Maven archetype plugin doesn't let .resources in archetype-resources through

How can I make resources like .gitignore be part of the resulting project?
create archetype with archetype-resources/.gitignore
mvn install
mvn archetype:generate
resulting project doesn't contain .gitignore
PS. I'm sure it isn't there.
The bug seems to be still present in the maven-archetype-plugin v3.0.1 .
For those who do not want to downgrade the maven-resource-plugin. I managed to establish a more or less ugly workaround.
First you rename the archetype-resources/.gitignore to
__gitignore__
then inside the archetype-metadata.xml add
<requiredProperties>
<requiredProperty key="gitignore">
<defaultValue>.gitignore</defaultValue>
</requiredProperty>
</requiredProperties>
<fileSets>
<fileSet>
<directory></directory>
<includes>
<include>__gitignore__</include>
</includes>
</fileSet>
</fileSets>
When the archetype is generated maven will now first copy the __gitignore__ then sees the __[file]__ syntax and will replace it with the default value ".gitignore"
This solution for upcoming maven-resources-plugin v3.0.0 (not yet released at the time of posting this; current is still 2.7) from https://issues.apache.org/jira/browse/MRESOURCES-190 seems better than holding back version upgrades:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<!-- Required so that .gitignore gets included in archetypes; see https://issues.apache.org/jira/browse/MRESOURCES-190 -->
<addDefaultExcludes>false</addDefaultExcludes>
Add a fileSet entry to src/main/resources/META-INF/maven/archetype-metadata.xml with an empty directory tag:
<fileSet>
<directory></directory>
<includes>
<include>.gitignore</include>
</includes>
</fileSet>
This will copy the included files from src/main/resources/archetype-resources to the project root directory.
Check your maven-resources-plugin version by launching the Maven build on debug (with -X option). If you use 2.7, there is a regression where .gitignore files are silently ignored.
In this case, you will have to explicitly use 2.6 in your pom.xml:
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
</plugin>
</plugins>
</pluginManagement>
</build>
ARCHETYPE/issues/ARCHETYPE-505 shows that this is thoroughly broken with current versions of the plugin and maven. No workarounds help anymore with this.
Solution that worked perfectly for me was to use archetype post install groovy script.
Create a file META-INF/archetype-post-generate.groovy in the resources folder of your archetype project.
Add this code:
file = new File( request.getOutputDirectory(), request.getArtifactId()+"/.gitignore.tmpl" );
def gitIgnorefile = new File( request.getOutputDirectory(), request.getArtifactId()+"/.gitignore" );
file.renameTo(gitIgnorefile)
In your archetype-metadata.xml file include the template .gitignore.tmpl file.
<fileSet>
<directory/>
<includes>
<include>.gitignore.tmpl</include>
</includes>
</fileSet>
I had problems with maven resource plugin hence used groovy script solution.
While looking for a solution for this problem, went to the FAQ section of the maven-archetype-plugin, and, apparently, version 3.2.1 supports such case, i.e, we can now include .gitignore.
For that, config maven-resources and maven-archtype-plugin:
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<addDefaultExcludes>false</addDefaultExcludes>
</configuration>
</plugin>
<plugin>
<artifactId>maven-archetype-plugin</artifactId>
<configuration>
<useDefaultExcludes>false</useDefaultExcludes>
</configuration>
</plugin>
</plugins>
Note: I used version 3.3.0 for the maven-resources-plugin and version 3.2.1 for the maven-archetype-plugin.
Source:
https://maven.apache.org/archetype/maven-archetype-plugin/faq.html#excludes
Alternative for downgrading maven-resources-plugin is to enforce plexus-utils version which actually has a regression:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<dependencies>
<!-- it's for fixing maven-resources-plugin 2.7 MRESOURCES-190 -->
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<!-- this is last 2.x release -->
<version>2.1</version>
</dependency>
</dependencies>
</plugin>
the bug is still in the newest maven-archetype-plugin 2.4 and maven-resources-plugin 3.0.1.
here is the solution:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-archetype-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
</plugin>
and in your generate pom.xml you should add
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
</plugin>

Resources