Maven versions-maven-plugin versions plugin 2.2 -- Maven Uncle Situation - maven

Maven is 3.1.0.
I'm using versions-maven-plugin:2.2 in my project's pom.xml (as shown below). Apart from the usual pom.xml file configuration, I'm just showing the main code snapshot below:
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>tools-parent</artifactId>
<version>0.0.7-SNAPSHOT</version>
<packaging>pom</packaging>
<description>
Infrastructure related to the "vapp" and
"deployer" utilities.
</description>
<parent>
<groupId>com.company.product</groupId>
<artifactId>deploy-parent</artifactId>
<version>0.0.6-SNAPSHOT</version>
</parent>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.9.4</version>
<configuration>
<connectionType>connection</connectionType>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<!-- Make sure that only non-snapshot versions are used for the dependencies. Only active when property 'snapshotDependencyAllowed' is false. -->
<id>enforce-no-snapshots</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<skip>${snapshotDependencyAllowed}</skip>
<rules>
<requireReleaseDeps>
<message>No Snapshots Allowed!</message>
</requireReleaseDeps>
<requireReleaseVersion>
<message>No Snapshots Allowed!</message>
</requireReleaseVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Now, when I run: mvn clean install, it builds successfully.
NOTE: In my project, I have a parent section, where I'm dependent upon deploy-parent artifact whose group id "com.company.product" is the same group id what I want to tools-parent artifact (whose pom.xml I have pasted above) but deploy-parent is an artifact of another repository/project.
When I run: mvn versions:set -DnewVersion=0.0.7, I get the following error message.
[INFO] ------------------------------------------------------------------------
[INFO] Building tools-parent 0.0.7-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- versions-maven-plugin:2.2:set (default-cli) # tools-parent ---
[INFO] Searching for local aggregator root...
[INFO] Local aggregation root: /user/home/u100123/giga/tools
[INFO] Processing change of com.company.product:tools-parent:0.0.7-SNAPSHOT -> 0.0.7
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] tools-parent .................................... FAILURE [1.093s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.404s
[INFO] Finished at: Fri May 01 20:44:22 GMT-00:00 2015
[INFO] Final Memory: 12M/246M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:versions-maven-plugin:2.2:set (default-cli) on project tools-parent: Execution default-cli of goal org.codehaus.mojo:versions-maven-plugin:2.2:set failed. NullPointerException -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException
NOW, when I change the versions-maven-plugin version back to 2.1 (which what I was using earlier), the above mvn versions:set -DnewVersion=0.0.7 command is working successfully and pom.xml file is successfully getting changed to <version>0.0.7</version> for tools-parent artifact.
With version 2.2, it's giving me the error and not changing the version to 0.0.7.
Any reasons why 2.2 is failing? What can be done to resolve it?

It seems like some bug.
Solution:
1. I have to add <groupId>com.company.product</groupId> property outside of ... section as well i.e. for tools-parent, NOW version-maven-plugin:2.2 is working fine i.e. I added the top line (as shown below). The only thing is, what's the use of parent section then (apart from inheriting the main code of what deploy-parent is brining to tools-parent project). Why groupId needs to be defined output of parent section for artifactId tools-parent when it's already there in the parent section for versions-maven-plugin:2.2 to work successfully.
The most important thing is: This issue occurs only in case your pom.xml for a project/module has a <parent> section where the parent section's artifactId is not the parent of the project itself (a typical - Maven Uncle situation) i.e. if tools-parent artifact is defined in the parent section of another module (lets say tools-child) then version 2.2 will work successfully. But if tools-child's parent section is not containing the artifactId as "tools-parent" and is something else for ex: deploy-parent/some-different-project-artifact (which resides in a different project in your source control tool) then, for tools-child artifactId, we need groupId value also set outside of the parent section as well (even if the groupId of parent section's artifactId is same/different to tools-child's groupId).
<groupId>com.company.product</groupId>
<artifactId>tools-parent</artifactId>
<version>0.0.7-SNAPSHOT</version>
<packaging>pom</packaging>
<description>
Infrastructure related to the "vapp" and
"deployer" utilities.
</description>
<parent>
<groupId>com.company.product</groupId>
<artifactId>deploy-parent</artifactId>
<version>0.0.6-SNAPSHOT</version>
</parent>
--OR
2. Switch back to versions-maven-plugin:2.1

Just to add to part 2 of Arun's answer, the way to use version 2.1 of the plugin is:
mvn org.codehaus.mojo:versions-maven-plugin:2.1:set org.codehaus.mojo:versions-maven-plugin:2.1:commit -DnewVersion=0.0.7
You have to specify the full group-id and artifact-id.

Found this bug reported on the issue:
https://github.com/mojohaus/versions-maven-plugin/issues/51

I ran into a NPE too but it turns out the reason was a different one than suggested earlier. I debugged the versions-maven-plugin and found out that the NPE was caused by a missing <version> declaration of a dependency in the listed in the <dependencyManagement>. This can be reproduced with the following listing:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>npe</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>NPE Example</name>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<!-- missing <version>4.2.0.RELEASE</version> -->
<scope>runtime</scope>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.2.0.RELEASE</version>
</dependency>
</dependencies>
</project>

Related

Adding external jar to project using maven-shading

My goal is to add an external jar into my Maven-project. Running the project invokes an NoClassDefFoundError. So I did a little research to found out that possibly the external jar is not included in my created jar file.
Therefor I found the solution to use maven-shade-plugin, but I'm stuck a little because the project will not compile.
I've got the following pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>this.isa.test</groupId>
<artifactId>test</artifactId>
<version>0.0.1</version>
<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>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version><!--change this value depending on the version or use LATEST-->
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version><!--change this value depending on the version-->
<type>jar</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.0</version>
<type>maven-plugin</type>
</dependency>
</dependencies>
</project>
Note that maven-shade-plugin is referenced as a dependency and included as an plugin for the build. I'm compiling the project through the Eclipse IDE with the preinstalled maven integration like the following mvn-install.
The following Error messages will be given in the Console:
[INFO] --------------------------------[ jar ]---------------------------------
[WARNING] The POM for org.apache.maven.plugins:maven-shade-plugin:jar:3.2 is missing, no dependency information available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.195 s
[INFO] Finished at: 2018-09-30T09:48:43+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-shade-plugin:3.2 or one of its dependencies could not be resolved: Failure to find org.apache.maven.plugins:maven-shade-plugin:jar:3.2 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
To be honest, I'm a little overchallenged because it's my first attempt to use Maven. There are plenty of questions and answers here and all over the internet, but nothing seems to fit my situation.
I am not using Eclipse, but instead invoking maven from commandline - and for making the thing work, I would recommend the same to you.
Once you have maven build working, you can try the next challenge with Eclipse, which should not be hard anyway.
Your pom needs following fixes:
remove the shade plugin from dependencies; dependencies should contain only artifacts that are needed for javac to compile the project, in your case also artifacts needed in runtime, but never (with very few exceptions) maven tooling artifacts
fix the shade plugin version to 3.2.0 (you have it correctly in your dependency, but not in plugin declaration)
Then try mvn clean install on commandline (make sure you are in the same directory where your pom file exists) and it should work - at least it did for me.

unable to change junit version from 3.8.1 to 4.11 using maven on eclipse kepler

i created a simple maven java project on eclipse kepler.
I wrote a simple JUnit (version 4) test. I can run it from Eclipse, but not from the pom.xml (alt-click, Run as, Maven Test). I suppose I need to tell Maven to search for that class, but I just don't know how.
with default junit version 3.8.1, mvn test works fine but failing on only eclipse when changed to 4.11. this worked on command promt.
my pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.seleniumsimplified.webdriver</groupId>
<artifactId>webdriverbasics</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>webdriverbasics</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
error :
Downloading: http://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-junit4/2.10/surefire-junit4-2.10.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.819s
[INFO] Finished at: Tue Feb 02 19:25:36 IST 2016
[INFO] Final Memory: 12M/210M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.10:test (default-test) on project webdriverbasics: Unable to generate classpath: org.apache.maven.artifact.resolver.ArtifactResolutionException: Unable to get dependency information for org.apache.maven.surefire:surefire-junit4:jar:2.10: Failed to retrieve POM for org.apache.maven.surefire:surefire-junit4:jar:2.10: Could not transfer artifact org.apache.maven.surefire:surefire-junit4:pom:2.10 from/to central (http://repo.maven.apache.org/maven2): null to http://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-junit4/2.10/surefire-junit4-2.10.pom
[ERROR] org.apache.maven.surefire:surefire-junit4:jar:2.10
[ERROR]
[ERROR] from the specified remote repositories:
[ERROR] central (http://repo.maven.apache.org/maven2, releases=true, snapshots=false)
[ERROR] Path to dependency:
[ERROR] 1) dummy:dummy:jar:1.0: UnresolvedAddressException
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
workarounds that i tried :
1) tried adding <build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>
2) changed test file name from AppTest.java to TestApp.java
3) commented <scope>test</test>
4) selected Upgrade Maven project
but nothing is helping. i am new to Maven.
please guide. thanks in advance :)
By definition
pluginManagement: is an element that is seen along side plugins. Plugin Management contains plugin elements in much the same way, except that rather than configuring plugin information for this particular project build, it is intended to configure project builds that inherit from this one.
But you need to configure plug-in in current project, so
<project ...
...
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.18.1</version>
</dependency>
</dependencies>
</plugin>
...
</plugins>
...
<build>
</project>
Specifying the version for surefire-junit is not required - maven has some rules around it, but I prefer the clarity.
You still need a <scope>test</test> for junit dependency though.

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile in Spring

