How does the m2e eclipse plugin interact with eclipse? - eclipse

I am an eclipse power and who has ignored maven due to the historically poor maven / eclipse integration. m2e seems to be maturing and I am taking it out for a serious test drive.
I want to understand how m2e works within eclipse, so I can better get the two working smoothly together and to understand the still cryptic error messages and problems that arise.
I have tried googling for an explanation of the m2e eclipse integration architecture and found nothing that provides a good account of how the integration works. rather just a lot of scattered blog posts all over the web.
Can anyone provide a solid overview of how m2e bridges the gap between the eclipse view of the world and maven view of the world? Especially how does maven integrate into the incremental builds that eclipse does? What is the impact on eclipse stability / performance from using m2e.

I have found the details I was looking for in a Presentation from Eclipse Con titled "m2e, an exercise in mixing oil and water"
http://www.eclipsecon.org/europe2012/sites/eclipsecon.org.europe2012/files/EclipseConEU2012-m2e-talk.pdf
Abstract:
m2e is a popular Eclipse IDE plugin with stated project goal "to
provide a first-class Apache Maven support in the Eclipse IDE". In
this talk I will give an overview of Maven/Eclipse integration
approach implemented by m2e, highlight differences between Maven and
Eclipse that make proper integration difficult or impossible and will
discuss possible ways to improve the integration. The talk is targeted
at Eclipse and Maven developers who want to better understand
challenges of Maven/Eclipse integration and advanced m2e users who
want to know what happens "under the hood".

Sonatype has a pretty good book about it at http://www.sonatype.com/Support/Books/Developing-with-Eclipse-Maven

In short, m2e will setup your Eclipse base on the Maven POMs of your projects, and it provides you access to Maven commands
these are some of the most obvious things m2e done:
setup the source folder and output directory according to POM
Setup dependencies/libraries and project dependency base on POM
Use corresponding Eclipse plugins base on Maven plugins (if M2E knows how to deal with it)
etc.
Allow you to run Maven goals
etc.....
It is neither a formal nor a accurate description, but I wish it give some basic idea :P

Related

