Exclude directories in clean task

Am new to Gradle, so bear with me if it sounds dumb.

Am in the process of moving an existing maven project to gradle for various reasons. Now my maven projects creates some files in the target folder when the java application is run, these files we usually exclude from clean phase by configuring clean-plugin of maven, How to do something similar in Gradle. i.e, exclude specific directories from clean task (files, folders that were created by the application itself and not by any Gradle task).

Hey,

you can configure the clean task with an exclude pattern:

clean {
    excludes '**/appFolder/**'
}
2 Likes

Sorry, Am just getting back to some gradle work again after a long time.
Trying to exclude directories in clean

clean {
excludes ‘/appFolder/
}

But I get this error now.

Could not find method excludes() for arguments [/appFolder/] on project.

And just to be sure that I can do any customization with clean at all tried.

clean {
delete “new/file”
}
And this works.