asciidoctorj-screenshot icon indicating copy to clipboard operation
asciidoctorj-screenshot copied to clipboard

[Bug] Closing problem when multiple backends including PDF

Open bcouetil opened this issue 6 years ago • 4 comments

I understand that the plugin is not intended to work with PDF.

But, under Maven, I generate my documentation for Reveal.js, HTML and PDF together, and I have a critical bug when going through the PDF generation :

GRAVE: (NameError) no method 'process' for arguments (org.jruby.RubyObjectVar9,org.jruby.RubyObjectVar9) on Java::OrgAsciidoctorExtension::ShutdownGebPostProcessor
  available overloads:
    (org.asciidoctor.ast.Document,java.lang.String)
    (org.asciidoctor.ast.DocumentRuby,java.lang.String)

I tried wrapping the code with ifndef::backend-pdf[] without success, before finding that, even without using any block, simply having the Maven dependency gives the critical error. And I did not find a way to have a Maven dependency only on a specific execution.

Just searching for a way to not block the process...

bcouetil avatar Jan 18 '19 14:01 bcouetil

This sounds a lot like there are multiple versions of asciidoctorj on you classpath. Can you post configuration for the asciidoctor-maven-plugin in your pom.xml file.

sclassen avatar Jan 21 '19 13:01 sclassen

Sure, here it is :