I am working on a Spring security project in STS. I am trying to build my project but I am getting the following exception.
Error log,
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.288 s
[INFO] Finished at: 2015-11-27T09:41:59+05:30
[INFO] Final Memory: 21M/227M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project spring-data-rest-security: Fatal error compiling: invalid target release: 1.8 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
My pom.xml file is
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-data-rest-security</artifactId>
<name>Spring Data REST - Security Example</name>
<parent>
<groupId>org.springframework.data.examples</groupId>
<artifactId>spring-data-rest-examples</artifactId>
<version>1.0.0.BUILD-SNAPSHOT</version>
</parent>
<properties>
<spring-security.version>4.0.2.RELEASE</spring-security.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
</dependency>
</dependencies>
</project>
I read answers of similar issues but none of them seem to work. Kindly help me out.
Do this in your cmd line C:\mvn>echo %JAVA_HOME% if the output is something like C:\Program Files\Java\jdk1.X... where X is anything but number 8, then you are trying to build it with wrong jdk version.
Install jdk 1.8 and make sure your %JAVA_HOME points to that or drop the target release to 1.X.
That would not help. I had the same issues and my %JAVA_HOME% pointed to jdk1.8.0_45. I also had java version 1.8 language version 8 in IntelliJ "Project Settings >> Build, Execution, Deploy >> Module Compiler Version" and "Project Structure >> Modules >> Source". However this did not fix my issue.
As per this apache resource, it looks like that default source setting after Maven 3.0 is 1.5 that needs a manual override using pom.xml. I explicitly provided source and targer release to 1.8 in my pom.xml and it DID fix my issue.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>

