Search code examples
mavenmaven-3maven-war-plugin

Prevent war file from being copied to .m2/repository when running mvn clean install


We have a multi-module Maven project and we typically run mvn clean install to build everything. Preferably, we'd like to keep it this way.

What we would like to do is prevent projects with packaging war (that are using the maven-war-plugin) to copy their generated war files to the ~/.m2/repository folder. How can we achieve this?


Solution

  • You can skip the execution of the maven-install-plugin inside each of your war projects, using the skip attribute. It is this plugin that is responsible for copying the produced artifact into the local repository.

    <plugin>
        <artifactId>maven-install-plugin</artifactId>
        <version>2.5.2</version>
        <configuration>
            <skip>true</skip>
        </configuration>
    </plugin>