I am having a little trouble building jar from gradle project. Namely gradle doesn't include my resource folder even though i have it specified in build.gradle as shown below:
plugins {
id 'application'
}
repositories {
mavenCentral()
}
application {
mainClass = 'skorupinski.xmass.Main'
}
sourceSets {
main {
java {
srcDirs = ['./src/main/java']
}
resources {
srcDirs = ['./src/main/resources']
}
}
}
jar {
manifest {
attributes(
'Main-Class': 'skorupinski.xmass.Main'
)
}
baseName = 'hi'
}
There are images in the resource folder that I load into my java program. When I run the jar file it returns an error that it coudln't file the image file unless i put the jar in the same directory as src folder.
May be you should try exclusively specifying the include
in jar section of build.gradle
jar {
// try adding this
from('src/main/resources') {
include '**/*.*'
}
manifest {
attributes(
'Main-Class': 'skorupinski.xmass.Main'
)
}
baseName = 'hi'
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.