maven-compiler-plugin report generation - maven

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). I would then like to view the file on CI console. 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>
<configuration>
<compilerArgument>-Xlint:all</compilerArgument>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
</configuration>
</plugin>

Related

Publish report for maven compiler plugin xlint

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>

How to add multiple plugin in same pom.xml file

I have two project, which run on two different platform Android and Ios. which i am controlling by different suite runner file . when i am trying to run same via Maven , whichever plugin mention last , only that profile run , how can i make working of all.
<plugins>
<!-- build standalone exe jar -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<configuration>
<skip>false</skip>
<mainClass>platform.atcios.SuiteRunner</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<configuration>
<skip>false</skip>
<mainClass>platform.atc.SuiteRunner</mainClass>
</configuration>
</plugin>
</plugins>
</build>
in this , if atc is mention in last , when run for ios , atcios giving build fail error and viceversa.
how to make both work
You need to define different <executions> inside the same <plugin> tag.
Each <execution> may have its own <configuration>.

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.

Getting Maven Build to include empty directories

I am trying to get maven to include an empty directory which is just used for output files created by the webapp (which is why it is empty).
I have googled and the maven-resources-plugin seemed to be the best option for this, the documentation states that the property includeEmptyDirs is since 2.3 and I am using 2.4, however this seems to do nothing and so far the only way Ive managed to get the directory to create is by putting a text file into it, I dont really want to do this if Maven should be able to do this for me.
Can someone tell me what I am doing wrong? Below is my build section from the pom file:
<build>
<finalName>MyApp</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<compilerVersion>1.7</compilerVersion>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4</version>
<configuration>
<includeEmptyDirs>true</includeEmptyDirs>
</configuration>
</plugin>
</plugins>
</build>
Take a look at the maven-war-plugin which has a configuration item includeEmptyDirectories.

Disable sure-fire and execute fail-safe report to run my test cases in a Maven project

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?

Resources