I have a personal project written in Java where I was using Maven so far. I'm migrating to Gradle to force myself to learn it (using it at work now). My intention is to produce a fat/uber jar.
When launching the .jar file, I'm getting a ClassNotFoundException because the main class cannot be found.
This is the build.gradle section where the Jar manifest is defined:
def mainClassName = 'GUI.APP_GUI'
jar {
destinationDirectory = file(project.rootDir)
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
from {
project.configurations.runtimeClasspath.collect {
//println it
it.isDirectory() ? it : zipTree(it)
}
}
manifest {
attributes(
"Main-Class": "$mainClassName",
"Manifest-Version": "1.0",
)
}
}
The Jar's manifest file does indicate the correct main class:
Manifest-Version: 1.0
Main-Class: GUI.APP_GUI
Yet, I get an exception caused by:
java.lang.ClassNotFoundException: GUI.APP_GUI
What am I missing?
Thanks!