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
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.
Here is what happens:
mvn clean
deletes the target
directorymvn package
performs some work, but then encounters a compilation error due to a missing dependency. That's why the target folder is in error. target
directory has all the compiled classes.mvn package
now succeeds, because it finds all the classes already compiled and doesn't need to perform any compilation.Ultimately, the problem is in the project configuration in pom.xml
. I had the same problem, and after adding the missing dependency I successfully compiled project with Maven.
It will update the files if any new updates avialable.you can use maven install after maven clean