I’ve a demo Lucene project that builds a Jar using the Java plugin. MANIFEST.MF does not define a Main class and when I try to run a class from the Jar using
java -cp build/libs/lucene-demo-1.0.jar org.apache.lucene.demo.IndexFiles
it can’t find the dependencies and fails with the following:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/lucene/analysis/Analyzer Caused by: java.lang.ClassNotFoundException: org.apache.lucene.analysis.Analyzer at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
I see that the assemble task copies the dependencies to a directory called ‘lib’ in the Jar but I don’t see those added to MANIFEST.MF classpath. That, anyway, doesn’t work in this case because no Main class is defined; there’re multiple classes that can act as entry point to the Jar. Maven solves this problem by providing an option to extract the dependencies in the jar. Is there something similar in Gradle?