How to create a temporary file / folder using the public Gradle API?

From the Gradle code, I found that there are methods: TemporaryFileProvider and TestNameTestDirectoryProvider for creating temporary files and folders, but they are not part of the public API.

org.gradle.api.internal.file.TemporaryFileProvider org.gradle.test.fixtures.file.TestNameTestDirectoryProvider 

If there are any methods from the public Gradle API that gives the user the ability to create temporary files and folders, and if not, what are the ways to do this?

PS. I am using org.junit.rules.TemporaryFolder for JUnit and Java File.createTempFile

+8
file junit folder gradle temporary
source share
1 answer

Task implementations can be used by task.getTemporaryDir().createNewFile() . What to use in JUnit tests is not Gradle's business, but org.junit.rules.TemporaryFolder will be my default choice.

+9
source share

All Articles