maven compilation fails because unavailable dependency

I'm trying to run java program with maven but when i compiled using the command mvn -U compile
he shows me the following error
[root#onePK-EFT1 tutorials]# mvn -U compile
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building onePK Java Tutorials 0.6.0.5
[INFO] ------------------------------------------------------------------------
Downloading: http://repo.maven.apache.org/maven2/com/cisco/onep/libonep-core-rel
/0.6.0.5/libonep-core-rel-0.6.0.5.pom
[WARNING] The POM for com.cisco.onep:libonep-core-rel:jar:0.6.0.5 is missing, no
dependency information available
Downloading: http://repo.maven.apache.org/maven2/com/cisco/onep/libonep-
core-rel/0.6.0.5/libonep-core-rel-0.6.0.5.jar
[INFO] ------------------------------------------------------------------------
INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.517s
[INFO] Finished at: Tue Jul 09 07:28:28 PDT 2013
[INFO] Final Memory: 3M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project java-tutorials: Could not resolve
dependencies for project com.cisco.onep:java-tutorials:jar:0.6.0.5: Could not find
artifact com.cisco.onep:libonep-core-rel:jar:0.6.0.5 in central
(http://repo.maven.apache.org/maven2) -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read
the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN
/DependencyResolutionException
and this is my pom.xml file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org
/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.cisco.onep</groupId>
<artifactId>hello-network-app</artifactId>
<version>0.1-SNAPSHOT</version>
<name>The onePK Hello Network Example Application</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<forkMode>always</forkMode>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.8</version>
<configuration>
<downloadSources>true</downloadSources>
<downloadJavadocs>true</downloadJavadocs>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>com.cisco.onep</groupId>
<artifactId>libonep-core-rel</artifactId>
<version>0.6.0.5</version>
</dependency>
<dependency>
<groupId>org.apache.thrift</groupId>
<artifactId>libthrift</artifactId>
<version>0.6.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.1</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
</dependency>
</dependencies>
<developers>
<developer>
<name>onePK Team</name>
<email>onepk-feedback#cisco.com</email>
<organization>Cisco.com</organization>
</developer>
</developers>
I think it's because he can't find libonep-core-rel.jar which i have it included
please any help
The simple solution is to use the appropriate maven repository for the artifacts com.cisco.onep* which are not located in Maven central.
As an immediate solution, but not a recommendation, you can use system dependencies to resolve artifacts on your local filesystem.
As #khmarbaise implied, try to publish those corporate artifacts to your corporate Maven repository (Nexus, Artifactory, Archiva, etc.), even an FTP/HTTP server would do...
Once you publish those corporate artifacts to your "corporate" repository(hopefully it's already in place), you just need a new repository declaration in your Maven POM.

Findbugs and Maven 3.x

Has anyone managed to get findbugs 2.3.1, 2.3.2-SNAPSHOT or 2.4-SNAPSHOT to work with a Maven 3.x project?
I always end up with:
[ERROR] Failed to execute goal
org.codehaus.mojo:findbugs-maven-plugin:2.4-SNAPSHOT:findbugs
(default-cli) on project cular-db: An
error has occurred in FindBugs Report
report generation. Could not find
matching constructor for:
org.codehaus.mojo.findbugs.FindbugsReportGenerator(org.codehaus.doxia.module.xhtml.XhtmlSink,
java.util.PropertyResourceBundle,
java.io.File,
org.apache.maven.doxia.tools.DefaultSiteTool)
I tried all the latest possible versions. It does not matter if I use findbugs:fingbugs or only the site goal. It is specified with
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>${findbugs.version}</version>
<configuration>
<threshold>High</threshold>
<effort>Default</effort>
</configuration>
</plugin>
On 2011/03/20, Findbugs 2.3.2 was been released, with Maven 3 support.
Announcement
Release Notes
This means that you should be able to use the latest non-snapshot version of the plugin (version 2.3.2 or later) with Maven 3.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.3.2</version>
</plugin>
As I said in the comment you should use findbugs version 2.3.2-SNAPSHOT with Maven 3. I started a project with using maven-quickstart-archetype and executed mvn findbugs:findbugs and the reports are generated successfully without any problems.
[INFO] ****** FindBugsMojo execute *******
[INFO] Inside canGenerateReport..... false
[INFO] Inside canGenerateReport..... skip false, classFilesDirectory.exists() true
[INFO] canGenerate is true
[INFO] ****** FindBugsMojo executeReport *******
[INFO] Temp File is /home/umut/noinstall/dummy/target/findbugsTemp.xml
[INFO] Fork Value is true
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2:56.550s
[INFO] Finished at: Mon Jan 10 11:05:13 PST 2011
[INFO] Final Memory: 9M/55M
[INFO] ------------------------------------------------------------------------
The following is the my pom.xml.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.dummy</groupId>
<artifactId>dummy</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>dummy</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<pluginRepositories>
<pluginRepository>
<id>codehaus.snapshots</id>
<url>http://snapshots.repository.codehaus.org</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.3.2-SNAPSHOT</version>
<configuration>
<threshold>High</threshold>
<effort>Default</effort>
</configuration>
</plugin>
</plugins>
</build>
</project>
BTW you are right it is not working with 2.3.1 but I did not try 2.4-SNAPSHOT.
Just a short note for anyone with the same problem: My experience is that it does work with 2.3.2-SNAPSHOT but not with 2.4-SNAPSHOT. (2.4-SNAPSHOT causes the same error.)

Resources