Question

Using the asciidoctor-maven-plugin on Windows we are getting an encoding incompatability error when ejecuting the goal process-asciidocs.

We have tried with the 0.1.4 release of the plugin and the latest SNAPSHOT from master.

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.asciidoctor:asciidoctor-maven-plugin:1.5.0-SNAPSHOT:process-asciidoc (default-cli) on project lgtdev-doc: Execution default-cli of goal org.asciido
ctor:asciidoctor-maven-plugin:1.5.0-SNAPSHOT:process-asciidoc failed: (Encoding::CompatibilityError) incompatible character encodings: CP850 and UTF-8
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:224)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default-cli of goal org.asciidoctor:asciidoctor-maven-plugin:1.5.0-SNAPSHOT:process-asciidoc failed: (Encoding::CompatibilityError) incompatible character enco
dings: CP850 and UTF-8
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:115)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
        ... 19 more
Caused by: org.jruby.exceptions.RaiseException: (Encoding::CompatibilityError) incompatible character encodings: CP850 and UTF-8
        at org.jruby.RubyString.concat(org/jruby/RubyString.java:2636)
        at RUBY.result((erb):58)
        at org.jruby.RubyKernel.eval(org/jruby/RubyKernel.java:1093)
        at RUBY.result(jar:file:/C:/Users/AUX7010/.m2/repository/org/jruby/jruby-complete/1.7.4/jruby-complete-1.7.4.jar!/META-INF/jruby.home/lib/ruby/1.9/erb.rb:838)
        at RUBY.render(jar:file:C:/Users/AUX7010/.m2/repository/org/asciidoctor/asciidoctor-java-integration/0.1.4/asciidoctor-java-integration-0.1.4.jar!/gems/asciidoctor-0.1.4/lib/asciidoctor/backends/base_template.rb:55)
        at RUBY.render(jar:file:C:/Users/AUX7010/.m2/repository/org/asciidoctor/asciidoctor-java-integration/0.1.4/asciidoctor-java-integration-0.1.4.jar!/gems/asciidoctor-0.1.4/lib/asciidoctor/renderer.rb:137)
        at RUBY.render(jar:file:C:/Users/AUX7010/.m2/repository/org/asciidoctor/asciidoctor-java-integration/0.1.4/asciidoctor-java-integration-0.1.4.jar!/gems/asciidoctor-0.1.4/lib/asciidoctor/document.rb:769)
        at RUBY.render(jar:file:C:/Users/AUX7010/.m2/repository/org/asciidoctor/asciidoctor-java-integration/0.1.4/asciidoctor-java-integration-0.1.4.jar!/gems/asciidoctor-0.1.4/lib/asciidoctor.rb:915)
        at RUBY.render_file(jar:file:C:/Users/AUX7010/.m2/repository/org/asciidoctor/asciidoctor-java-integration/0.1.4/asciidoctor-java-integration-0.1.4.jar!/gems/asciidoctor-0.1.4/lib/asciidoctor.rb:993)
        at RUBY.render_file(<script>:51)
        at org.jruby.gen.InterfaceImpl1306937631.render_file(org/jruby/gen/InterfaceImpl1306937631.gen:13)

When using cruby with the asciidoctor gem we don't get this error so it imagine that the problem is with the jruby execution environment.

On Mac we solved the same error by setting JAVA_TOOL_OPTIONS="-DFile=encoding.UTF-8" but on Windows this has no effect.

How can we coerce jruby into using UTF-8?

Was it helpful?

Solution

We have solved this by editing the asciidoctor sources in the asciidoctor-java-integration jar, forcing Encoding.default_external = Encoding::UTF_8 in gems/asciidoctor-0.1.4/lib/asciidoctor.rb. Whilst not an elegant solution it works.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top