In Maven, Why Run 'mvn clean'?

前端 未结 4 555
鱼传尺愫
鱼传尺愫 2020-12-01 04:19

I am wondering what the major difference between running mvn compile and mvn clean compile are, in practicality.

I understand what the actu

4条回答
  •  天涯浪人
    2020-12-01 04:51

    Certain plugins require a clean in order to work properly. For instance (at least in Maven 2), the maven-war-plugin explodes each dependent WAR into an existing directory tree. It requires a clean to get rid of files that have been removed from the dependent WARs.

    Another problem is that when you rename a class, the old compiled version can hang around in the build tree, and will get included in JAR files, etcetera ... until you run mvn clean.

    I can assume "mvn compile" will regenerate files if it's necessary, right?

    For mainstream plugins, that is a fair assumption. However, if you are using a plugin to generate source code components, I'd look carefully at the documentation, and at where you put the generated source code. For instance, there are a couple of unsupported plugins whose purpose is to drive the Eclipse EMF code generator.

提交回复
热议问题