<plugin>
    <groupId>org.asciidoctor</groupId>
    <artifactId>asciidoctor-maven-plugin</artifactId>
    <!-- to increment versions, see pom.xml examples on Asciidoctor Github -->
    <!-- 1.5.7 and 1.5.7.1 show too many warnings on PDF -->
    <version>1.5.6</version>
    <inherited>false</inherited>
    <dependencies>

        <dependency>
            <groupId>org.asciidoctor</groupId>
            <artifactId>asciidoctorj-pdf</artifactId>
            <version>1.5.0-alpha.16</version>
        </dependency>

        <dependency>
            <groupId>org.asciidoctor</groupId>
            <artifactId>asciidoctorj-diagram</artifactId>
            <version>1.5.9</version>
        </dependency>

        <!-- comment to use the default version -->
        <dependency>
            <groupId>org.jruby</groupId>
            <artifactId>jruby-complete</artifactId>
            <version>9.1.17.0</version>
        </dependency>

        <!-- comment to use the default version -->
        <!-- <dependency>
            <groupId>org.asciidoctor</groupId>
            <artifactId>asciidoctorj</artifactId>
            <version>1.5.7</version>
        </dependency> -->

        <!-- install chrome-driver 
            Win10 : choco install chromedriver
            Linux : apt-get install chromium-chromedriver -->
        <dependency>
            <groupId>org.asciidoctor</groupId>
            <artifactId>asciidoctorj-screenshot</artifactId>
            <version>0.2.2</version>
        </dependency>
        <dependency> 
            <groupId>org.gebish</groupId>
            <artifactId>geb-core</artifactId>
            <version>2.3</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-all</artifactId>
            <version>2.4.16</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-support</artifactId>
            <version>3.141.59</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-chrome-driver</artifactId>
            <version>3.141.59</version>
        </dependency>
        
    </dependencies>
    <configuration>
        <sourceDirectory>src/docs/asciidoc</sourceDirectory>
        <requires>
            <require>asciidoctor-diagram</require>
            <!-- block extension to include c3js (line/spline/step/area/area-spline/area-step/bar/scatter/pie/donut/gauge) -->
            <require>./src/docs/asciidoc/lib/c3js-block-macro.rb</require>
        </requires>
        <attributes>
            <icons>font</icons>
            <idseparator>-</idseparator>
            <idprefix />
            <!-- custom -->
            <project-version>${project.version}</project-version>
            <root-project-dir>${user.dir}</root-project-dir>
            <history-dir>${project.build.directory}/generated-docs/history</history-dir>
            <project-images-dir>${project.basedir}/src/main/resources/images</project-images-dir>
            <plantuml-config>themes/plantuml.cfg</plantuml-config>
            <screenshot-dir-name>screenshots</screenshot-dir-name>
        </attributes>
    </configuration>
    <executions>
        <execution>
            <id>asciidoc-to-revealjs</id>
            <!-- after html because it's also an html -->
            <phase>generate-resources</phase>
            <goals>
                <goal>process-asciidoc</goal>
            </goals>
            <configuration>
                <backend>revealjs</backend>
                <outputDirectory>${project.slides.directory}/reveal</outputDirectory>
                <templateDir>${project.build.directory}/asciidoctor-reveal.js-${asciidoctor-revealjs.version}/templates</templateDir>
                <attributes>
                    <source-highlighter>highlightjs</source-highlighter>
                    <highlightjs-theme>lib/highlight/styles/gruvbox-dark.min.css</highlightjs-theme>
                    <revealjsdir>../reveal.js-${revealjs.version}</revealjsdir>
                    <!-- default closest to Zenika's graphic chart : -->
                    <!-- <revealjs_theme>blood</revealjs_theme> -->
                    <revealjs_customtheme>themes/css/reveal-zenika-tokyo-shibuya.css</revealjs_customtheme>
                    <!-- none, fade, slide, convex, concave, zoom -->
                    <!-- dynamic : PRES-asciidoc.html?transition=convex -->
                    <revealjs_transition>slide</revealjs_transition>
                    <revealjs_slideNumber>true</revealjs_slideNumber>
                    <!-- does not work T_T -->
                    <!-- <favicon>themes/favicon.png</favicon> -->
                    <revealjs_width>1100</revealjs_width>
                    <revealjs_height>700</revealjs_height>
                    <revealjs_plugins>revealjs-plugins/revealjs-plugins.js</revealjs_plugins>
                    <revealjs_plugins_configuration>revealjs-plugins/revealjs-plugins-conf.js</revealjs_plugins_configuration>
                    <docinfo>shared</docinfo>
                    <toc>macro</toc>
                    <toclevels>1</toclevels>
                </attributes>
            </configuration>
        </execution>
        <execution>
            <id>asciidoc-to-html</id>
            <phase>generate-resources</phase>
            <goals>
                <goal>process-asciidoc</goal>
            </goals>
            <configuration>
                <backend>html5</backend>
                <sourceHighlighter>highlight.js</sourceHighlighter>
                <attributes>
                    <highlightjsdir>lib/highlight</highlightjsdir>
                    <highlightjs-theme>gruvbox-dark</highlightjs-theme>
                    <imagesdir>./images</imagesdir>
                    <toc>left</toc>
                    <toclevels>2</toclevels>
                    <sectanchors>true</sectanchors>
                    <favicon>themes/favicon-white.png</favicon>
                    <linkcss />
                    <stylesheet>html-zenika.css</stylesheet>
                    <stylesdir>themes/css</stylesdir>
                </attributes>
            </configuration>
        </execution>
        <execution>
            <id>asciidoc-to-pdf</id>
            <phase>generate-resources</phase>
            <goals>
                <goal>process-asciidoc</goal>
            </goals>
            <configuration>
                <backend>pdf</backend>
                <sourceHighlighter>rouge</sourceHighlighter>
                <attributes>
                    <imagesdir>${project.build.directory}/generated-docs/images</imagesdir>
                    <toc />
                    <toclevels>3</toclevels>
                    <pagenums />
                    <pdf-style>${user.dir}/src/docs/asciidoc/themes/pdf-theme.yml</pdf-style>
                    <pdf-fontsdir>${user.dir}/src/docs/asciidoc/themes/fonts/pdf</pdf-fontsdir>
                </attributes>
            </configuration>
        </execution>
    </executions>
</plugin>

And here is the relevant part of mvn -X :

