Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

From the Gradle's code I found that there are methods : TemporaryFileProvider and TestNameTestDirectoryProvider for creating temporary file and folder but they are not part of the public API.

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

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

PS. I use org.junit.rules.TemporaryFolder for JUnit tests and Java's File.createTempFile

like image 590
Xelian Avatar asked Aug 03 '14 12:08

Xelian


People also ask

How do I create a tmp folder?

Open your File Explorer (it's usually the first button on your desktop taskbar, looks like a folder). Go to the "This PC" section on the left, and then double-click your C: drive. On the Home tab at the top, click "New Folder" and name it "Temp".

How to create temporary Files in Java?

A temporary file can be created using the method java. io. File. createTempFile().


1 Answers

Task implementations can use task.getTemporaryDir().createNewFile(). What to use in JUnit tests isn't Gradle's business, but org.junit.rules.TemporaryFolder would be my default choice.

like image 115
Peter Niederwieser Avatar answered Oct 16 '22 12:10

Peter Niederwieser