1

I use here Eclipse with m2e plugin. If I do a project clean, it doesn't do anything.

On my experiments, I see as if m2e simply weren't wired into the eclipse project cleaning option.

I've tried to set up in lifecycle-mapping-metadata.xml, but it didn't work. If I understand this well, maybe a clean can't be set up here, because cleaning is not considered as part of a project lifecycle from the viewpoint of the eclipse.

So, is there any way to do a simple mvn clean from eclipse on a project cleanup?

(The ideal solution didn't require to start a new jvm, and all run inside of the eclipse process.)

peterh
  • 11,875
  • 18
  • 85
  • 108
  • So you want an Eclipse project->clean to trigger a `mvn clean` operation? If so, why is this important to you, rather than just running a `mvn clean` from within Eclipse when you feel the need? – Duncan Jones Aug 28 '14 at 10:42
  • When I run maven clean in my Eclipse I can see that it deletes target folder, but then re-creates it and restores resources only in it – Evgeniy Dorofeev Aug 28 '14 at 10:43
  • @EvgeniyDorofeev Maybe it is because you turned auto-build on. I don't. Eclipse java builder deletes all target folders, which gives the interesting question, why should a project cleaning called by a _java_ _compiling_ _subsystem_. And there are a very big legion of such interessant questions around eclipse. – peterh Aug 28 '14 at 10:46
  • @Duncan Yes, I could do these things, but I am really wondering, why can a such _basic_ functionality so _hard_ to set up. A well known Java IDE, and it can't simply clean up a project? – peterh Aug 28 '14 at 10:48
  • @PeterHorvath In my Eclipse install, if I do a project->clean (with automatic building disabled), it deletes all class files from `target`, but leaves the `classes` and `test-classes` directories in place. Is that the behaviour you see? – Duncan Jones Aug 28 '14 at 10:54
  • @Duncan No, because I have some additional things in target as well, and I want also them to be deleted. If I call mvn clean from the command line, it deletes everything properly. This is what I try to do from m2e as well. – peterh Aug 28 '14 at 10:56
  • @PeterHorvath Well, I would think the correct way to do this from m2e is to do right-click, Run As > Maven clean. The fact that m2e isn't integrated into Project>clean is perhaps unfortunate, but I doubt there's a way around that. – Duncan Jones Aug 28 '14 at 11:09

1 Answers1

1

In lastest version of the m2e plugin, on Luna, you can display what Maven will do:

Eclipse Preference

This explains why the clean step is never called.

And sadly, it is unsupported in default Eclipse clean, but you can also invoke Maven from Eclipse using Run As > Maven clean.

NoDataFound
  • 11,381
  • 33
  • 59