Magnus
Magnus

Reputation: 8300

Conventional file system path for gradle test files

I have a standard gradle java project. My tests need to both read and output files to the filesystem. The files should exist within the project directory only and the output files should be automatically deleted when the gradle project is cleaned.

Gradle seems to have conventional directories for source files and test source files.

What is the conventional relative path that should be used to place input and output files used and generated by the test code.

Upvotes: 1

Views: 252

Answers (1)

Radim
Radim

Reputation: 4808

I'd prefer to use java.io.tmpdir for your temporary files and access that place using common methods that are part of Java libraries. See http://docs.oracle.com/javase/tutorial/essential/io/file.html#creating or http://docs.oracle.com/javase/7/docs/api/java/io/File.html#createTempFile(java.lang.String,%20java.lang.String)

If that does not work for you you can pass a system property to your test runner process telling it where to create those files. That property can be easily set to some place under build directory in your project.

Upvotes: 2

Related Questions