-1

I wonder if when I hit Project > Clean, mvn is really involved in setting up the build process.

Is M2E (Maven to Eclipse, standard plug-in) just reading and analyzing the pom setting up / updating the Eclipse project the way specified by the pom or does it actually run the phases defined in the pom?

I just wonder what happens on Project > Clean when it comes to Maven... .

[Update]

Since people seam to get confused by the question here are more information:

I altered the build process of the project in maven and it seam to be not reflected by actions I trigger in the IDE directly. So M2E seams to be more like a translator of maven settings and applying the same settings to Eclipse without altering the behaviour. It also would explain why M2E is providing connectors in the first place.

Since I could not verify this, I boiled it down to a simple question that if answered, I know the answer to the more difficult question regarding Maven integration in Eclipse.

[Update2]

M2E has the ability to execute certain phases. I added an answer. This answer is not obvious since I searched the internet up and down before I asked this question. Also I only found the answer by some thoughts that were raised by the previous answer to this question which is what I asked for but only half of the picture.

This question is a perfect example why often on stack overflow the obvious is neither asked nor was implied nor is the final answer and the trigger happy close friendly swarm sometimes misses the point :-).

Martin Kersten
  • 5,127
  • 8
  • 46
  • 77
  • You are confusing Maven and Eclipse. Both are two very different technologies. Project > Clean is a Eclipse Action and in no way is it related to Maven. – Tunaki Sep 23 '15 at 12:45
  • 4
    possible duplicate of [Function of Project > Clean in Eclipse](http://stackoverflow.com/questions/4549161/function-of-project-clean-in-eclipse) – meskobalazs Sep 23 '15 at 12:46
  • No I am not confusing. I am trying to extend the build process and that the mvn clean or mvn build is producing a different output. So it boils down how M2E is internally working so it boils down to this simple question: What is M2E is actually doing when I hit Project > Clean. So this is neither a duplication nor I confuse something. This is just advanced IDE vs Maven stuff I could not figure out yet. – Martin Kersten Sep 23 '15 at 12:48
  • @MartinKersten Tunaki is right: When cleaning a project, the M2E plugin does nothing. But it will do some things, when a build is invoked because Eclipse projects that have the Maven nature also have a Maven builder attached. – Seelenvirtuose Sep 23 '15 at 12:51
  • OK so in the end M2E is leaving it untouched. Thanks for the clarification. I thought that having a clean target M2E might have issued this instead. – Martin Kersten Sep 23 '15 at 12:54
  • Also a Eclipse Action is replaceable by any plug-in extending the eclipse platform so using such a tool integrating into the IDE can actually change anything. I should have asked a different question with different explanation reducing the chance of getting confused. – Martin Kersten Sep 23 '15 at 12:55
  • @MartinKersten Much better reception this time. All you had to do was delete the question and come back later... – takendarkk Sep 23 '15 at 13:02
  • Still having problem what implying a question by a sentence means :-)? Also it is called learning curve. Stackoverflow is quite a different audience. – Martin Kersten Sep 23 '15 at 13:05
  • I see how they learned to continue to downvote your question :) Don't worry, I'll keep watch so I can learn from you. – takendarkk Sep 23 '15 at 13:06
  • Your question is "what happens on Project > Clean when it comes to Maven". The answer is "Nothing". If you want a more complete answer, you will need to tell exactly what you want to do, what you already did, what did not work and what you expect. It is hard to answer otherwise. – Tunaki Sep 23 '15 at 13:16
  • Yeah now read my answer and remember why you want to close this and thought it was 'stupid' to be asked. It is not happening nothing, it is by default configured to nothing has to happen. Big difference – Martin Kersten Sep 23 '15 at 13:23
  • Also the line: >I wonder if when I hit Project > Clean, mvn is really involved in setting up the build process.< says exactly well what was asked. – Martin Kersten Sep 23 '15 at 14:11

2 Answers2

2

When you clean a eclipse project, eclipse clears output directories of the project, without invoking maven. This is a eclipse operation that is executed over all projects you have, whether or not the projects has been imported from maven.

If you want to run maven targets on an imported eclipse project, you could use Run configurations to explicitly invoke maven targets on the projects.

malaguna
  • 4,183
  • 1
  • 17
  • 33
  • I found a better explaination what really happens. I post my own answer but yours is valid too. – Martin Kersten Sep 23 '15 at 13:15
  • By the way thanks for your answer, I really appreciated and it finally lead myself to the full picture which is worth knowing when messing with the default build cycle as I currently do. So many thanks! – Martin Kersten Sep 23 '15 at 13:31
1

M2E does has its own mapping for each phase. Depending on this mapping Eclipse actions are replaced, extended or left-as-is.

Configuration of each Maven Phase and how it is handled by M2E integration.

From the following picture one can see that the clean command is set to ignore. You can view/change those mappings by Project Properties > Maven > Lifecycle Mapping. So this is actually (as-expected) a per phase mapping. By downloading new connectors M2E is able to provide additional mappings to special phases not supported by default installation.

Martin Kersten
  • 5,127
  • 8
  • 46
  • 77