Open bric3 opened 6 years ago
I can imagine that this comes from the upgrade of JRuby from 1.7.x to 9.x.x.x together with Spring Boot. The new JRuby contains some changes regarding class loading and since has an own packaging format I could imagine that this is no longer compatible.
Imo this issue is better suited for the spring rest docs project unless it is reproducible with a build that is completely independent of sprint rest docs.
@robertpanzer I didn't updated spring-* dependencies or any other, just asciidoctor ones.
I did not mean that a spring dependency was updated, but that JRuby was most probably updated to another major version. And it seems like that the way Spring Boot handles class loading (of which I have no knowledge at all) is incompatible with this.
I will verify this. But it is quite unlikely since gradle uses a specific classpath when the asciidoctor task is executed (look at the last snippet form the original ticket.
Also note that spring boot classloading has nothing to do in this as well, because documentation is read from files in the repository directories. spring-restdocs-asciidoctor
only allows asciidoctor to understand some variables, this dependency contains 4 classes.
@robertpanzer I created a very simple project, that demonstrate the issue. https://github.com/bric3/asciidoctorj-issue661
No spring (but the extension), no jruby dependencies, just asciidoctor. As said the extension contains 4 classes and has no dependencies : https://github.com/spring-projects/spring-restdocs/tree/v1.2.4.RELEASE/spring-restdocs-asciidoctor.
It seems to work for me if I put the dependencies at the right place:
buildscript {
repositories { jcenter() }
dependencies {
classpath 'org.asciidoctor:asciidoctor-gradle-plugin:1.5.7'
}
}
//...
dependencies {
asciidoctor "org.springframework.restdocs:spring-restdocs-asciidoctor:$springRestDocs"
asciidoctor 'org.asciidoctor:asciidoctorj-diagram:1.5.9'
}
//...
oohhhhh
I hard a hard time to make diagrams to work because the example repo is out of date. My configuration was inspired by this issue https://github.com/asciidoctor/asciidoctor-gradle-examples/issues/15 especially and with other resources on the internet.
I don't know when it changed (or not), but the usage documentation should clearly be updated.
Anyway thanks for the tip !
Hmmm... I can't really tell what the difference is, but adding the asciidoctor extensions to the script classpath looks wrong to me. It's subtle, but the Asciidoctor Gradle plugin creates an own Classloader to load AsciidoctorJ. Then bringing in an extension from the parent doesn't look right. (In the same way you already added spring-restdocs-asciidoctor to the asciidoctor configuration instead of adding it to the build class path)
I'm glad that we now found the problem, thanks for the reproducer :)
Yeah it makes sense, but as it worked with 1.5.8, it looked weird. Maybe the exception message could be more meaningful, e.g. :
Did you place the
asciidoctorj-*
dependency in theasciidoctor
configuration, otherwise it cannot see extensions.
Upgrading
asciidoctorj-diagram
inbuild.gradle
to 1.5.9 make our build fail. Using version 1.5.8 fixes the issue.Gradle : 4.8.1 OS: Mac OSX 10.13.5 JDK: HotSpot 1.8.0_172-b11 asciidoctorj-diagram : 1.5.9 asciidoctorj : 1.5.7 asciidoctor-gradle-plugin : 1.5.7
Build log with info and stacktraces
Using info and stacktraces, I can see that JRuby is having some issue to load the Spring preprocessor. I noticed a few interesting bits here :
The version that asciidoc finds is 1.5.6, while it has been set to 1.5.7.
The stacktrace suggest JRuby fails to see load the
DefaultAttributesPreprocessor
class of a jar, but succeed to loadRestDocsExtensionRegistry
.The full log :
build.gradle
build environment
asciidoctor
task dependencies