I got a hudson job which analyses the sources with findbugs. I'm currently using filters to surpress the warings but it would be better if I could surpress them directly in code.
I've seen that there is a findbugs plugin to analyse the code in eclipse and add annotations there. Do I need anything to make the annotations from eclipse work in hudson? The thing is I dont want to add FindBugs to the classpath of the projects... Is the eclipse plugin enouth and if yes what do I have to do to make it work in the hudson job.
The FindBugs annotation for suppressing false positives is #edu.umd.cs.findbugs.annotations.SuppressFBWarnings.
In order to use the FindBugs annotations, the following two JAR files must be on the Classpath:
annotations-x.x.x.jar (replace 'x' with FindBugs version number)
jsr305.jar
These files must be on the classpath of the process that performs the FindBugs analysis. They do not need to be on the classpath in production. In other words, you must add them to the Eclipse classpath and probably also in your build scripts (so that analysis works in Hudson). However, you do not need to deploy the files into production.
If you don't want to modify the projects' classpath, then it will probably not work in Hudson. It should work in Eclipse, although you will be required to put them in some global classpath, which is kinda dirty.
Related
I've started working on a large project where the IntelliJ environment has already been set up. The environment includes JUnit, and I can successfully run unit tests. I've seen screens where I can specify the usage of JUnit 3 or JUnit 4, but how can I determine which specific JUnit is being used to run my tests, e.g., JUnit 4.11?
I have already tried "Open Module Settings". When I look at the "Dependencies" tab, I don't see anything relating to JUnit, although I can run JUnit tests.
Which jar is used?
When you run JUnit from IntelliJ, the very first line of the console output displays your classpath. You can use Ctrl+F to find any "junit" references.
junit-rt.jar is a helper library that JetBrains might have written. By opening the jar as an archive with 7-zip, you will find that the only package inside it is under com.intellij
According to Java: Which of multiple resources on classpath JVM takes? the first reference to junit.jar is the one you will use.
What version is that jar?
Once you know which jar is being used, there are a number of ways to find the version. One is to use this code taken from https://stackoverflow.com/a/16729507/1405720
import junit.runner.Version;
System.out.println("JUnit version is: " + Version.id());
Another method might be to open up the jar as an archive and see if you can figure it out from there.
If you are looking for the JUnit libraries that are shipped with IntelliJ have a look at the corresponding jars in the lib/ directory of your Intellij IDEA installation.
For more information on this have a look at the online documention:
http://www.jetbrains.com/idea/webhelp/configuring-testing-libraries.html
http://www.jetbrains.com/idea/webhelp/testing.html
I'm developing a Solr plugin and using the Solr test-framework I place a test SOLR_HOME dir under test/resources with /conf/ and /lib . Now the framework inistantiates a SolrCore and loads my plugin from /lib. Not an issue to output the jar of the plugin to /lib, but the issue is that the plugin is not yet available since it still needs to past the test (chicken and the egg).
How do you recommend solving this? I see those options:
Create another project for the tests with a dependency on the plugin, and in it run the tests. Simple enough, but how do I ensure that everytime the plugin is built also the tests of this other project is built? The point of the automated tests at every build is to having a new plugin jar which breaks the tests.
In dp4j pom.xml I build the project on 2 phases, in the 1st I <include> only the annotation processors while in the other I compile the tests which rely on the annotation processors compiled in the eariler phase.
I'm in favor of 2 since copy-pasting the configuration doesn't seem a bad option, and makes it seem less complicated than it probably is. I don't remember if I had asked about it here - what do you recommend? Any other case studies /working code to look at?
there's a 3rd. most probably best solution ~ do nothing!
I was under the impression that the Solr Testframework need to load my plugin from /lib but apparently it doesn't need to, it can load it from test-classes, all on its own!
I'd like to run my JUnit tests in JMeter. Using maven-jar-plugin I can create a jar with my tests in order to put it inside the JMeter's classpath ($JMETER_HOME/lib/junit). The problem is that my tests have a lot of dependencies that Maven2 doesn't put into the jar, including the main classes of the project, classes from other projects and external libraries. How can I do this?
You can use the fatjar plugin.
As iwein has mentioned, you may use the maven-fatjar-plugin which will put all the dependent JAR's inside of your JAR artifact and create the appropriate MANIFEST entries to include them on your classpath.
Another option is that you can use the maven-shade-plugin which will simply take all of the ".class" files out of the dependecy JARs and include them directly in your JAR. This is called a UBER-JAR. There are a couple of reasons which I prefer this approach:
This often leads to slightly smaller JARs
I have other plugins which already manipulate the MANIFEST (including the Classpath property) and I don't want to chance having an incorrect manifest being generated.
Creating an UBER-JAR is just too good to pass up ;)
Summary: I'm looking for a way to instruct maven to search for dependencies in target/classes instead of jar in the local repository
Say I have 2 modules, A and B where A depends on B. Both are listed in a module S. Normally I need to run 'mvn install' in S. I'm looking for a way to run 'mvn compile' so that when A is compiled its classpath will contain ../B/target/classes instead of ~/.m2/repository/com/company/b/1.0/b-1.0.jar.
(my reason is so that i can have continous compilation without the need to go through packaing and installation, or, more exactly, use 'mvn scala:cc' on multiple modules)
I don't think that this is possible without horrible hacking, this is just not how maven works. Maven uses binary dependencies and needs a local repository to resolve them. So, the maven way to handle this is to launch a reactor build on all modules. Just in case, have a look at Maven Tips and Tricks: Advanced Reactor Options.
But, during development, can't you just import all your projects in your IDE and use "project references" (i.e. configure your projects to depend on source code instead of a JAR) like most Java developers are doing? This is the common approach to avoid having to install an artifact to "see" the modifications.
If this is not possible and if you really don't want to install artifacts into your local repository, then you'll have to move your code into a unique module.
i know this is annoying. which helped me here is definitely IDE support. eclipse and IntelliJ are clever to collect all dependencies once a maven-project import is done. even cross module dependencies are compiled live.
Is it possible to specify the classes location like you can in the findbugs ant task?
or is there another way to exclude a directory of class files
(we compile our test classes to a different directory and don't want to use findbugs on those)
P.V. Goddijn
After looking through te source of the Eclipse Findbugs plug-in i found its currently impossible to do this (without modifying the Findbugs plug-in).
the plug-in does either a findbugs run over a single class file after a change has been made or a complete run over all the classes as defined by the eclipse project.