View log of maven commands run by Eclipse plugins - eclipse

I often found myself in a situation where I would like to see exactly which Maven commands Eclipse is running behind the scenes. In this case I am running a webapp with WTP, but this question is more general (though I would gladly accept answers for just that scenario).
Is there any way either with a pom configuration or an Eclipse configuration to view a log of all commands (and potentially any output) that any Eclipse plugin (or at least m2eclipse-wtp) have run?

The Maven Console will show you the Maven output from m2e and m2eclipse - access it from the very right hand side dropdown of the normal Console view.

Related

Eclipse mars is too slow.. Always busy in scanning classpath

I am using eclipse mars 4.5. Problem is, it always busy with scanning class path that actually makes eclipse too slow to work on. I am working on the multimodule OSGI projects, so there are around 30 projects in the workspace and eclipse every time starts scanning classpath for all projects.
can anybody help to optimize the eclipse and stopping auto class path scan for each project.
On my machine the vaadin designer scanned each projects of my workspace (in my case about 100 bundles), and this took very long (eclipse Mars.2 and Neon)
Hint: open visualvm - connect to eclipse pid; create a thread dump and analyze the worker threads of eclipse.
I have the same issue and the only things I do are:
Maven plugin:
If you use the maven plugin, on each project, choose the Maven option Disable Workspace Resolution the other project will not refers anymore those in the workspace.
Apparently this is a known bug and you can find some more solution like rebuilding the maven indexes here.
Maven in command line:
Another option I choose is to use the maven on command line (It's not perfect but in the environment I work in it is the best solution) and use the option "Offline" in the maven preferences. This is due to proxy which is not working from Eclipse but work from command line (my setup).
Personally I use both option but this is due to a very strict proxy which is not friendly; I think this is a good setup for OSGI as trying to resolve all dependencies could be very long.
Another point: try to see if you have circular dependencies, it can happens very quickly in OSGI environment and I guess that can also make the compiler to be mad.

How do I run SBT from within Eclipse?

So far I've been running IntelliJ IDEA Community Edition for my Scala projects, but as my projects are expanding in complexity, I stumble upon more and more roadblocks with the IDE.
Like for example the simple fact that IDEA doesn't allow for web-development or Java EE development what so ever, which means using the Play Framework or TomEE in Community Edition leads to nothing but dead ends and frustration.
The only reason I switched to IDEA in the first place, is because of its excellent plugin system, allowing me to run SBT seamlessly as the primary scala compiler and library downloading tool with ease.
Searching around on Google, however I can only seem to find mentions about the eclipse plugin for sbt, that makes an sbt project Eclipse friendly, which is the exact opposite of what I'm really looking for.
I'm not willing to spend €89 per year for a student licence after all the pain it's put me through so far...
So my question is; is there a plugin for Eclipse that allows me to use SBT the same way as in IDEA? Or am I forced to go through the console?
There may be some movement in this direction in the future, but for now there is no such plugin.
Currently there is no Sbt plugin for Eclipse. Depending on your use-case, you could:
use the Eclipse builder
Pros: proper integration (error markers in Problems and editors, cancelation, progress reporting)
Cons: may get out-of-sync with the Sbt build file (when adding a dependency, for example), doesn't handle anything other than Java and Scala (like Play templates or route files)
use Sbt on the command line (make sure to disable auto-building in Eclipse)
Pros: can handle complex builds, classpath is always up to date
Cons: no integration (see above)
use Activator
Same Pros and Cons as Sbt, but with a pretty UI
We are working on an sbt-server plugin for Eclipse, which will delegate the build to an external Sbt process without giving up the convenience of integration. We hope to have something out towards the end of this year.
I think the main problem you are trying to solve for is too have sbt jar dependencies show up and get used natively by your eclipse project. You can do that with the IvyIDE plugin (which is found in the eclipse marketplace).
If you have that installed (and the eclipse plugin for sbt) then this closes the gap between systems.
To enable:
type the {sbt deliver-local} command from your terminal. This adds an ivy xml in your project's target directory
right click on your project. Choose the Ivy -> enable Ivy dependency management option
go into your projects properties. Highlight the Ivy property. Click the new button and navigate to the ivy xml file in your projects target directory.
Now your eclipse compiles off of your sbt managed dependencies and now you are doing everything you want except actually running sbt from within eclipse (which you only have to do now when you are changing dependencies)

Eclipse (STS) with m2eclipse - not showing compile errors in Problems view

This is maybe silly question, but I will try to ask anyway :).
It is possible to link compile errors form Maven Console to Eclipse Problems Window ?
I can see errors in the maven console, but the Eclipse Problems view showing no errors, only warnings.
I'm using Spring Source Tool Suite (STS) with M2Eclipse plugin.
My Maven project (for example CarService) consists of 2 modules (server, client). Each of them is separate eclipse project and I don't have imported the parent pom, only the child poms.
Problems window is configured to show all possible errors :).
Thank you for any advice :).

