How to delete project folders outside the usual maven clean phase

+1 vote
asked Sep 13, 2017 by asanke

This might sound bit off, but here is what I want;

I have a project that generates files in my target directory (so as every average project). I have configured maven clean to be executed in every build using the below.


I also have couple of other folders outside target (I have deliberately opted to ) which store logs and test reports. These I do not want to clean in every run as I want them to refer for a certain period.

The project roughly looks like below.


Here the logs and reports are the folders I want to prevent getting deleted in every run. I was able to manage the part that the report and logs folders not getting deleted in every run. ( pretty straight forward, don't mention of the two folders in your build)

However, I also need to have a maven command to delete these two special folders once in a while. How can I do that ?

1 Answer

+2 votes
answered Sep 13, 2017 by vonc

You could consider adding a profile in which you set a different clean process:




Calling it with mvn clean -PcleanLog would call that specific build process.
See also this tutorial on maven profiles.

Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter