Resource file missing from JAR after gradle build

337
February 17, 2017, at 06:49 AM

I have a resource file call names.txt that is called by my code when I hit a rest endpoint.

This is held in src//main//resources//names.txt. I have an application.yml that references the file location as such

file:
    namesPath: src//main//resources//names.txt

when I build and run my solution everything works fine. If i run the jar from the commandline outside the IDE it also works fine.

How ever if I copy that JAR to another instance, it complains and says that it cannot find the file referenced

If I browse the JAR the file is there but it is under BOOT-INF/Classes/names.txt

How do I solve this so I can deploy the JAR wherever I want?

Answer 1

It is hard to say what is wrong without seeing your build.gradle file but I would expect if you put something like below in your build file the resource files should end up in the right location:

sourceSets {
    main {
        java {
            srcDirs = ['src/main/java', 'src/gen/java']
        }
        resources {
            srcDirs = [src/main/resources']
        }
    }
    ....
}
READ ALSO
Invalid certificate error with Geckodriver on FF 51

Invalid certificate error with Geckodriver on FF 51

I am using Selenium 3 on Firefox 510

561
How often does garbage collection occur in a typical managed desktop application?

How often does garbage collection occur in a typical managed desktop application?

I'm reading about garbage collection schemes and how they're optimized, but it's hard for me to grasp the tradeoffs because I don't have a feel for how often garbage collection is going to happenI tried Googling but couldn't find much of anything

313
Get all selected checkboxes in Java

Get all selected checkboxes in Java

I have a dialog in Java that presents ~ 15 checkboxes to the userIs there a way to get the names of all the checked checkboxes at once? Currently, I'm looking one by one if they are selected, which isn't that fancy of a solution

431
Java message not sending to server unless prior client instance is closed

Java message not sending to server unless prior client instance is closed

I am creating a program in which a server can receive messages from multiple clientsThe clients would create the connection and upon clicking a button, sending information and then close the connection (not a back and forth live chat program)

293