pom changes needed to get JIRA link - maven

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>

Related

SpotBugs site report inconsistent with spotbugs:gui goal

I have set up SpotBugs to help us adhere to some standards, but I get different results in my generated site compared to SpotBugs user interface. This is my configuration of SpotBugs in my pom file:
<build>
<plugins>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>${spotbugs-maven-plugin.version}</version>
<configuration>
<excludeFilterFile>
src/test/resources/SpotBugsExcludeFilter.xml
</excludeFilterFile>
</configuration>
<dependencies>
<dependency>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs</artifactId>
<version>${spotbugs.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
...
<reporting>
<plugins>
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>${spotbugs-maven-plugin.version}</version>
<configuration>
<excludeFilterFile>
src/test/resources/SpotBugsExcludeFilter.xml
</excludeFilterFile>
</configuration>
</plugin>
</plugins>
</reporting>
When I run mvn clean install site, the site reports 5 bugs.
When I run mvn clean install spotbugs:gui, the gui reports 0 bugs.
How come there is a difference? It seems as if the site goal disregards my exclusion filter, but I can't see why. I am also not entirely sure how the build/plugins section correlates with the reporting/plugins section. If someone could tell me what I'm messing up here I'd be very grateful.
spotbugs:gui is not triggering the reporting scope where your configuration is defined.
You should be specifying your SpotBugs configuration in the <build> section.
<build>
<plugins>
[...]
<!-- SpotBugs Static Analysis -->
<plugin>
<groupId>com.github.spotbugs</groupId>
<artifactId>spotbugs-maven-plugin</artifactId>
<version>${spotbugs-maven-plugin.version}</version>
<configuration>
<excludeFilterFile>src/test/resources/SpotBugsExcludeFilter.xml</excludeFilterFile>
</configuration>
</plugin>
</plugins>
</build>
https://github.com/find-sec-bugs/find-sec-bugs/wiki/Maven-configuration

How can I exclude certain overlay-derived directories from my war using maven?

We build a webapp using maven 3.5.0 and the maven-war-plugin. We have many overlays, many of which have a tests directory that contains JSP files used for testing certain things in a dev environment. We don't want these included in our war.
We tried the following:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1</version>
<configuration>
<overlays>...</overlays>
<warSourceExcludes>tests</warSourceExcludes>
</configuration>
</plugin>
This didn't work, nor did a couple of configuration variations:
<packagingExcludes>tests</packagingExcludes>
and
<packagingExcludes>**/${project.artifactId}/tests/**</packagingExcludes>
Is this due to my naive misuse of configuration options, or does it have to do with how overlays are processed?
You should use <excludes>..</excludes> (see https://maven.apache.org/plugins/maven-war-plugin/overlays.html) instead of <packagingExcludes>..</packagingExclude>...
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<overlays>
<overlay>
<groupId>com.example.projects</groupId>
<artifactId>documentedprojectdependency</artifactId>
<excludes>
<exclude>WEB-INF/classes/images/sampleimage-dependency.jpg</exclude>
</excludes>
</overlay>
</overlays>
</configuration>
</plugin>
</plugins>
</build>
...
The dependentWarExcludes element worked to eliminate the tests directories and their contents:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<overlays>...</overlays>
<dependentWarExcludes>tests/**</dependentWarExcludes>
</configuration>
</plugin>

java 1.6 maven checkstyle eclipse

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.

Maven Report Configuration vs Build Configuration

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.

How to disable "Test Source Xref"

I'm using Maven Site Plugin to generate my project page. I want to publish sources also. So I used JXR Plugin. Does anybody know if it is possible to disable "Test Source Xref" report. I've only found this page http://jira.codehaus.org/browse/JXR-47 but this parameter doesn't seem to be working.
My configuration in POM looks like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.2</version>
<configuration>
<reportPlugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.3</version>
<configuration>
<suppressTestXref>true</suppressTestXref>
</configuration>
</plugin>
</reportPlugins>
</configuration>
</plugin>
suppressTestXref is not available anymore. The way to do this is:
<project ...>
...
<reporting>
...
<plugins>
<plugin>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.3</version>
<reportSets>
<reportSet>
<reports>
<report>jxr</report>
</reports>
</reportSet>
</reportSets>
</plugin>
AFAIK this is not documented anywhere :)

Resources