I was trying to create a fat jar for my project in gradle . I was using this code to create the jar .
jar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
manifest {
attributes(
'Main-Class': 'com.kroger.cxp.app.Main'
)
}
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
}
But When I tried to runt the jar it threw "could not find or load main Class" Error. I searched and changed my code to
jar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
manifest {
attributes(
'Main-Class': 'com.kroger.cxp.app.Main'
)
}
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}{
exclude "META-INF/*.SF"
exclude "META-INF/*.DSA"
exclude "META-INF/*.RSA"
}
}
After adding these exclude META-INF lines I was able to run the jar but i still don't understand how this fixed the issue ? What the these META-INF files and how removing them helps here.