Run jacoco report without Maven or Gradle - eclipse

We want to our Jacoco code coverage in some of our Java projects. Unfortunately, their maven and gradle configurations do not include generating Jacoco test reports.
There are 40+ Java projects and I don't have the time to fix all their pom.xml or gradle build files to add jacoco test coverage reports. What is the fastest way to scan them for code coverage? is there a way do to this without the need for modifying pom.xml or gradle build files.
I am using Eclipse IDE

Have you tried to add EclEmma (from Help Eclipse Marketplace and search for EclEmma)?
After the installation of EclEmma:
the context menu of a project also contains a Coverage As entry
And besides the debug button in the main toolbar will also be another button for running java code with code coverage analysis.
Once a program is run with code coverage a Coverage View will show up in the Eclipse IDE.
(PS recently released EclEmma 3.1.5 supports recently released Java 17 thanks to JaCoCo 0.8.7)

Related

Eclipse gradle integration

Do eclipse project->build, project-build all, project->clean commands work with gradle projects? If they do, which gradle tasks do they invoke and where is console output.
Thank you!
--- Vadim
An eclipse project build/clean does normally use the integrated eclipse java compiler instead of gradle build system. So your build output is inside /bin folder. The eclipse internal build is very fast because of the eclipse delta compiler etc.
When you build your projects in gradle normally /build/** folders are used for gradle output results.
So you got "two worlds" / two output folders. This is important to understand when you are using console parallel with eclipse. Some gradle integrations for eclipse try to change this default behaviour and are adding special Builders to call gradle for build/clean etc. but - in my opinion - this will increase build time too much when your projects are growing bigger.
Instead of buildship you could also use EGradle IDE (https://marketplace.eclipse.org/content/egradle-ide).
Its lightweight, fast and compfortable. You can very simple call tasks in this eclipse integration for gradle. More information can be found at https://github.com/de-jcup/egradle/wiki/Help

Eclipse cannot run Spock tests with source folder disappearing

I've encountered a very curious case about Eclipse and Spock tests.
I have Eclipse 4.5.2 (Build id: 20160218-0600) with Groovy compilers plugins installed, Groovy-Eclipse M2E Integration and Groovy-Eclipse Feature, all in version: 2.9.2.xx-201604081629-e45.
In this Eclipse I have a maven project configured to compile and run Spock tests. In Eclipse I have src/test/groovy folder configured as a source folder and it is holding my spock tests. Both maven and Eclipse can run the tests just fine.
Recently my friend has had a problem with the same setup, so I tried to reproduce it. And now I have the same Eclipse 4.5.2 (Build id: 20160218-0600) with Groovy plugin (and this is the weird part, I used the same update site for these plugins but the build version is different, it is: 2.9.2.xx-201607251752-e45). I imported the same maven project, however, when I try to run Spock tests the curious thing happens: the src/test/groovy source folder dissappears from the project and on the console I can see ClassNotFoundException with the name of the Spock test class. Here is a short summary how it looks like:
We tried the same also in Eclipse Neon and Spring STS and we have the same result. (In IntelliJ the same project runs just fine).
I'm starting ti thing that this may be related to the Groovy plugins, which might have got changed in the latest build and a bug was introduced. However, I hope I am mistaken.
Any thoughts?

Building a groovy project in eclipse

I have imported a groovy project in my eclipse and I have installed the groovy plugins in my eclipse too. now, I want to build my project(which is a groovy-gradle plugin) in eclipse and use it further. I have gone through a link http://www.selikoff.net/2013/01/11/creating-a-groovy-project-with-gradle-in-eclipse/ but I don't understand how to build my project. I don't get build option.
Install the gradle plugins.
Some tasks will be available in the tasks Window.
Right click on build task and run it.

How eclipse maven and ant work together?

I made simple maven project and I opened it with Eclipse. I have installed maven plugin for Eclipse. I'm interested in following:
How Eclipse compiles code when I hit save on my source code (does it use configuration from ant or maven or something else)?
When I run tests from JUnit plugin for Eclipse those Eclipse calls mvn test (I suppose not, but what is then happening exactly)?
Is it possible that maven does the build successfully but Eclipse is
showing errors in code?
The Maven Integration for Eclipse makes it easier to edit POM files, allows you to execute maven builds from within Eclipse and to help with dependency management. It doesn't actually compile your code (unless of course you execute a maven build from within Eclipse). The main help is with the dependency management and writing the .classpath file of your project within Eclipse.
To try and answer your questions:
Eclipse uses its standard mechanism to compile code. With a standard eclipse for java developers your project will have a Java Project nature and Eclipse will then use the Java Development Tools - JDT to compile the code. (Internally this uses an incremental builder to build the code http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Fguide%2FresAdv_builders.htm). What source files it will compile and where it will place the resultant .class files is configured in your project's Java Build Path (which I am guessing the maven plugin may well configure for you)
JUnit support is part of the Java Development Tools as well.
It is possible that maven will successfully build a project outside of Eclipse, but that the same project will show errors within Eclipse. This is usually down to classpath errors (dependencies defined in the project's POM not being added to the classpath in Eclipse). If you are using the maven plugin with eclipse this probably shouldn't happen. If you are not using the maven plugin within eclipse you can execute maven eclipse:eclipse to have maven update the Eclipse .classpath file of the project which should then fix any of these problems.

JUnit4 plug-in and build path for junit.jar in Eclipse

I've got Eclipse (Helios) installed along with the JUnit3, JUnit4 and Java Development Tools plug-ins for some Android development.
I've created some unit tests but the only way they run (without throwing a java.lang.ClassNotFoundException for org.junit.Test) is if I add an External JAR to the test project build path for junit.jar from the normal JUnit install I have.
Why isn't Eclipse able to reference the junit.jar from the JUnit4 plugin which I can see when I expand the library in Package Explorer? In fact I can remove the JUnit4 Library from the test project leaving just the External JAR and the tests run fine.
I tried adding the path to the plug-in folder to my CLASSPATH system environment variable as I had to setting up JUnit but this made no difference. The plugin path is created as a JUNIT_HOME Classpath Variable in Eclipse but this is labeled as deprecated.
Do I even need the JUnit3 and JUnit4 plugins as these must have come with the distro I used?
In any new project, the sure way I add the required Junit deps (with the exception of declaring them in maven) is through creating the test using the in-built Junit test shortcut.
Go to New > Junit Test Case. If the right deps are not on the project classpath, eclipse will pull them in automatically.