Right now I am having this issue where I need to have my SpringBoot application be turned into an executable jar, but it needs to be done in a task as opposed to just a configuration in the gradle.build.
So the below snippet in my build.gradle
will produce an executable jar:
jar {
manifest {
attributes 'Main-Class': 'com.path.name.to.main.App'
}
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
}
Everything works, but when I make the jar creation a task the jar no long becomes executable and throws this error Error: Could not find or load main class com.path.name.to.main.App
:
task makeJar(type: Jar) {
archiveName = 'app.jar'
manifest {
attributes 'Main-Class': 'com.path.name.to.main.App'
}
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
}
The way my company does deployments it is advisable to have the jar creation in a task in the build.gradle
as opposed to the configuration mentioned above.
However, I'm not really sure why moving it from jar
config to a task would affect the outcome of the actual jar that was created and what do I need to do to fix this?