Hello,
I use as subproject a project with ant build.xml and other important file in the {buildDir}.
I know this is bad but it is not my project. I have just added a build.gradle in it to launch every task of the subproject from my main project.
The problem here is if someone launch the clean Task, subproject is destroyed.
I am interrested in two kind of solutions:
1.When someone launch the clean task -> do nothing
2.When someone launch the clean Task -> do something else instead
Are those two solutions possible and how?
Best Regards
By default the behavior of the ‘clean’ task is to delete project.buildDir
. You have a couple options.
As for solution number #1 you can:
- Disable the task with
clean.enabled = false
- Have it simply do nothing by setting the paths to delete to an empty list
clean.delete = []
For solution #2 you’ll want to go with option 2 above and then specify your own behavior:
- Have it delete something else via
clean.delete 'some/dir', 'some/otherDir'
- Or do whatever you want via a custom task action
clean.doLast { // arbitrary code }
At first , i used “clean.enabled = false” in my subproject and it worked flawlessly.
Then i had the time to trully customize the task to delete only files into two directories of my subproject like this
clean.delete=[]
clean {
delete fileTree(‘tmp’).include(’**/’),fileTree(‘dist’).include(’**/’)
}
Thank You.