1

Is there a way to use the Eclipse plugin to rebuild the .project files but not make new ones if not present?

I'd like to run a generic command from the root of the modules that adds the project dependencies to newly imported (by "imported" I mean mvn eclipse:eclipse has been run) for previously imported projects without having to do it individually for each or unintentionally import everything.

Example, say I have a multi module project like this.

  • Parent
    • Foo
      • Foobly (newly imported)
      • Fooble (not imported)
    • Bar
      • Barbly (previously imported, depends on Foobly)
      • Barble (not imported)

From Parent, is there some command I can run that will add the project Foobly as a dependency in Eclipse to Barbly so when I view source it opens that projects .java files instead of M2's .class files without adding the .project, .classpath, etc. to Fooble and Barble.

Also, for what it's worth, I'm not talking about m2eclipse, the Eclipse plugin for Maven, I am talking about the Maven plugin maven-eclipse-plugin. This is sort of a moot point because m2eclipse doesn't use mvn eclipse:eclipse, but I just wanted to clarify.

Captain Man
  • 6,997
  • 6
  • 48
  • 74
  • Just curious: why do you still use eclipse:eclipse? m2e should be superior in all respects. – rec Aug 12 '15 at 19:36
  • The same reason some people prefer using source control from the command line instead of from the workspace. Apart from that it always seems like there's some plugin it can't find and then it has to modify the pom, I just am not a big fan of it. – Captain Man Aug 12 '15 at 20:49
  • I wasn't even aware that this plugin is still being developed - just hopped over to their site seeing that in fact they still do releases. But there's also be big disclaimer saying that in general one should be using the m2e instead. Having to pimp the pom with dedicated m2e settings is arguable a bit annoying, but fortunately a one-time thing. It's even cool because it allows actually running maven build plugins as part of the Eclipse build. I've used that a couple of times to my benefit. "eclipse:eclipse" couldn't do that ever. – rec Aug 12 '15 at 20:55
  • @rec the issue to me is I use m2e, it can't handle some plugin so it modifies the pom, now the pom shows it's modified despite not having changes I intend to commit. Also, correct me if I'm wrong, but telling m2e to ignore some plugin means using maven from the command line will skip it too, right? – Captain Man Aug 12 '15 at 21:32
  • 1
    Unfortunately, I can't see from here what m2e did to your pom. What I can say though is that the special settings for m2e that are encoded in the pom do *not* affect the command line build. These settings are wrapped up in a kind of pseudo-plugin called "lifecycle-mapping". And to be extra sure that this plugin is completely ignored in command line builds, you normally wrap it in a profile. Cf. here: http://stackoverflow.com/questions/16469315/eclipse-maven-error-plugin-execution-not-covered-by-lifecycle-configuration/21371123#21371123 – rec Aug 12 '15 at 21:36
  • @rec thanks, I'll look into giving it a second chance then. – Captain Man Aug 12 '15 at 21:39
  • For anyone coming here in 2020 or later, please note that m2e at some point (maybe in 2016?) added an option to ignore plugins in a workspace file so you don't need to modify your POM files. – Captain Man Mar 25 '20 at 16:48

0 Answers0