I'm using Eclipse and working on a J2EE project. We are trying to write Groovy/Spock tests for unit testing. The project is a Maven project and added Groovy nature to it. The problem is If I edit any of the Groovy test classes, It's doesn't get compiled. So running a test as Junit is not picking up the latest changes. I have to run a Maven build in order to pickup the recent changes test class.
My setup,
Groovy compiler 2.4
Installed Groovy-Eclipse plugin
Added Groovy nature to the project
Checked another question, it didn't help much
Another Question
Un checked, the following fixed the issue.
Preferences > Groovy > compiler > Enable script Folder support
Related
I'm using Eclipse Neon2 (4.6.2). I'm trying to use Spock Framework (http://spockframework.org/). Here's what I did so far:
Added the Groovy plugin to Eclipse. Since in the Eclipse Market there's no Groovy plug-in for this specific version of Eclipse (Neon2 V4.6.2), i followed the instructions mentioned here and specifically in the 'How To Install' section: https://github.com/groovy/groovy-eclipse/wiki
I right clicked on my Eclipse Project and converted it to a Groovy project.
I installed Spock Plugin 2.13 by Jspresso from the Eclipse Marketplace.
I right-clicked on my Eclipse project and added the 'Spock Nature' to it.
At this stage I'm able to create Groovy classes but the IDE still cannot identify Spock syntax. For example when extending Spock's Specification class, we get a class not found or package not found error.
I realize how this can be much easier using Maven or Gradle, but that's a long story now and I'm just trying to find out what i'm doing wrong so far.
Thanks.
Did you add Spock as a dependency of your project? It needs to be on the classpath when compiling your tests.
I have some questions about the m2e-Eclipse-Plugin. Version of m2e is 1.6 and the version of Eclipse is 4.5 (Mars).
In my Eclipse-workspace I have a Maven-Project (Java web application) that is deployed on a local Tomcat server.
I really would like to know how m2e-Plugin and Maven work together. If I change a Java-file and save it, the corresponding Class-file in the mvn-target-directory is immediately updated.
Is this compilation done by the default Java-Builder in Eclipse or is it done by Maven ? (i.e. the mvn-compile-plugin does the compilation). If the latter case is true, how is the compile-goal executed ?
Can I configure which mvn-goals are executed if a Java-file is changed and saved? If the compilation is done by the Java Builder, how does the Builder know that it has to copy the compiled
file to the mvn-target-directory
?
I found two posts:
How do Java and Maven builders work together in eclipse?
How do I start Maven "compile" goal on save in Eclipse?
that deal with similar issues. But most of the proposed configuration settings didn't work in my Eclipse.
The compilation in your scenario is done by the Eclipse compiler and not by Maven nor the maven-compiler-plugin. M2E Maps all things to Eclipse internals to handle most of the things needed to work inside Eclipse.
During an initial import of a Maven project into Eclipse using M2E (creating .project/.classpath/.settings) the life cycle will be run till generate-resources and therefore some plugins are run and can create other stuff (things like ANTLR/JAXB generators etc.).
Eclipse handles the correct target folders by reading the pom.xml files and by M2E it is translated into configuration for Eclipse etc. The things you are referencing about configuration is simply not working cause those posts are too old...
I have a Scala project built with SBT. I use Jenkins to do my build, and include the following as a build target:
scoverage:test
This gets me very nice coverage reports for my Scala sources using the Cobertura plugin for Jenkins.
My project has Java files as well, however, and I get no coverage for them. If this were Maven, I'd know what to do. But being SBT, I'm a bit unclear on how I can get coverage for the Java sources and then ensure that Jenkins sees the output and displays it as well.
I do know that the Java tests run using "sbt test" so that's not an issue.
Is this even possible?
I'm looking for a plugin that would run in a console continuously to scan a Maven project's test sources directory, and when it detects a change kicks off a test cycle. Something analogous to mvn scala:cc or the Scala Build Tool, but for Java. Can anyone point me towards one?
I have personally used sbt even for a java only project just for continuous test feature.
I added a sbt build file to a maven based project and use sbt when developing, but use maven when building the final package, starting embedded jetty etc and this has worked out quite well.
I've just discovered that the scala-maven-plugin supports both continuous compilation & testing, as well as cross-compilation (Java + Scala). So it's possible to use it over a pure Java build and get all the continuous build goodness.
Recently, I have had a need for a solution to this. Having been learning scala and finding about the goodness of sbt ~test, I want to apply it to Java projects that do not have continuous test.
Using the scala-maven-plugin that you mentioned, I have created a github seed that will run Java Junit tests everytime I save a Java source or a Java test.
Check it out:
https://github.com/ailveen/maven-scala-java-continuous-test
The project is very simple right now (contains only Java files because that is my current need) but in the future I hope to add scala test (or specs2 or scalacheck) so it works with mixed java and scala files.
Hope you find it useful.
It is not exactly for Maven, but JUnit Max does continuous testing and if you're on Eclipse it might be the tool you would like to check out
My web project includes Groovy class files.
How should I compile it for my project using Eclipse?
Rest of my team is using IntelliIDEA to use it but I want to set it up in Eclipse.
To start with I have installed a Groovy Plug-In for my Eclipse and installed Groovy on my Windows.
You should be able to right click on the project -> Configure -> Convert to Groovy project.
If your project is a maven project, then you should also install m2eclipse as well as the optional m2eclipse configurator for groovy-eclipse. This will automatically configure your project for Eclipse and groovy.
Hope this links helps you. It has step by step on how to import your existing Groovy Project into eclipse so you can work on it.
http://docs.codehaus.org/display/GROOVY/Create+Your+First+Groovy+Project
If the project is created using grails create project, I believe all of the .project and .setting files are there for eclipse.
If you have the groovy eclipse plugin installed you should be able to mix your groovy classes into the same packages as your java code. Are you using maven or ant to build your actual war file? If not you will have to make sure that you compile the groovy classes along with the java code. while in eclipse you will be fine. Both ant and maven have facilities for compiling the groovy and java code together for your actual war that you deploy.