asciidoctor / asciidoclet

:clipboard: A Javadoc Doclet based on Asciidoctor that lets you write Javadoc in the AsciiDoc syntax.
https://github.com/asciidoctor/asciidoclet
Apache License 2.0
133 stars 40 forks source link

java.lang.NoClassDefFoundError when using command line #38

Closed jmbruel closed 8 years ago

jmbruel commented 9 years ago

I am trying to use asciidoclet in command line:

javadoc ... -doclet org.asciidoctor.Asciidoclet -docletpath doclet/asciidoclet-1.5.0.jar ...

And I get: javadoc: error - In doclet class org.asciidoctor.Asciidoclet, method optionLength has thrown an exception java.lang.reflect.InvocationTargetException java.lang.NoClassDefFoundError: com/google/common/collect/ImmutableList

Any idea? Thanks in advance

johncarl81 commented 9 years ago

You're probably not pulling in all the dependencies of Asciidoclet (which there are quite a few). Any reason why you aren't using a CLI build tool?

jmbruel commented 9 years ago

Guess I'll have to ;-) No reason other than the fact that this is for a course (B.Sc. kind of level) and they are only using scripting techniques so far.

johncarl81 commented 9 years ago

This is a really good point though, we could shade the dependencies of Asciidoclet to make it a single unified jar to avoid problems like this.

jmbruel commented 9 years ago

I raised the point because I had no problem with the plantuml doclet (also a jar file). http://plantuml.sourceforge.net/doclet.html

johncarl81 commented 9 years ago

I was tinkering around with the shade plugin, if you'd like to try the single-jar result here's a link: https://oss.sonatype.org/content/repositories/snapshots/org/asciidoctor/asciidoclet/1.5.2-SNAPSHOT/asciidoclet-1.5.2-20141128.154014-1.jar ^ Wow, 51 megabytes

jmbruel commented 9 years ago

This works great in command-line! Thanks a lot. Should make it available :-) Great job.

johncarl81 commented 9 years ago

@benevans, @mojavelinux what are your thoughts on combining the artifact and dependencies into one jar? Personally, I was surprised by the size of the result but I wonder if there's something we can do to reduce this.

mojavelinux commented 9 years ago

@johncarl81 The shaded jar is huge because of a packaging bug introduced in AsciidoctorJ 1.5.0 (and present in 1.5.1). AsciidoctorJ 1.5.2 will be 650K (which doesn't include JRuby). If we can figure out what to take from JRuby specifically, then we might be able to get the contribution from JRuby down.

Another approach here is to create a distribution, which we'll be doing with AsciidoctorJ 1.5.2.

(We've switched to Gradle for the build, which makes creating a distribution jar super simple. It even provides a launcher script).

johncarl81 commented 9 years ago

I guess we'll wait for 1.5.2 for this then.

mojavelinux commented 9 years ago

That's what I recommend. We should have it out by this weekend.

mojavelinux commented 9 years ago

1.5.2 is out!

Btw, what we're talking about here is both a distribution and a fat jar. A distribution is just putting everything in one zip with a launcher script to run the java command with everything on the classpath (Gradle provides this out of the box). A fat jar is when you stuff everything into a single jar. The convention for naming a fat jar is *-all.jar or *-complete.jar.

johncarl81 commented 8 years ago

This should be available in the upcoming 1.5.3 release.