Nav
Nav

Reputation: 20658

How to add an external file to the jar using gradle?

Until recently I was just using a simple Java project. I recently decided to upgrade it to use a gradle wrapper and Netbeans 12, but now the program is unable to detect the beep3.wav file.

Earlier, I had managed to get the project to automatically embed the wav file into the jar. But now the project properties do not have any such option, which I assume is because the embedding has to be done via gradle. Even though the file is visible as part of the project, I couldn't see it in the jar when I opened the jar using archive manager.
enter image description here

I've seen this, this and many other pages, but none of them have info on adding files to the jar, so I'm assuming I'm looking for the wrong info.

Could you help with this please? I just need to get that wav file to automatically get inserted into the jar when I build the project.

Upvotes: 0

Views: 550

Answers (1)

andreoss
andreoss

Reputation: 1800

You just add your files to src/main/resources and they end up in your jar.

Upvotes: 2

Related Questions