asciidoctor / asciidoctor-gradle-plugin

A Gradle plugin that uses Asciidoctor via JRuby to process AsciiDoc source files within the project.
https://asciidoctor.github.io/asciidoctor-gradle-plugin/
Apache License 2.0
285 stars 120 forks source link

There is garbled code in the output directory when there are Chinese characters in the task name #669

Closed daijpeng closed 1 year ago

daijpeng commented 1 year ago

I dynamically create tasks by traversing the directory using subdirectory names, but if the subdirectory contains Chinese characters, the output directory is transcoded to UTF-8 characters。

The following is the execution result of the command:gradlew tasks

Default tasks: generateAll
taskName :renderDesignXDBI设计及使用
outputDir:E:\asciidoc\demoadoc\build\docs\asciidocRenderDesignXDBI#ffffffe8ffffffaeffffffbe!#ffffffe8ffffffaeffffffa1!#ffffffe5ffffff8fffffff8a!#ffffffe4ffffffbdffffffbf!#ffffffe7ffffff94ffffffa8!
taskName :renderDesignX数据加载工具
outputDir:E:\asciidoc\demoadoc\build\docs\asciidocRenderDesignX#ffffffe6ffffff95ffffffb0!#ffffffe6ffffff8dffffffae!#ffffffe5ffffff8affffffa0!#ffffffe8ffffffbdffffffbd!#ffffffe5ffffffb7ffffffa5!#ffffffe5ffffff85ffffffb7!

demoadoc.zip

Expected: Output directory name supports Chinese characters。

mojavelinux commented 1 year ago

It's just a hunch, but I think this may be related to this issue: https://github.com/jruby/jruby/issues/7750

mojavelinux commented 1 year ago

Can you try to use JRuby 9.2 to see if it still happens?

daijpeng commented 1 year ago

Hi mojavelinux:

I'm using jruby 9.2.13

implementation +--- org.asciidoctor:asciidoctor-gradle-base:3.3.2 | --- org.ysb33r.gradle:grolifant:0.16.1 | --- org.tukaani:xz:1.6 +--- org.asciidoctor:asciidoctor-gradle-jvm:3.3.2 | +--- org.ysb33r.gradle:grolifant:0.16.1 () | --- org.asciidoctor:asciidoctor-gradle-base:3.3.2 () +--- org.asciidoctor:asciidoctor-gradle-jvm-pdf:convert FAILED +--- org.asciidoctor:asciidoctorj-pdf:2.3.4 --- org.asciidoctor:asciidoctorj:2.4.1 +--- org.asciidoctor:asciidoctorj-api:2.4.1 +--- org.jruby:jruby:9.2.13.0 | +--- org.jruby:jruby-core:9.2.13.0 | | +--- com.github.jnr:jnr-netdb:1.1.6 | | +--- com.github.jnr:jnr-enxio:0.25 | | | --- com.github.jnr:jnr-constants:0.9.15 | | +--- com.github.jnr:jnr-unixsocket:0.28 | | | +--- com.github.jnr:jnr-constants:0.9.15 | | | +--- com.github.jnr:jnr-enxio:0.25 () | | | --- com.github.jnr:jnr-posix:3.0.54 | | | --- com.github.jnr:jnr-constants:0.9.15 | | +--- com.github.jnr:jnr-posix:3.0.54 () | | +--- com.github.jnr:jnr-constants:0.9.15 | | +--- com.github.jnr:jffi:1.2.23 | | +--- org.jruby.joni:joni:2.1.31 | | | --- org.jruby.jcodings:jcodings:1.0.46 | | +--- org.jruby.jcodings:jcodings:1.0.46 | | +--- org.jruby:dirgra:0.3 | | +--- com.headius:invokebinder:1.11 | | +--- com.headius:options:1.4 | | +--- com.jcraft:jzlib:1.1.3 | | +--- com.martiansoftware:nailgun-server:0.9.1 | | +--- joda-time:joda-time:2.10.5 | | +--- com.headius:backport9:1.8 | | --- javax.annotation:javax.annotation-api:1.3.1 | --- org.jruby:jruby-stdlib:9.2.13.0 --- com.beust:jcommander:1.72

(*) - dependencies omitted (listed previously)

daijpeng commented 1 year ago

Sorry,I'm wrong, jruby version is 9.3.8.0 How should I change the version of jruby?

daijpeng commented 1 year ago

I use the following method to modify the version number of asciidoc: asciidoctorj { version = '2.4.1' jrubyVersion = '9.2.13.0' }

I tested the following combinations: asciidoctorj 2.4.1+ jruby 9.2.13.0 asciidoctorj 2.4.1+ jruby 9.3.8.0 asciidoctorj 2.4.1+ jruby 9.4.2.0 asciidoctorj 2.5.7+ jruby 9.3.8.0 asciidoctorj 2.5.7+ jruby 9.4.2.0

Got the same results。

Additionally, I think that this issue is not related to jruby, as even if jruby related packages are deleted, The output path of the "gradlew tasks" command still contains garbled code.

ysb33r commented 1 year ago

That's not garbled, it is by design. It uses an underlying method for creating safe file names that are portable across different kinds of filesystems.

ysb33r commented 1 year ago

You can override that behaviour by providing your own output directory.

daijpeng commented 1 year ago

Hi ysb33r: Thank you for your answer.Now,I override the outputDir and resolve this issue,but But I have encountered new issue:Temporary path error

* What went wrong:
Execution failed for task ':renderDesignXP20230002-优化存储bizCore现场数据方案'.
> java.io.FileNotFoundException: D:\WORKSPACE\document\build\tmp\renderDesignXP20230002-#ffffffe4ffffffbcffffff98!#ffffffe5ffffff8cffffff96!#ffffffe5ffffffadffffff98!#ffffffe5ffffff82ffffffa8!bizCore#ffffffe7ffffff8effffffb0!#ffffffe5ffffff9cffffffba!#ffffffe6ffffff95ffffffb0!#ffffffe6ffffff8dffffffae!#ffffffe6ffffff96ffffffb9!#ffffffe6ffffffa1ffffff88!.javaexec-data (文件名、目录名或卷标语法不正确。)

I tried to overeide the temporaryDir , but the attribute is read-only. How can I solve this issue?

outputDir = buildDir.toString() + "/docs/" + taskName
temporaryDir = buildDir.toString() + "/tmp/" + taskName
Cannot set the value of read-only property 'temporaryDir' for task ':renderDesignXP20230003-表大字段压缩' of type org.asc
iidoctor.gradle.jvm.AsciidoctorTask.