How can I merge the resources and the classes for the classpath of the “run” task?
I am reworking the build.gradle of the open source game “Terasology”. https://github.com/MovingBlocks/Terasology/blob/develop/build.gradle
It defines an own “run” task but I try to use the gradle “run” task. Both variants have a problem with the resource files. The program needs the resource files at the same folder like the classes. Running from a JAR file or from an IDE (eclipse) works fine, because the resource files are copied to the class files.
The current (and working) solution changes the output.
sourceSets {
main {
output.resourcesDir = 'target/classes/main'
}
}
But this solution needs an ugly fix for the JAR task, because the resource files are twice.
jar.doFirst {
// Work around for duplicate entries in jar bug
sourceSets.main.output.resourcesDir = '/dev/null'
}
jar.doLast {
sourceSets.main.output.resourcesDir = 'target/classes/main'
}
Is it possible (and wise) to copy the classes and resources to a new “run” folder and use this as the classpath for the “run” task?