简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM