build.gradle - How do I extend gradle's clean task to delete a file? -
so far i've added following build.gradle
apply plugin: 'base' clean << { delete '${rootdir}/api-library/auto-generated-classes/' println '${rootdir}/api-library/auto-generated-classes/' }
however not file not deleted, print statement shows ${rootdir}
not being converted root directory of project. why won't work, concepts missing?
you need use double quotes. also, drop <<
, use dofirst
instead if planning deletion during execution. this:
clean.dofirst { delete "${rootdir}/api-library/auto-generated-classes/" println "${rootdir}/api-library/auto-generated-classes/" }
gradle build scripts written in groovy dsl. in groovy need use double quotes string interpolation (when using ${}
placeholders). take @ here.