Maven - Why after “mvn clean” I need to execute “Maven Update Project” before “mvn package”?

后端 未结 3 649
北荒
北荒 2020-12-31 11:34

I\'m making some tests and I would like to understand why after execute the command mvn clean I need to execute \"Maven > Update Project\" before run mvn

3条回答
  •  情书的邮戳
    2020-12-31 11:56

    The Eclipse m2e plugin (this is a simplification) reads the POM file and translates it into instructions for Eclipse so that Eclipse can do its thing. Because Eclipse is in control the whole time, your view gets updated correctly and things are pretty smooth. Some more advanced Maven actions with plugins are not supported by m2e, and so those actions just won't happen. Some simple stuff, like the classpath is different from how Maven does things -- m2e uses the "test" classpath no matter what because Eclipse can't predict what you'll want to run.

    On the other hand, performing "Run as > Maven ..." actually calls Maven, a program completely outside of Eclipse, and asks it to run. Eclipse doesn't automatically know when files have been created or deleted by Maven.

    I would generally stay away from the "Run as > Maven" commands. The integration is poor, the Eclipse console interface is ugly, it's just easier to call mvn from the command line if you need to run specific Maven goals.

    If you just want to develop a Maven project, I find the m2e integration works very well. I use Jenkins to handle the packaging and deployment for me, so I'm only using Eclipse to edit and test my code.

提交回复
热议问题