Skip validation and maven build on startup in eclipse - eclipse

Technically I'm using Springsource Toolsuite, but I think this is a general eclipse question. My eclipse startup is now in the minutes, because on startup its running Maven Builder: FULL_BUILD and validation over all the open projects. I recently started working with a very large application, and going through the build and validation takes forever.
Is there a way to skip this at startup?

You can turn off automatic build under the Project top-level menu. Then you can explicitly control when to kick off a build. I would also ping m2eclipse guys on their forum about this issue. It sounds like there is a malfunction in their builder. It should not kick off a full build on every startup unless you workspace is significantly changed since the last Eclipse session.

Related

Debugging Spring Code in STS (Eclipse)

I am used to working in Netbeans, where I can start a project in debug mode, alter some code, and hit the "Apply Code changes" button.
at the moment I am working in Eclipse (Spring Tools Suite) and I would like to do something similar.
I found This article which suggests that Eclipse does it automagically if Project -> Build automatically is set, but that is not my experience. (regarding Spring Boot projects, which is what I am currently working with)
Any help is much appreciated.
In Eclipse and in combination with the Spring Boot Devtools, you have two options to deal with this situation.
One if the ability of the JVM to swap-in code changes while you are debugging without loosing the state of the application. This works in Eclipse out-of-the-box when you have "Build Automatically" enabled and do a code change after you hit a breakpoint. Usually the JVM drops the current execution frame and continues the execution at the beginning of the current method invocation.
BUT: This works for minor code changes only (changing the implementation of a method, for example). Most changes to the source code can't be hot-swapped by the JVM. If the IDE tries to do that, you will get an error message that this is not possible with the question whether you want to restart the JVM, stop it, or continue without the code changes. This is a limitation of the JVM, not directly of the IDE.
The other option is to go with the Spring Boot Devtools. Once they are on the classpath of the app and you change a class on the classpath of the project (which happens automatically if you have the "Build Automatically" enabled), the Boot Devtools will detect those changes and re-start the boot app automatically. This doesn't cause the JVM to be restarted, just the boot app part of it. Therefore it is much faster than starting the full JVM. BUT: you are loosing the state of the application. From the debugging perspective, it is the same as if you would restart the app, it is just faster. But you can't do what while sitting on a breakpoint and expecting the app to continue with the same stack frame.
There are other tools like JRebel that allow for more sophisticated code changes to be hot-swapped into the running app and there are also plugins for Eclipse to use JRebel, for example, but that is another story.

Eclipse project build takes a long time

I'm working with a decent sized application (300-350MBs) in my Eclipse IDE. All is well, but when I modify a source file (i.e. MyServlet.java), I can't see any changes until I clean the project, which in turn runs a project build. Due to the size of my project, this build takes about 3-5 minutes.
I guess what I'm asking is if there's a faster way to update changes made to my source files, so that whenever I need to debug, I don't have to wait 5 minutes for every minor change.
What I've tried so far:
Restarting the server
Refreshing the project
Restarting Eclipse
Committing to the SVN
Clearing my browser cache
There is a dedicated tool for that: JRebel. Problem is that you need a licence.
But what you really need to do is to recompile changed class. In your case if this is a Servlet you also need to deploy it to server (+some servers support 'hot-deploy' and some don't, I.e. do you have to restart the server)

best way to enable hot deployment on Jetty when using Gradle+Eclipse

I'm used to mvn, but I'm testing Gradle (v1.8) for a small web development project.
I've noticed that the Jetty Gradle plugin support autoscan and hot deployment, so I've enabled it. My goal is to recompile from Eclipse and get a Jetty reload the context every time I change a Controller, etc.
However, this is non working, mainly because Gradle compilation output goes to build/, however the Gradle Eclipse plugin creates a .classpath configuration that directs all the Eclipse output to /bin (even mixing test and main source folders).
Is there a way to?...
Run graddle jettyRun on a separate console.
Save a modified class on Eclipse (triggering a compilation)
See that Jetty picks up the change and reloads the context.
As per my research, I've identified three workarounds, but none of them solves the question above (I'm posting them in case you have related comments or more recommendations)
Tweak Gradle Eclipse config to direct test and main build output to the same directory that Gradle uses (using the pattern seen here). This is not recommended by some people, as it means using two different compilation systems that could interfere with each other.
Use the Gradle eclipse-wtp plugin to generate a WTP2 config, and use Eclipse's "Run AS -> Run on Server". This accomplishes the hot deployment / iterative goal and keeps both systems (IDE and Gradle) isolated. However, you need to setup the server on Eclipse.
(Not really a workaround): I've tested Spring's Eclipse build (STS) Gradle integration, however it seems that the integration is focused on the project setup, and while Gradle builds can be automatically triggered, Eclipse compilation is still redirected to bin/.
So you are interested in fine-tuning hot-deployment, right?
Please, consider using Gretty gradle plugin: https://github.com/akhikhl/gretty
It is an advanced gradle plugin for running web-apps on jetty. It does exactly what you want, regarding hot-deployment (and, possibly, even more).
Disclosure: I am author of Gretty plugin.
If you don't want to change to other plugins, here are two steps for the workaround:
add below configurations into your build.gradle:
jettyRun {
reload = "automatic"
scanIntervalSeconds = 1
}
each time after you changed java code, run the following task:
gradle compileJava
Because jetty is watching the *.class files, it will hot reload only after *.class files changed.
Refer to this link: https://discuss.gradle.org/t/hot-deploy-with-jetty-plugins-jettyrun/7416

