4

I am using the eclipse plugin for maven to generate eclipse projects from maven pom.xml files.

mvn -Dwtpversion=1.5 eclipse:eclipse

This works fine and, after some experimenting with several of the 400 different archetypes available, I settled on using the webapp-javaee6 archetype, which was the only one which generated a set of dependencies that were both all available and which created a project that was useable by the WTP plugin.

The problem now is that I would like to be able to invoke mvn goals from eclipse. The accepted way to do this I understand is to use the m2eclipse plugin, which I have installed.

However, after playing around a bit and getting nowhere I discovered this comment in my .project file:

<comment>NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>

Further searching (see this lengthy diatribe from October) suggests I'm not (just) being stupid in not being able to get this to work.

The how-to linked in the top answer to this question seems hopelessly out of date.

So, the real question - what is currently the correct way to use maven to generate a WTP-friendly project that can be converted to eclipse and then use eclipse to call the project's goals?

Community
  • 1
  • 1
robbbbbb
  • 147
  • 1
  • 8
  • This isn't an entirely satisfactory answer, but [Rafael's how-to](http://blog.goyello.com/2010/06/15/how-to-create-java-web-application-with-eclipse-wtp-and-m2eclipse/) got me almost all the way to get this working without needing to ditch m2eclipse. I say this is only a partial solution as it only solves the problem when creating new projects via m2eclipse using a specific archetype. It doesn't offer a solution to the bigger problem of converting existing projects to allow me to use eclipse to drive maven builds, which is ultimately the goal. – robbbbbb Jul 06 '11 at 17:07
  • This page describes a way to deal with this issue: http://blog.teamextension.com/m2eclipse-m2e-support-for-maven-eclipse-plugin-projects-497 – vegemite4me Apr 18 '16 at 14:24

2 Answers2

2

Have you tried File -> Import -> Check out existing Maven Projects from SCM? My understanding is that m2eclipse will then create the eclipse project for you. If the packaging defined in the pom is war, the project should be deployable with WTP. (The latter used to require an the maven-wtp-integration plugin as well, don't know whether that's still the case).

meriton
  • 68,356
  • 14
  • 108
  • 175
  • Thanks, I think in as much as there is an answer to this question, this is it. The SCM flavour of m2eclipse project creation will get an existing maven project working from eclipse, with WTP extensions working (yes, it's still the case that you need to install that extra plugin from sonatype). However, as the rant I linked to mentions, this doesn't help in making any build created from such an eclipse setup reproducible. m2eclipse slides a bunch of extra build configuration between eclipse and maven. Seems like this may just be an intractable issue and it's back to the command line for me! – robbbbbb Jul 07 '11 at 09:58
  • I don't see, and the article you linked to doesn't elaborate, how "any build must be reproducible entirely on the commandline and must not depend on an IDE configuration" would be a problem with m2eclipse. In particular, I never noticed any discrepancy between "run as maven build" from within eclipse and directly invoking maven using the command line (assuming you have the same maven runtime and the same settings file configured, of course), even though I have been using m2eclipse for years now. – meriton Jul 07 '11 at 12:15
  • OK, well I'll proceed with caution, thanks for the reassurance :) – robbbbbb Jul 07 '11 at 12:49
0

Not sure about WTP or maven archetypes, but have you come across SpringSource Tool Suite (Spring packaged eclipse) and created a Spring Roo project? You can use this to create a data driven maven built web-app in a few mins. You can even remove the spring roo bits if you don't want them, it will give you a good starting point for a web-app with very little pain.

martin
  • 116
  • 4
  • SpringSource was the next thing I was going to move on to (I've actually already got it installed). Could be a good solution to the 'making a new project' problem, but certainly wouldn't work for how to start from an existing maven project (which is in source control, already being edited by several people) and use eclipse as an interface on to it (which is really the general case I'm working towards). – robbbbbb Jul 06 '11 at 20:49
  • Having played a bit with Roo, it seems like a really good starting point for a modern J2EE app from scratch - I'm thinking of it as on a par with Grails but with all the nice AOP stuff from Spring. Not really a solution to this more general problem of lower-level Maven-Eclipse-WTP integration though. – robbbbbb Jul 07 '11 at 10:02