java 1.6 maven checkstyle eclipse - maven

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.

Related

PluginVersionResolutionException in Maven project when I set packaging to bundle

In my Maven project when I change the packaging type from 'jar' to 'bundle' most of my plugins (compiler, deploy, install, resources, surefire) lose their versions. Why is this?
My pom.xml is below:
<groupId>org.wso2.carbon</groupId>
<artifactId>org.wso2.carbon.ui_4.4.35_patch</artifactId>
<version>1.0.0</version>
<packaging>bundle</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>4.2.1</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${project.artifactId}</Bundle-Name>
<Export-Package>web.admin.*</Export-Package>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
There are two possible approaches. The one I use for my own projects is to keep the bundle packaging and add the maven plugin versions to a pluginManagement section in the pom.xml. For example:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</pluginManagement>
<!-- Add you current 'plugins' section here. -->
</build>
In addition to the version, you can also add configuration to each plugin. If your project has a parent pom, it would be natural to add the pluginManagement section there instead of in your bundle module.
Alternatively, as suggested by #khmarbaise, you can use jar packaging and just use the maven-bundle-plugin to generate the manifest. That approach is described in the plugin documentation page.

IntelliJ - What indicates that a module is compiling in the Java version indicated in the POM

Using a multi-module Maven project configured in IntelliJ IDEA, I am configuring version 1.8 in the maven-compiler-plugin in the parent POM version. But I am configuring 1.5 in a certain child module.
In the parent:
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
In the child:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
</plugins>
</build>
In Eclipse, I had this indicator:
How and/or where do we check that in IntelliJ IDEA? How do I know that the child module is compiling with the desired 1.5 Java version?
See the related answer for the relevant screenshots.
You can find the source version in the Project Structure dialog, Modules, Sources tab: Language level.
Target version is in File | Settings | Build, Execution, Deployment | Compiler | Java Compiler (Per-module bytecode version).

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 :)

pom changes needed to get JIRA link

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>

Resources