Access files in the Gradle dist directory

Viewed 701

Working on a Gradle project and I want to have loose data files so that more can be loaded on the fly.

I need to load these files from the Java application the Gradle project is made for.

How would I load files that are placed in the src/dist directory so they are still accessible when the program is packaged?

1 Answers

I ended up figuring out a method myself.

System.getProperty("user.dir")

gets the directory the program was launched from.

In a Gradle packaged project, that's the bin folder. You can just move up a directory from there.

Running it from an IDE it's the root project folder which is harder to deal with. A better method would be nice to have, but this works for now.

Related