[INFO] --- asciidoctor-maven-plugin:1.5.6:process-asciidoc (asciidoc-to-revealjs) @ cg-asciidoctor-sample ---
[DEBUG] Dependency collection stats: {ConflictMarker.analyzeTime=321300, ConflictMarker.markTime=186400, ConflictMarker.nodeCount=186, ConflictIdSorter.graphTime=130500, ConflictIdSorter.topsortTime=50200, ConflictIdSorter.conflictIdCount=81, ConflictIdSorter.conflictIdCycleCount=0, ConflictResolver.totalTime=3473500, ConflictResolver.conflictItemCount=171, DefaultDependencyCollector.collectTime=338184700, DefaultDependencyCollector.transformTime=4198000}
[DEBUG] org.asciidoctor:asciidoctor-maven-plugin:jar:1.5.6:
[DEBUG]    org.asciidoctor:asciidoctorj-pdf:jar:1.5.0-alpha.16:runtime
[DEBUG]    org.asciidoctor:asciidoctorj-diagram:jar:1.5.9:runtime
[DEBUG]    org.jruby:jruby-complete:jar:9.1.17.0:runtime
[DEBUG]    org.asciidoctor:asciidoctorj-screenshot:jar:0.2.2:runtime
[DEBUG]    org.gebish:geb-core:jar:2.3:runtime
[DEBUG]       org.gebish:geb-ast:jar:2.3:runtime
[DEBUG]       org.gebish:geb-waiting:jar:2.3:runtime
[DEBUG]          org.gebish:geb-implicit-assertions:jar:2.3:runtime
[DEBUG]          org.gebish:geb-exceptions:jar:2.3:runtime
[DEBUG]       org.jodd:jodd-lagarto:jar:3.7.1:runtime
[DEBUG]          org.jodd:jodd-core:jar:3.7.1:runtime
[DEBUG]          org.jodd:jodd-log:jar:3.7.1:runtime
[DEBUG]       org.threeten:threeten-extra:jar:1.4:runtime
[DEBUG]    org.codehaus.groovy:groovy-all:jar:2.4.16:runtime
[DEBUG]    org.seleniumhq.selenium:selenium-support:jar:3.141.59:runtime
[DEBUG]       org.seleniumhq.selenium:selenium-api:jar:3.141.59:runtime
[DEBUG]       org.seleniumhq.selenium:selenium-remote-driver:jar:3.141.59:runtime
[DEBUG]       net.bytebuddy:byte-buddy:jar:1.8.15:runtime
[DEBUG]       org.apache.commons:commons-exec:jar:1.3:runtime
[DEBUG]       com.google.guava:guava:jar:25.0-jre:runtime
[DEBUG]          com.google.code.findbugs:jsr305:jar:1.3.9:compile
[DEBUG]          org.checkerframework:checker-compat-qual:jar:2.0.0:runtime
[DEBUG]          com.google.errorprone:error_prone_annotations:jar:2.1.3:runtime
[DEBUG]          com.google.j2objc:j2objc-annotations:jar:1.1:runtime
[DEBUG]          org.codehaus.mojo:animal-sniffer-annotations:jar:1.14:runtime
[DEBUG]       com.squareup.okhttp3:okhttp:jar:3.11.0:runtime
[DEBUG]       com.squareup.okio:okio:jar:1.14.0:runtime
[DEBUG]    org.seleniumhq.selenium:selenium-chrome-driver:jar:3.141.59:runtime
[DEBUG]    org.apache.maven:maven-plugin-api:jar:2.0:compile
[DEBUG]    org.apache.maven:maven-project:jar:2.2.1:compile
[DEBUG]       org.apache.maven:maven-settings:jar:2.2.1:compile
[DEBUG]       org.apache.maven:maven-profile:jar:2.2.1:compile
[DEBUG]       org.apache.maven:maven-model:jar:2.2.1:compile
[DEBUG]       org.apache.maven:maven-artifact-manager:jar:2.2.1:compile
[DEBUG]          org.apache.maven:maven-repository-metadata:jar:2.2.1:compile
[DEBUG]          backport-util-concurrent:backport-util-concurrent:jar:3.1:compile
[DEBUG]       org.apache.maven:maven-plugin-registry:jar:2.2.1:compile
[DEBUG]       org.apache.maven:maven-artifact:jar:2.2.1:compile
[DEBUG]       org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile
[DEBUG]          junit:junit:jar:3.8.1:compile
[DEBUG]          classworlds:classworlds:jar:1.1-alpha-2:compile
[DEBUG]    org.apache.maven.shared:maven-filtering:jar:3.1.1:compile
[DEBUG]       org.apache.maven:maven-core:jar:3.0:compile
[DEBUG]          org.apache.maven:maven-settings-builder:jar:3.0:compile
[DEBUG]          org.apache.maven:maven-model-builder:jar:3.0:compile
[DEBUG]          org.apache.maven:maven-aether-provider:jar:3.0:runtime
[DEBUG]          org.sonatype.aether:aether-impl:jar:1.7:compile
[DEBUG]             org.sonatype.aether:aether-spi:jar:1.7:compile
[DEBUG]          org.sonatype.aether:aether-api:jar:1.7:compile
[DEBUG]          org.sonatype.aether:aether-util:jar:1.7:compile
[DEBUG]          org.sonatype.sisu:sisu-inject-plexus:jar:1.4.2:compile
[DEBUG]             org.sonatype.sisu:sisu-inject-bean:jar:1.4.2:compile
[DEBUG]                org.sonatype.sisu:sisu-guice:jar:noaop:2.1.7:compile
[DEBUG]          org.codehaus.plexus:plexus-classworlds:jar:2.2.3:compile
[DEBUG]          org.sonatype.plexus:plexus-sec-dispatcher:jar:1.3:compile
[DEBUG]             org.sonatype.plexus:plexus-cipher:jar:1.4:compile
[DEBUG]       org.apache.maven.shared:maven-shared-utils:jar:3.0.0:compile
[DEBUG]       org.sonatype.plexus:plexus-build-api:jar:0.0.7:compile
[DEBUG]    org.codehaus.plexus:plexus-interpolation:jar:1.22:compile
[DEBUG]    org.codehaus.plexus:plexus-utils:jar:3.0.23:compile
[DEBUG]    org.asciidoctor:asciidoctorj:jar:1.5.6:compile
[DEBUG]       com.beust:jcommander:jar:1.35:runtime
[DEBUG]    io.netty:netty-codec-http:jar:4.0.38.Final:compile
[DEBUG]       io.netty:netty-codec:jar:4.0.38.Final:compile
[DEBUG]          io.netty:netty-transport:jar:4.0.38.Final:compile
[DEBUG]       io.netty:netty-handler:jar:4.0.38.Final:compile
[DEBUG]          io.netty:netty-buffer:jar:4.0.38.Final:compile
[DEBUG]             io.netty:netty-common:jar:4.0.38.Final:compile
[DEBUG]    org.apache.maven.doxia:doxia-core:jar:1.7:compile
[DEBUG]       org.apache.maven.doxia:doxia-sink-api:jar:1.7:compile
[DEBUG]       org.apache.maven.doxia:doxia-logging-api:jar:1.7:compile
[DEBUG]       org.codehaus.plexus:plexus-component-annotations:jar:1.5.5:compile
[DEBUG]       commons-lang:commons-lang:jar:2.4:compile
[DEBUG]       org.apache.httpcomponents:httpclient:jar:4.0.2:compile
[DEBUG]          commons-logging:commons-logging:jar:1.1.1:compile
[DEBUG]          commons-codec:commons-codec:jar:1.3:compile
[DEBUG]       org.apache.httpcomponents:httpcore:jar:4.0.1:compile
[DEBUG]       xmlunit:xmlunit:jar:1.5:compile
[DEBUG]    commons-io:commons-io:jar:2.4:compile
[DEBUG]    org.apache.maven.doxia:doxia-module-xhtml:jar:1.7:compile

bcouetil avatar Jan 21 '19 13:01 bcouetil

OK, the problem was not do to multiple versions on the classpath but to a limitation of the PDF backend.

See https://github.com/asciidoctor/asciidoctorj-pdf/issues/7

I implemented a workaround in the screenshot extension as this particular postprocessor does not want to modify the output but only free expensive resources.

A new version 0.2.3 of the screenshot extension is available

sclassen avatar Jan 21 '19 22:01 sclassen

Tested in 0.3.0, working, thanks 😄

bcouetil avatar Jan 22 '19 09:01 bcouetil