I managed to run findbugs within my maven build process, and I also have findbugs configured in eclipse. However when running in Eclipse and Maven I get different bugs, and I can't seem to find a setting, where the number of bugs matches in Eclipse and Maven.
My Maven settings is like this:
<version>2.5.2</version>
<configuration>
<failOnError>false</failOnError>
<threshold>Normal</threshold>
<effort>Default</effort>
<xmlOutput>true</xmlOutput>
<findbugsXmlOutput>true</findbugsXmlOutput>
<findbugsXmlWithMessages>true</findbugsXmlWithMessages>
</configuration>
And in Eclipse I have:
Findbugs Version: 2.0.1
Analysis Effort: Default
Minimum Rank to report: 20
Minimum Confidence to Report: Medium
Reported categories: All
With those settings, I get more bugs in Eclipse. My main problem is, that I can't even match the different settings between maven and eclipse.
You could try using m2e-code-quality, which includes an m2eclipse 'connector' that should ensure your Eclipse FindBugs configuration matches the configuration specified in your pom.
I'm having exactly the same problem. There is a mismatch between settings available in Eclipse (using FindBugs 2.0.1) and the Maven plugin (version 2.5.2).
One setting that is missing from the Maven plugin is 'confidence'.
Using another piece of software to match the configurations doesn't address the issue because the Eclipse matching just highlights a problem. I want certain bugs reported from the Maven build completely independently of Eclipse that aren't being reported. It just happens that it is possible to have them reported in Eclipse.
Related
Problem Description
I'm working with a collection of old projects from defects4j. My problem now is that since I want to combine those projects with a newer maven plugin, a regression test tool, there are some issue with the maven surefire plugin version.
In the pom.xml that come along with the projects, there are no specifications of surefire version:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<executions>
<execution>
<id>plain</id>
<configuration>
<includes>
<include>**/*Test.java</include>
</includes>
<runOrder>random</runOrder>
</configuration>
</execution>
</executions>
</plugin>
However, the regression tool (made into a maven plugin), require surefire version of 2.14 and above. So I get error like this:
[ERROR] Failed to execute goal edu.illinois:starts-maven-plugin:1.4-SNAPSHOT:select (default-cli) on project commons-lang: Unsupported Surefire version: 2.12.4. Use version 2.13 and above
Efforts Done
I checked several stackoverflow posts, and they talked about the effective pom. When I run mvn help:effective-pom, I can see that the version of surefire used is
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
Question
Since the project collection in defects4j does not specify surefire version in their pom.xml, is there a way to specify the surefire version used to 2.14 or above from command line? I want to prevent from manually editing the pom every time.
Update
by running mvn dependency:resolve-plugins, i get
Plugin Resolved: maven-surefire-plugin-2.12.4.jar
So it seems to me that somehow maven use 2.12.4 as a default. The reason maybe that I used this version previously. How do I fix this?
Without modifying the pom manually?
Any advice will be welcomed!
Update:
Problem solved by editing maven's super pom.
Maven takes the newest version from the repository if there was no version fixed in your POM, parent POM or the super POM (from which every Maven project inherits).
It is best practise to fix a version "manually" in the POM. The best place for this is a parent POM from which the projects inherit (this means, only one place to change).
You cannot just supply a version from command line. Unless you do some tricks like putting <version>${surefire.version}</version> into the plugin definition and set this property from command line.
I'm 4+ years removed from working with poms so don't remember everything, but consider a couple of things.
First, since the pom you show isn't specifying the version of surefire to use I don't think that the 2.12.4 version can be coming from that directly. Try getting a dependency tree to see where things are coming from. Try How can you display the Maven dependency tree for the *plugins* in your project? for that and a few other suggestions.
Second, I think I recall that in your own pom you should be able to specify the version of plugin to associate with a dependency that doesn't specify one. You'll have to research that option yourself.
I think your best bet is the dependency tree to find what's using what and where things are coming from. If you get the tree and still can't figure out what to do try adding the tree output to your question. (You can edit out parts that are proprietary, or clearly unrelated.)
I am a new programmer to a maven web project, and m2e in eclipse gives an error that others tell me to ignore but I would like to fix. A clean and rebuild in eclipse marks the <execution> tag as an error, and hovering over it shows the following:
Could not process schema:
projectXsdOne.xsd (org.codehaus.mojo:jaxb2-maven-plugin:1.2:xjc:JAXBStringifiedGeneration:generate-sources)
org.apache.maven.plugin.MojoExecutionException: Could not process schema:
projectXsdOne.xsd
at org.codehaus.mojo.jaxb2.XjcMojo.execute(XjcMojo.java:313)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
at org.eclipse.m2e.core.internal.embedder.MavenImpl.execute(MavenImpl.java:331)
at org.eclipse.m2e.core.internal.embedder.MavenImpl$11.call(MavenImpl.java:1362)
There was one post about a very similar error that the poster originally fixed by adding <xmlSchema> and <wsdl> tags of false and true, respectively, to the <configuration> portion of the <execution> tag, but that didn't eliminate my error. The web application does seem to run, but I hate having an error "on the boards" and just ignoring it. Does anyone know what else I might try to fix it?
I'm running eclipse photon, m2e 1.9.0 (configured to run "embedded"), java JDK 1.8.0_51, Windows 10.
There exists multiple JAXB plugins for Maven.
Have a look at: difference-of-maven-jaxb-plugins
The different plugins varies in age and activity, and the support for them by the m2e plugin have historically not been that great.
You can try some of the other plugins, or maybe try to exchange it for another plugin like e.g. The CXF XJC Maven Plugin, and see if it makes a difference.
Otherwise you will probably have to accept the fact that Maven support in Eclipse is not complete, and ignore the error or ignore the plugin goal.
In ma maven project I have something like below in pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<systemPropertyVariables>
<environment>DEV</environment>
</systemPropertyVariables>
</configuration>
</plugin>
And of course I use this property in my Java code.
However my problem is that if I run my tests in Eclipse then this property is not read from pom file and finally my 'environment' property stays empty.
If I run my tests from console adding ' -Denvironment=DEV ' then it's ok.
My question is how to configure Eclipse so that it sees my 'environment' property as it is while I run it from console?
Can anyone help please?
I cannot find solution by myself...
Thanks
This is a common misunderstanding of how Maven works.
The core of Maven defines a build lifecycle, essentially a state machine that tells it how to transition to a given phase. For example, if you run:
mvn test-compile
Maven knows that it first needs to through a series of steps (states) before it can execute test-compile. Each of these states may or may not have a plugin attached to it that Maven will execute, given how the POM is written. So essentially, Maven itself doesn't do any resource copying, compiling, testing, packaging, etc. All of these tasks are delegated to plugins.
When you import a Maven project into Eclipse, it will provide its own mapping of plugins, for various reasons. Some of these (like compiling) will make sense for the IDE to do, it will use its own plugins to do the job. Other phases that is not part of what Eclipse normally does (such as packaging) will have no mapping and thus no plugin to execute.
Running JUnit tests is not what Eclipse does normally as part of the build, so that's why you run JUnit tests manually (right-click test class > Run as > JUnit test). Eclipse simply ignores the surefire plugin since it uses its own internal JUnit runner to run the tests and as such it doesn't pick up the configuration from the surefire plugin.
I have no doubt that this could be made to work in Eclipse but at the time of writing, it simply doesn't. Have you tried IntelliJ by any chance?
However, since one could argue that Eclipse always is in "DEV" mode, would a suitable workaround be that you statically set the system property on the JRE in Eclipse?
Like so:
Window > Preferences > Java > Installed JREs > select your JRE >
Edit... > Default VM arguments: -DDEV
I am using Java 8 for my JRE in Eclipse Luna with with the m2e Maven plugin. I see this warning as soon as I create a Maven project: Build path specifies execution environment J2SE-1.5. There are no JREs installed in the workspace that are strictly compatible with this environment. I see lots of older advice on this site on how to deal with this error, but nothing related to Java 8. I also that Oracle says J2SE was deprecated in 2008. The most promising answer I have found thus far comes from #Pascal Thivent here:
Warning - Build path specifies execution environment J2SE-1.4
But these instructions no longer seem to be relevant for Luna:
Eclipse project Properties > Maven > Update Project Configuration
I only see "Lifecycle mapping" under Maven.
Can someone please explain (1) what this error means (2) if it is still a worry, given that J2SE-1.5 seems to have been deprecated (3) how to best fix it in Luna?
This error is because the project pom file is instructing maven to compile against java 1.5.
It is best to compile and test to a current java version. In your case java 8.
I am unsure how to fix it inside the eclipse IDE, but the project pom file can be edited to include the compile version as follows:
<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>
I am trying to build the openNMS in eclipse helios using maven. After importing the source using "import existing maven project" i get the around 10k errors. Also i have some error in pom.xml itself, i thought fixing it could reduce the no of errors. The error in pom.xml is
maven-resources-plugin prior to 2.4 is not supported by m2e. Use maven-resources-plugin version 2.4 or later.
Iam referring to http://www.opennms.org/wiki/Eclipse_and_OpenNMS for building the openNMS
Iam using maven available at http://www.eclipse.org/m2e/download/
It would help if you told us which versions of Eclipse & m2eclipse you are using, and which version of OpenNMS you are trying to build.
If all else fails, you should be able to run the Maven build from the command line. In my experience, command line builds are always more reliable and predictable.
Also make sure that you are using the instructions that match the version of OpenNMS you are trying to build.
I have run the command mvn eclipse:eclipse from cmd line which downloaded the libraries in repository then i tried to import the same source directory into eclipse only to find 10k errors
That's not what I meant.
Get out of eclipse.
Get a command prompt.
Create a new directory somewhere the is not in your eclipse workspace.
Checkout the source code.
From the command prompt run "mvn install".
And you haven't answered the questions I asked above. If you don't want to answer, fine ... but don't expect us to be able to help you.
... and i get the error as Build Failure [INFO] There are test failures.
What has happened is that the unit tests have failed, presumably because something needs to be set up to enable testing. (Perhaps, the tests are trying to talk to a database?)
There are two solutions:
Find out what is causing the tests to fail, and fix it. The surefire reports may give you some clues, and there may be some developer documentation on the test setup.
Turn off the tests by adding -Dmaven.test.skip=true to the mvn command line; see this page.
It would also be a good idea to read the Maven documentation if you haven't done so already.
You cannot combine eclipse:eclipse with the m2eclipse support. You cannot use m2eclipse with a project that uses the old resource plugin.
If you want to use eclipse:eclipse, you must use NOT use the 'maven' import from eclipse. Use just 'import existing project'. If you want to use m2eclipse, don't use eclipse:eclipse.
I had this issue with the PDFBox source, with the parent pom for that project. I put this in the pdfbox/pom.xml (just to get it to compile in eclipse at lease, which is the only thing I wanted):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4</version>
<executions>
<!-- had a process goal here that i removed because it was not compatible -->
</executions>
</plugin>