Java maven development slow

I am developing a war/java website that is built via maven.
Currently, I have to make changes... tell maven to build them... then deploy to Tomcat. This is around 40seconds. So every change I make, I have to wait >=40seconds to see the change.
This is becoming very frustrating, so I have tried to speed up the deployment. I deployed the site via maven with war:exploded. Now, I edit the files live in 'deployed' format. The problem being I will need to move these changes back to the source location for pushing into our source control.
So has anyone written a script to 'undeploy' changes on the server carefully pointing them back to where maven expects them to be, or found another way I can instantly see my changes in a web browser. Rebuilding from source everytime is not a fun solution.
Currently, I have to make changes... tell maven to build them... then deploy to Tomcat. This is around 40seconds. So every change I make, I have to wait >=40seconds to see the change.
This is just a wrong way to use Maven in my opinion.
Either use something light like jetty:run (and hook Eclipse remote debugger to enable hotswap), see Configuring Jetty, Maven, and Eclipse together with Hot Swap.
Or use Eclipse WTP and deploy your project on a Tomcat server inside Eclipse (your project can be recognized as a Dynamic Web project whether you're using m2eclipse or the Maven Eclipse plugin).
Have you tried JavaRebel?
http://www.zeroturnaround.com/jrebel/
Use hot-deployment.
Just configure tomcat-maven-plugin and try tomcat:redeploy.

How do I configure Eclipse to run your tests automatically?

I read this article: Configure your IDE to run your tests automatically
http://eclipse.dzone.com/videos/configure-your-ide-run-your
It's pretty easy to configure Eclipse IDE to run an Ant target every time a file is saved.
MyProject -> Right-click : Properties -> Builders -> New -> Ant Builder
The problem is that the builder has to rebuild the jar on every save, which is very long. The JUnit tests run using the .classes in the jar.
We already have JUnit configurations (EclipseIde .launch files which contains the whole classpath to run the tests). I wish I could create a builder that wraps those JUnit launch files. This would have the benefit of running the tests against Eclipse .classes (faster than rebuilding the jar). Also the test results are displayed in the JUnit view.
Has anybody manage to do that?
I recently started using Infinitest and it seems to somehow "know" which parts of the code affect which test cases. So when you change some code, it automatically re-runs the tests which are likely to break. If the test fails, it marks an error at the spot where it failed, the same way Eclipse would mark a coding error like calling a non-existent method or whatever. And it all happens in the background without you having to do anything.
You could try CT-Eclipse, a continuous testing plugin for Eclipse.
From the plugin page:
With CT-Eclipse enabled, as you edit your code, Eclipse runs your tests quietly in the background, and notifies you if any of them fail or cause errors.
You can use JUnit Max it is an eclipse plug in that will run all you tests every time you save. But it will do it without interrupting your work flow. The results are shown in the left corner of Eclipse and you can always go back to the last successful testrun. The plugin runs the tests that are most likely to fail first so that you get a response for your last saving as fast as possible.
http://www.junitloop.org/index.php/JUnitLoop is another one like this (haven't tried it yet myself)