Maven: clean the webapp directory before the war: exploded?

quote from plugin usage page while using maven :

<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 to clear the contents of a directory defined in <webappDirectory>/sample/servlet/container/deploy/directory</webappDirectory> before blowing up a war file?

In my experience, a folder defined as webappDirectory will not be emptied, and therefore will have unrelated files that were part of webapp.

It will be great if I can add something to the current im command currently used to clear webappDirectory, something like this:

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

Thanks!

+4
source share
1 answer

You might want to look at adding the maven clean plugin by specifying the desired folder for cleaning. Something like below ... Note that directory must 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> 
+6
source

Source: https://habr.com/ru/post/1344051/


All Articles