asciidoctor / asciidoctorj-pdf

AsciidoctorJ PDF bundles the Asciidoctor PDF RubyGem (asciidoctor-pdf) so it can be loaded into the JVM using JRuby.
Apache License 2.0
35 stars 17 forks source link

Unable to Load asciidoctor-pdf #65

Closed programming-wolf closed 1 year ago

programming-wolf commented 2 years ago

I upgrade to Gradle 7.1 and Java 16. This brought a bunch of issues, which I could correct except one. Everything worked fine with Gradle 6.8, Java 14 and asciidoctor.convert 1.5.4.

Originally, I had errors stating that I need to pass --add-opensjava.base/sun.nio.ch=ALL-UNNAMED... to the process. I figured that out (with that issue as help). Now it says: org.jruby.exceptions.LoadError: (LoadError) no such file to load -- asciidoctor-pdf, causing Error running Asciidoctor whilst attempting to process /path/to/curriculum-template.adoc using backend pdf

(I don't know if that's an issue with this plugin or with jRuby, or asciidoctorj).

Here's my gradle file (I removed some stuff that's not required):

import org.asciidoctor.gradle.jvm.AsciidoctorTask

import java.text.SimpleDateFormat

buildscript {
    allprojects {
        repositories {
            mavenCentral()
            maven {
                url "https://plugins.gradle.org/m2/"
            }
        }
    }
    dependencies {
        classpath 'org.jruby:jruby-complete:9.2.19.0'
        classpath 'org.asciidoctor:asciidoctorj:2.5.1'
        classpath "org.asciidoctor:asciidoctorj-pdf:1.6.0"
    }
}

plugins {
    id "org.asciidoctor.jvm.convert" version "3.3.2"
}

class RenderCurriculumTask extends AsciidoctorTask {
    @Inject
    RenderCurriculumTask(WorkerExecutor worker, String curriculumFileName, String versionDate, String language, boolean withRemarks) {
        super(worker)

        forkOptions {
            jvmArgs "--add-opens", "java.base/sun.nio.ch=ALL-UNNAMED", "--add-opens", "java.base/java.io=ALL-UNNAMED"
        }

        sourceDir = new File("./docs/")
        sources {
            include "index.adoc"
            include "${curriculumFileName}.adoc"
        }

        outputDir = new File("./build/")
        outputOptions {
            separateOutputDirs = false
            backends 'pdf', 'html5'
        }
        def fileVersion = project.version.trim() + "-" + language

        attributes = [
                // some attributes we set
        ]
    }
}

task buildDocs {
    group 'Documentation'
    description 'Grouping task for generating all languages in several formats'
    dependsOn "includeLearningObjectives", "renderNoRemarksDE", "renderNoRemarksEN"
}

task renderNoRemarksDE(type: RenderCurriculumTask,
        constructorArgs: [curriculumFileName, versionDate, "DE", false]) {
    doLast {
        addSuffixToCurriculum("-de")
    }
}

task renderNoRemarksEN(type: RenderCurriculumTask,
        constructorArgs: [curriculumFileName, versionDate, "EN", false]) {
    doLast {
        addSuffixToCurriculum("-en")
    }
}

apply from: 'scripts/includeLearningObjectives.gradle'

defaultTasks "buildDocs"

Any help would be appreciated. Thanks!

robertpanzer commented 2 years ago

I'd recommend opening a ticket for https://github.com/asciidoctor/asciidoctor-gradle-plugin. AsciidoctorJ and AsciidoctorJ-PDF are generally tested with Java 16, so I would assume that there is either a configuration problem in this gradle build, or some incompatibility with the plugin and the latest grade and java versions.