carnivorous jazz
carnivorous jazz

Reputation: 41

Access files in the Gradle dist directory

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?

Upvotes: 3

Views: 848

Answers (1)

carnivorous jazz
carnivorous jazz

Reputation: 41

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.

Upvotes: 1

Related Questions