Bertie
Bertie

Reputation: 17697

Maven: clean the webapp directory before war:exploded?

quoting from maven war plugin usage page :

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.1.1</version>
        <configuration>
          <webappDirectory>/sample/servlet/container/deploy/directory</webappDirectory>
        </configuration>
      </plugin>
    </plugins>
  </build>
  ...
</project>

How do i clean the content of the directory defined in the <webappDirectory>/sample/servlet/container/deploy/directory</webappDirectory> before exploding the war file ?

In my experience, the folder defined as the webappDirectory wont get cleaned, and so will have nonrelated files that was part of the webapp.

It'll be cool if i can add something to the current command im currently using to clean the webappDirectory, which is something like this :

mvn -o clean <cleanWebappDirectory here?> install war:exploded

Thank you !

Upvotes: 4

Views: 2794

Answers (1)

Raghuram
Raghuram

Reputation: 52635

You may want to look at adding the maven clean plugin, specifying the requisite folder to be cleaned. Something like below... Note that the directory should be relative.

<build>
  [...]
  <plugin>
    <artifactId>maven-clean-plugin</artifactId>
    <version>2.4.1</version>
    <configuration>
      <filesets>
        <fileset>
          <directory>sample/servlet/container/deploy/directory</directory>
          <includes>
            <include>*</include>
          </includes>
        </fileset>
      </filesets>
    </configuration>
  </plugin>
  [...]
</build>

Upvotes: 6

Related Questions