Differences in NetBeans and Eclipse for maven projects [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
What are the differences between Netbeans and Eclipse for working with maven projects?
I'm Eclipse user, but to be perfectly honest I have to say that Maven support in Eclipse isn't perfect and often cause weird errors you resolving by cleaning, recompiling, regenerating project files etc.
As far as I know, IDEA and NetBeans have far better support for Maven.
NetBeans has native support for Maven.
What does that mean exactly? It means that if you have a Maven-based project in NetBeans then the pom.xml is what the IDE uses for project definition. The POM is the definition!
Contrast this with Eclipse where Maven support is bolted on top of Eclipse's project definition. This means that any Eclipse solution will have to concentrate on converting to/from Eclipse's own project definition and the POM. I believe this is the root cause of Eclipse's sometimes-less-than-optimal Maven support.
In NetBeans, if your project is Maven-based, then all actions are carried out by Maven. Even the "run" action is effectively done by Maven. The IDE only triggers it. Having this consistency means that you can be sure that your project behaves exactly the same for example if in a non-IDE environment such as a Jenkins/Hudson.
I've met many people who believe that Maven is cumbersome. When you talk some more about it turns out that their bad experience to a large extent comes down to their experience with Maven from within Eclipse, not so much Maven itself. Users of Eclipse tend to think that this is just the way it is supposed to be because they've never seen anything else. (NetBeans users do the same in the opposite direction in the areas where NetBeans is sub-optimal and Eclipse shines)
Let there be no doubt: Eclipse has MANY virtues. Maven support is not one of them.
Starting on an maven based project is much more easier in Netbeans and IDEA than using Eclipse.
in Eclipse, you have to configure your existing project to use maven. Starting by enabling a appropriate maven plugin
using Netbeans and maven is much more easier. Open -> Projekt -> select the pom.xml and you are ready
IDEA has a similar approach. You simply have to import a the project from the existing pom.xml
I have chosen IDEA as my favorite IDE and I'm quite happy with the maven support. Sometimes I have to open NetBeans and at least the maven support works as expected. My own experiences with Eclipse are a little bit outdated but I hear a lot of complaints from my colleagues using Eclipse together with maven.
m2e is the "latest" maven eclipse integration (not to confuse with the old m2eclipse). I really thank all people who spend their time in developing eclipse, maven and m2e - it's my daily work setup, but m2e is far from perfect. Just have a look at the latest "M2E plugin execution not covered" dilemma. If you use non mainstream plugins you have to modify your pom.xml for the m2e usage - just to avoid project errors in eclipse.
To run my mave commands I prefer the command line instead m2e.
As I know Netbeans uses maven more "native" and therefore has not that kind of integration problems. But I am not sure about it. If you have the choice you should compare both possibilities.
I've used both Eclipse and Netbeans. I've used Eclipse more at the university, and professionally it was mixed between Eclipse and Netbeans.
Eclipse is far better than Netbeans depending on the domain.
If you want to work with scala - no other way, eclipse scala plugin is heavily maintained and works much better than Netbeans. If you want to work with perl, same thing.
If you have a massive project with more than 50 large modules and need to do cross cutting refactoring, you are faster with mvn eclipse:eclipse on your root pom, and leting eclipse import and build the project, and then starting with your refactoring.
With that said, when you are doing feature development. And your base project is built in the CI by maven. Oh! Then I can promise you, Netbeans is light years better than eclipse. They are not in the same league when you add maven as the build tool into the equation.
With eclipse, you have to give in and say:
- It is beyond me I let eclipse work as my own built tool and I keep away from the command line. If I even go to a folder and do mvn clean install, eclipse with fight against me.
With netbeans, he just does not try to re-invent the wheel. He lets maven do what maven does, and build your project. It runs your tests with surefire.
In my personal opinion, for Java EE development - namely adding features and "NOT" doing cross cutting massive refactoring and your project is built on maven, Netbeans is by far the best IDE. It is perfect.
It is simplicity in itself. A simple and confortable user interface.
A perfect debugger.
Perfect JSF to bean navication.
Perfect maven integration.
Perfect colaboration with Jrebel.
Netbeans is simple and super effective.
I've found Eclipse to be my enemy, when i want to use maven to run all unit tests or for wahtever reason. If I want to deploy a WAR built by maven ... better not! I need to absolutely give myself into eclipse and let it own everything. I need to keep well away from a command line.

Eclipse project structure ANT and MAVEN

I am trying to set up a project, but feel completely overwhelmed with lack of knowledge. In university we used netbeans which resolved project structure gently for us. As community leans towards eclipse I am trying to migrate there, but feel myself like a penguin not able to fly. I can't understand project structure where and what has to be added, do I have to define ANT or MAVEN manually in eclipse can they be integrated? Where to go ? Apache manuals are so complicated, why is that I can program in Java , but don't know the fundamentals, soo depressed, please anyone guide me. I find pieces on web, but seems can't build full picture in my head.
You have a couple of options. Basically, eclipse uses a workspace, which contains one .metadata directory used by the plugins and all of the project folders. Projects can then be things like java projects, PDE projects, PHP projects, etc.
There is maven integration in eclipse which I would use, http://www.eclipse.org/m2e/ It was part of Indigo, which released June 2011.
Set up your java projects in your workspace, and then use m2e to mavenize them, or use m2e to generate the java projects into your workspace.
maven provides a facility to create a new project with the required structure based on the type of project (jar, war, etc.).
You can do this or achieve it directly from Eclipse as suggested by Paul Webster, by installing the m2e plugin.
This structure can then be easily built using maven, as well as developed in Eclipse.

Managing external jar dependencies

I'v written a selenium framework which needs to be extended to the team. I've checked in the code in SVN. How can I make sure that external jars are added to build path and folder that folder by other team members? Basically I want to manage these dependencies better. Somebody said, Maven can take care of these so I tried to install m2eclipse plugin for eclipse 3.2 without any success. Can Maven solve this problem and is there any better way of managing it?
Do the easy way: commit the jars into SVN. It will save everybody a lot of time.
If you are amenable to using Eclipse, Maven, and m2eclipse, I would suggest using SpringSource Tool Suite. It is an Eclipse based IDE with Maven and m2eclipse pre-bundled. This bundling makes getting those three tools to work together very easy.

How to integrate maven the right way into Eclipse and into the software development process?

I am new to maven. The main feature I benefit from, yet, is the automatic dependency management. The standardized directory structure seems also to be nice, but Eclipse has a standard directory structure, too. The directory structure is now independent from Eclipse, but now it is dependent from maven. OK, I see, both programs seem to be quite flexible at this point.
I am not quite sure, if maven is more dedicated to servers or to client systems, e.g. there is a feature / plugin to generate a project website. Doesn't this make most sense on a server system?
How to integrate maven with a version control system (VCS), e.g. SVN? I think of a system where there is a repository and always up-to-date website with download section for development artifacts.
How to integrate maven with Eclipse? I'm now using m2eclipse with WTP integration. Its ok, but it has some behaviors that I don't like, e.g.:
When I generate new Java projects the JRE version is set to 1.4 . I have to reset it to 1.6 / workspace default manually.
Facets configuration is not stable. Some configurations have to be done manually and in a specific order.
Maybe I can fix them if I read more about it. And I have a more or less serious problem with its WTP extension. I think its important to say, that the WTP extension is not officially supported and may not have production quality.
I know there is another plugin which integrates maven into Eclipse. I did not try it, yet. Is it better?
Also I think, that maven may be useful for much more areas. For example the directory structure could be extended to hold e.g. requirements, specification and modeling artifacts. I think that would only work, if it would be standardized. Revision control for all documents would be nice, too.
So many thing, that could be integrated to support the complete software development prosess. Maybe its unrealistic, to get all of these features. For now the Eclipse integration with WTP and VCS integration have the highest priority for me.
Any suggestions? Thanks in advance.
The directory structure is now independent from Eclipse, but now it is dependent from maven. OK, I see, both programs seem to be quite flexible at this point.
Yes, they are both flexible so we could bend one or the other. But if I had to choose a layout, I would pick the IDE agnostic one i.e. the Maven layout and I would stick to the defaults to minimize the efforts and because they are well known (so anybody familiar with Maven knows where to find things). And if someone wants to use IntelliJ IDEA or NetBeans because he feels more productive with it, he can do it. In other words, I don't see any benefit to use the Eclipse layout.
I am not quite sure, if maven is more dedicated to servers or to client systems, e.g. there is a feature / plugin to generate a project website. Doesn't this make most sense on a server system?
Maven can be used for local builds on developer machines, for central builds on a continuous integration machine. And things like generating a website, deploying artifacts are usually done on the central server.
How to integrate maven with a version control system (VCS), e.g. SVN? I think of a system where there is a repository and always up-to-date website with download section for development artifacts.
I didn't really understand the first part of the question. How do you want to integrate Maven with SVN exactly (there is the maven-release-plugin but I'm not sure that's what the question is about)? For the second part, the traditional approach is to use a continuous integration server to trigger a build after a change in the VCS and to deploy (in the maven sense) the created artifacts to a "corporate repository". Many people use Hudson as CI server.
When I generate new Java projects the JRE version is set to 1.4 . I have to reset it to 1.6 / workspace default manually.
That's because the maven project itself is not configured to use 1.6 level (the Eclipse configuration is derived from the POM, which makes sense). You have to configure the maven compiler plugin for 1.6. Here is one way to do it (there are plenty of previous questions on this topic):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
And then update your project configuration under Eclipse via right-click then Maven > Update Project Configuration.
Facets configuration is not stable. Some configurations has to be done manuel and in a specific order.
They are for me and again, they are derived from your POM (e.g. from the version of your web.xml).
And I have a more or less serious problem with its WTP extention. I think its important to say, that the WTP extension is not officially supported and may not have production quality.
Huh? Where did you read this? Works fine for webapps for me.
I know there is another plugin which integrates maven into Eclipse. I did not try it,yet. Is it better?
I don't have experience with Eclipse IAM. But what is your problem with m2eclipse?
Also I think, that maven may be useful for much more areas. For example the directory structure could be extended to hold e.g. requirements, specification and modeling artifacts. I think that would only work, if it would be standardized. Revision control for all documents would be nice, too.
You're free to put whatever you want in your project tree. Many people are doing this and referring to docs from the site. Possibilities are endless.
Some random points to push you in the right direction:
The standardized directory structure seems also to be nice, but Eclipse has a standard directory structure, too
Eclipse does not have a "standard" directory structure. For example, some people put their unit tests in src next to their code, and others put it in a separate dir like tests or test. You can configure either up as much as you want, but Maven follows has defaults that almost everyone follows:
source in src/main/java
tests in src/test/java
resources necessary for running in src/main/resources
language files
Spring config files
resources necessary for running tests
golden results
config files in src/main/config
Eclipse is an IDE, and Maven is a built build management tool
case in point: if you ask Eclipse to build a JAR/WAR, you have to manually tell it what to include and where. Because you placed your files in Maven's defaults, you get things like:
JARs/WARs contain the compiled Java classes from src/main/java, but not the ones from src/test/java
config files from src/main/config don't go into the JAR/WAR (kinda defeats the purpose of a config file if it did)
test resources from src/test/resources don't go into the JAR/WAR
if you decide to build an assembly (Maven speak for a distribution of your code you can put on your website that includes documentation, source, binaries, etc.), it can make a JAR, the config files, and javadocs into a ZIP file.
I am not quite sure, if maven is more dedicated to servers or to client systems, e.g. there is a feature / plugin to generate a project website.
Yeah, the Maven site plugin.
Doesn't this make most sense on a server system?
Not really. Documentation is critical for any project, especially for client systems.
Maybe I can fix them if I read more about it. And I have a more or less serious problem with its WTP extention. I think its important to say, that the WTP extension is not officially supported and may not have production quality.
Because Maven integration with Eclipse via the m2eclipse plugin isn't perfect, I actually won't use it for WTP projects. I use the Maven Eclipse plugin to generate Eclipse project files and then import the project as a regular Eclipse project. The downside is that the Eclipse project files have to be re-run after any significant changes to the project.
Revision controll for all documents would be nice, too.
That's not Maven, or any build management tool. That's your SCM, Subversion or whatever.
When I generate new Java projects the JRE version is set to 1.4 . I have to reset it to 1.6 / workspace default manually.
You can set that through Maven.
Maybe its unrealistic, to get all of these features. For now the Eclipse integration with WTP and VCS integration have the highest priority for me.
The m2eclipse plugin and friends work best for simple Java Maven projects. Personally, I use the Maven eclipse plugin to generate an Eclipse project for any web, EJB, etc. projects.
There's downsides to that as mentioned earlier, but the upsides, including dependency management as you mentioned, outweigh them, IMHO.
Of course, a poorly configured Maven project is still a poorly configured project. It's not magic. :)

Maven2 Eclipse integration

There seem to be two rival Eclipse plugins for integrating with Maven:
m2Eclipse
and
q4e.
Has anyone recently evaluated or used these plugins?
Why would I choose one or the other?
Side by side comparison table of three maven plugins.
There is only one point where q4e is actually better: dependency viewer. You could see the dependency tree, manage your dependencies visually and even see them in a graph. But, m2eclipse works in a better way, specially because you can create you own build commands (in the run menu). q4e comes with some predefined commands and I can't find where to define a new one. In other words, m2eclipse is more friendly to the maven way.
I have been using m2Eclipse for quiet some time now and have found it to be very reliable. I wasn't aware of q4e until I saw this question so I can't recommend one over the other.
My 2cents,
I am using eclipse for some months now with m2eclipse integration. It's easy to use and straight forward. Once you associate your project to maven and update the dependencies using m2eclipse, any change to pom.xml are reflected to entire project, even Java version definition causes it to be compiled in right JRE (if you have it installed, and properly configured into eclipse.)
Another advantage I found is the maven plug-ins are easy to use integrated with eclipse (jetty being my best example, again, properly configured you can easily integrate maven, jetty-plug-in and Eclipse Debugger)
Compilation, packaging and all other maven features are equally easy to use with a couple clicks or shortcuts.
About q4e I have been reading a lot of good stuff about it and seems the next versions will do a lot more than m2eclipse, with a better dependency management and even visual graphs (!) but the general opinion is that m2eclipse is still better than q4e but q4e is getting better each new version and maybe will surpass m2eclipse soon.