Quantcast
Channel: Gradle Forums - Latest posts
Viewing all articles
Browse latest Browse all 19888

How can I delete a file from inside a task?

$
0
0

I’m trying to make a custom task, written in Kotlin, that generates a file through a commandline command. The problem is that this the external commandline program can’t handle if the generated file already exists.

So, what I am trying to do inside my @TaskAction is to delete the contents of the output directory before running the command.

I tried to do the following, but I get Gradle import errors and Project resolve errors.

project.delete(
    fileTree("${project.buildDir}/jpackageAppImage")
)

When I look in the docs for delete, it says that the input to that function can be

Any type of object accepted by files(Object...)

When I look at the docs for files, it says it accepts a a FileTree

Can anyone help me out with this?


Viewing all articles
Browse latest Browse all 19888

Trending Articles