Eclipse cannot run Spock tests with source folder disappearing - eclipse

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?

Related

How to run Junit Test (Java) from VSCode

I have an Eclipse Maven project that uses selenium and Junit to run some tests.
It currently works fine when I run it as Junit Test.
I want to try out the ide from visual studio code but I can't get it to work. I am getting the following message:
ConfigError: The project 'CopaSelfWebCheckIn' is not a valid java project.
I know there is no main folder. I rather run it from where it is right now.
Can someone explain me how to set this up. Thanks.
Make sure you have all the required java extension installed on your VS-Code
Mainly
Test Runner for Java
Language Support for Java(TM) by Red Hat
Maven for Java (if you have any dependencies)
Debugger for Java
Project Manager for Java
All these extensions are packed with a single extension Extension Pack for Java
if you have installed proper dependencies and extensions your vscode will look similar to the below picture

Java 9 Eclipse does not include Maven dependencies

I downloaded the Spring Tool Suite which uses the latest Eclipse (4.7.1a) and imported the code from https://github.com/ConSol/java9-modules-maven-junit-example
This project compiles great from the command line, but in Eclipse, it refuses to take the Maven dependencies into account. On the classpath, I see the maven dependencies specified and everything looks fine, but I still see those errors:
Any help would be appreciated

Eclipse running lift project (project configuration issues)

Trying to get a lift project to run on windows, I've installed maven on my computer, then tried to use
mvn archetype:generate from cmd, then chose the lift basic one , but it always failed on the jetty:run part. Before that, I had to change a lot of the pom.xml file to even get a successful build (since the tutorial I was using was obsolete and it couldn't find the dependencies).
So I've decided to try with the eclipse plugin, thinking it should be easier.
I've installed the maven plugin for eclipse and created a project with the lift archetype.
The project was succesfully created, but I have all kinds of errors in the editor for missing ; and so on (I have scala ide installed on eclipse also and creating a normal scala project works and compiles/runs fine). I have also tried to include the scala-library.jar in the buildpath, with no change.
The odd part is that I can run the cmd and go to the project folder, then run mvn jetty:run and it will actually work (?!) Trying to run in eclipse with jetty:run as goal will give me ClassNotFoundException on the HelloWorld snippet.
So what might be wrong with my settings?
UPDATE: no luck whatsoever, after trying 3 different eclipse versions, installing the maven for scala plugin and following every tutorial I could find. It just simply feels all is outdated on the instructions:
this is how it looks after I include the scala libraries for eclipse on every project (after I create it from an archetype):
is this "mvn archetype:generate" up to date? I don't know if anybody guarantees it will work at all..
Anyway, the default way to at least try Lift and see it working is the following: https://github.com/lift/lift_25_sbt
It uses "Simple Build Tool" instead of maven, but maven should work, too. Also, you can easily read "build.sbt" to get all the dependencies.
Plugins for creating eclipse/intellij project definitions are included. (See the README of the demo project.)
The target to create eclipse project is "eclipse" or "eclipse with-sources=true".
The target to launch the app is "container:start".

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.