How do I extend gradle's clean task to delete a file?

前端 未结 5 823
傲寒
傲寒 2021-02-01 00:29

So far i\'ve added the following to my build.gradle

apply plugin: \'base\' 
clean << {
    delete \'${rootDir}/api-library/auto-generated-classes/\'
    pr         


        
5条回答
  •  日久生厌
    2021-02-01 01:09

    You just need to use double quotes. Also, drop the << and use doFirst instead if you are planning to do the deletion during execution. Something like this:

    clean.doFirst {
        delete "${rootDir}/api-library/auto-generated-classes/"
        println "${rootDir}/api-library/auto-generated-classes/"
    }
    

    Gradle build scripts are written in Groovy DSL. In Groovy you need to use double quotes for string interpolation (when you are using ${} as placeholders). Take a look at here.

提交回复
热议问题