It is interesting what is the differences between
report->configuration element and build->configuration element in POM.
It is written in POM references:
Subtle 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).
See http://maven.apache.org/pom.html#Reporting
Could you give particular example of the differences in behaviour?
This statement means the following:
If we have report generation plugin configuration like
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.8</version>
<configuration>
<linkOnly>true</linkOnly>
</configuration>
</plugin>
</plugins>
</build>
then linkOnly configuration property won't be used when invoking site generation command
mvn site
Instead, we should use the same configuration under reporting element:
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.8</version>
<configuration>
<linkOnly>true</linkOnly>
</configuration>
<reportSets>
<reportSet>
<reports>
<report>license</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
Here we generate only license report with configuration parameter linkOnly=true.
I.e. build configuration is not used.
Note:
If we explicitly invoke report generation goal "license"
mvn project-info-report:license
then it will use configuration under build element.
I.e. we have opposite behaviour here.
Related
I would like to capture warnings/errors generated by maven-compiler-plugin (when running compile goal) and output them to a file (be it xml or json).By default, maven-compiler-plugin doesn't provide the option to configure a reporter. So, curious to know how this can be done. Here's my plugin config -
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.0</version>
<configuration>
<compilerArgs>
<arg>-verbose</arg>
<arg>-Xlint:all,-options,-path</arg>
</compilerArgs>
<showWarnings>true</showWarnings>
</configuration>
</plugin>
I am running maven application "DemoApp" that generates checkstyle static code analysis reports. It works correctly when I run it on eclipse, but when I build it on jenkins it gives the below error
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-site plugin:3.3:site (default-site) on project DemoApp: Execution default-site of goal org.apache.maven.plugins:maven-site-plugin:3.3:site failed: A required class was missing while executing org.apache.maven.plugins:maven-site-plugin:3
and The following exception :
java.lang.NoClassDefFoundError: org/apache/maven/doxia/siterenderer/DocumentContent
Caused by: java.lang.ClassNotFoundException: org.apache.maven.doxia.siterenderer.DocumentContent
I added the following plugins in pom.xml
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>validate</id>
<phase>validate</phase>
<configuration>
<configLocation>src/main/resources/google_checks.xml</configLocation>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
<failsOnError>false</failsOnError>
<linkXRef>false</linkXRef>
</configuration>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</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-project-info-reports-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.0.0</version>
<reportSets>
<reportSet>
<reports>
<report>checkstyle</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
I can't tell whether this solves your current issue but generally: Declarations within <pluginManagement> do not actually set anything in the build process but are intended as a centralized place for declarations common to (sub-)projects:
[...] this only configures plugins that are actually referenced within the plugins element in the children or in the current POM.
See the different versions in the error message: maven-site-plugin:3.3 and in the declaration: <version>3.7.1.
To add such a plugin declaration to the build process you have to declare/reference it additionaly in:
<build>
...
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
</plugin>
</plugins>
...
</build>
The same applies to the maven-checkstyle-plugin:
If you want to report to the console or fail the build, you must add an execution of checkstyle::check to the <build> element and configure any options that you need.
Is there a way to make this work? It seems my project always downloads the 3.5.1 version of maven-site-plugin and since Im stuck on java 1.6 its not working.
In my pom I have
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.15</version>
</plugin>
and
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>2.15</version>
<reportSets>
<reportSet>
<reports>
<report>checkstyle</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
You'd need to use some quite ancient versions, but it is possible. Refer to the Checkstyle Compatibility Matrix to see the versions.
Mostly, you will have to use Checkstyle 6.1.1, and configure your Maven to use it, too.
In my parent POM I have configured for sure fire report. But in some modules, I need to skip the sure fire report generation and instead I want to run fail-safe plugin to generate the test report.
I have tried like
<properties>
<skipTests>true</skipTests>
<skipFailsafeTests>false</skipFailsafeTests>
</properties>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.5</version>
<configuration>
<skipTests>${skipFailsafeTests}</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipExec>${skipTests}</skipExec>
<skipTests>${skipTests}</skipTests>
</configuration>
</plugin>
But still it seems sure-fire report is running. Is there any way to overcome it?
How do I configure my changes.xml and pom file in order to link JIRA issue on the maven site.
I am including the maven-changes plugin. But I want to see how do we add for JIRA as I add the following for bugzilla.
JIRA
https://bugs.abc.corp/enter_bug.cgi?product=${project.groupId}&component=${project.artifactId}
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-changes-plugin</artifactId>
<version>2.2</version>
<configuration>
<issueLinkTemplatePerSystem>
<bugzilla><![CDATA[http://internal.bugtracker/show_bug.cgi?id=%ISSUE%]]></bugzilla>
<navigator><![CDATA[http://external.bugtracker/?cr=%ISSUE%]]></navigator>
</issueLinkTemplatePerSystem>
</configuration>
<reportSets>
<reportSet>
<reports>
<report>changes-report</report>
</reports>
</reportSet>
</reportSets>
</plugin>
<plugin>
Of course, it is a great idea to take a look at the docs, as Raghuram suggested. JIRA is one of the pre-configured systems, and its standard URL for issues is %URL%/%ISSUE%.
From the XML snippet I understand you have added the issueLinkTemplatePerSystem configuration in the reporting section of the pom file. I have been struggling with this until I have tried adding that configuration to the pluginManagement section instead:
<project>
<!-- ... -->
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-changes-plugin</artifactId>
<version>2.9</version>
<configuration>
<issueLinkTemplatePerSystem>
<system1>https://a.b.c/ticket?id=%ISSUE%</system1>
<system2>https://foo.bar/baz/%ISSUE%/view</system2>
</issueLinkTemplatePerSystem>
</configuration>
</plugin>
<!-- ... -->
</plugins>
</pluginManagement>
<!-- ... -->
</build>
<!-- ... -->
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-changes-plugin</artifactId>
<reportSets>
<reportSet>
<reports>
<report>changes-report</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
<!-- ... -->
</project>
Then it worked like a charm, being able to use several different systems (with different template URLs) in changes.xml. I did not find this in the documentation.
Hint: try adding the option --debug (mvn --debug clean changes:changes-report) to see the IMSs taken by the plugin from the configuration.
Perhaps you should try the steps documented in Linking to Your Issue Management System section of the usage page of the plugin.
According to it, from version 2.4, the plugin comes pre-configured for a bunch of issue tracking systems, including jira. Quoting from the page,
If you use the issue attribute in your changes.xml file and have the
element configured in your pom.xml, the report will
contain links to the issues in your issue management system.
This is how I got it working for bugzilla and jira. So you just need to add an extra row -
You may put the url instead of the variable "%"
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-changes-plugin</artifactId>
<version>2.9</version>
<configuration>
<issueLinkTemplatePerSystem>
<jira><![CDATA[%URL%/browse/%ISSUE%]]></jira>
<bugzilla><![CDATA[http://bugzill.url/show_bug.cgi?id=%ISSUE%]]></bugzilla>
</issueLinkTemplatePerSystem>
</configuration>
<reportSets>
<reportSet>
<reports>
<report>changes-report</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>