i know this is probably frowned upon by maven lovers, but the whole 'target' directory is a waste of space in the context of our program and it's deployment. we have other build processes responsible for creating the actual deployment and i currently manually delete the target dir after every maven build, so that its contents don't interfere with my file searches etc...
is there a way to delete this dir automatically at the end of a maven build/install?
thanks, p.
Use the maven-clean-plugin as here http://maven.apache.org/plugins/maven-clean-plugin/examples/delete_additional_files.html
<project>
[...]
<build>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.4.1</version>
<executions>
<execution>
<id>auto-clean</id>
<phase>install</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
[...]
</project>
You should simply add the clean goal to your maven goals at the end.
mvn install clean
The problem with the clean-plugin is that if you like to run the clean at the end of the build it depends which goal you called at the beginning. For example you called mvn package you need to have a phase post-package which does not exist or if you called mvn install you have to have phase post-install which does not exist either.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With