Indigo Maven Project Builder

In Eclipse it is possible to configure builders for a project. I am using m2e and Eclipse indigo for a dynamic web project. I am trying to figure out exactly what happens when I invoke Build for the project from eclipse and so be able to understand the difference between this and a just doing a maven build from the command line. I go to project / builders and see there are five builders: JavaScript Validator, Java Builder, Faceted Project Validation Builder, Maven Prokect Builer and Validation. It would be interesting to see what goals the Maven Project Builder will do but I can't see this from this screen. Edit is disabled. I try Project Properties / Maven and there is nothing to do with Goals there. Even though this http://maven.40175.n5.nabble.com/Preventing-Maven-project-builder-from-being-run-td137622.html suggests there should be.
I am wondering is there any way to see and configure what goals Eclipse will call?
Many thanks.
Strange as it sounds, m2e does not really invoke Maven to do the build.
Its job is to parse POM file and delegate the job of doing everything that it finds there to Eclipse.
It does so by mapping maven plugins to special m2e Eclipse plugins.
Sometimes, when no mapping exists you get a warning and you have a choice of either disabling this part of your build or running the maven plugin in I guess default wrapper provided by m2e. In either case the result is not as good as when a maven-to-eclipse plugin mapping exists

synchronising / maintaining ant and eclipse classpaths

I'd be interested to find out about any automated processes that people have for ensuring that the project classpaths for the ant and eclipse configurations are in synch. In my case, I want the classpath defined in the ant build file to be the master configuration, since its used for our production builds. As part of the build i'd like to add an ant target that will verify that the eclipse classpath is up to date, or at least indicate differences between the two classpaths.
I'm aware of ant4eclipse but its focus is in the opposite direction, ensuring that the eclipse classpath is master and that the ant build reuses the eclipse path. I like the idea behind AntAndEclipse but am wondering are their ant other tools in this space that i'm not aware of.
You solution at a previous company was to have ant invoke Eclipse to do the compiles as described here:
http://www.eclipse.org/articles/Article-PDE-Automation/automation.html
I'm not aware of any ant tools which can do this but I've switched from ant to Maven a few years ago and never looked back. You can use the "Maven integration for Eclipse" to make Eclipse use the Maven classpath.
As of today, I'm not 100% happy with the Eclipse plugin, though. It's a bit slow and due to the different philosophy of Eclipse and Maven, some operations behave strange. For example, Eclipse doesn't differentiate between a "production" and "test" classpath, so you can get compile errors in Maven when everything looks great in Eclipse.
My solution was to use the plugin to keep the classpath in sync and compile from the commandline.
there is an ant task to do xml transformations, we used that task to create the classpath in our build file. It was a little trick to get the XSL right but once it worked it was great
Did you evaluate Apache IVY? Currently I am building a Continuous Integration environment at our place and we use IVY to handle our dependencies. There is a eclipse plugin that takes the dependency configuration of eclipse and uses it as eclipse classpath.
Currently this solution looks quite promising.
My team wrote an Eclipse plug-in to add a new type of library to the Java Build Path->Add Library option in the project settings. This custom library type allowed both Eclipse and ANT to reference the same canonical list of dependencies.
Nowadays, I'd probably look at IVY for doing the same thing if I was locked into using ANT, rather than writing my own.
You need Ant2Eclipse.