Open diguage opened 3 years ago
I search the issue. There is an issue that has the same problem: https://github.com/asciidoctor/asciidoctor-gradle-plugin/issues/442
Follow the author of the issue, I found the example project: https://github.com/someok/asciidoctor-gradle-example
I written the config as the example:
pdfThemes {
local 'Source', {
styleDir = file('cfg/theme')
styleName = 'Source'
}
}
But run the Gradle task will throw an error:
╭─☞ ~/spring-framework git:(analysis) ✗
╰─➜ ./gradlew :truman:asciidoctorPdf
FAILURE: Build failed with an exception.
* Where:
Build file '/path/to/spring-framework/truman/build.gradle' line: 113
* What went wrong:
A problem occurred evaluating project ':truman'.
> No such property: styleDir for class: org.asciidoctor.gradle.jvm.pdf.AsciidoctorPdfThemesExtension
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.8.3/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 1s
A build scan was not published as you have not authenticated with server 'ge.spring.io'.
My project and config: https://github.com/diguage/spring-framework/blob/analysis/truman/build.gradle#L110
(disclaimer)Haven't tested myself...(end-disclaimer) But if this is working https://github.com/diguage/jdk-source-analysis/blob/a5a1e1cd36bd53cf7473a8cd89646d68bfe25211/pom.xml#L315-L318, I don't see why setting the same attributes as simple attributes in gradle should not work.
@abelsromero Yes, https://github.com/diguage/jdk-source-analysis is OK.
https://github.com/diguage/spring-framework/blob/analysis/truman/ has a problem.
If you open the comment,
pdfThemes {
local 'Source', {
styleDir = file('cfg/theme')
styleName = 'Source'
}
}
and run the command ./gradlew :truman:asciidoctorPdf
, it will throw an error.
But if instead of pdfThemes
you setup as attributes https://asciidoctor.github.io/asciidoctor-gradle-plugin/development-3.x/user-guide/#options using the same key-values as in maven, does also fail?
But if instead of
pdfThemes
you setup as attributes https://asciidoctor.github.io/asciidoctor-gradle-plugin/development-3.x/user-guide/#options using the same key-values as in maven, does also fail?
pdfThemes will override any attributes you place w.r.t to this.
But if instead of
pdfThemes
you setup as attributes https://asciidoctor.github.io/asciidoctor-gradle-plugin/development-3.x/user-guide/#options using the same key-values as in maven, does also fail?
I do not know. Let me try. Thanks.
I found the cause of the problem.
https://github.com/asciidoctor/asciidoctor-gradle-plugin/issues/563
asciidoctorj {
version = '2.5.1'
fatalWarnings ".*"
// outputDir "$buildDir/docs/html"
options doctype: 'book', eruby: 'erubis'
attributes([
icons: 'font',
idprefix: '',
idseparator: '-',
docinfo: 'shared',
revnumber: project.version,
sectanchors: '',
sectnums: '',
'source-highlighter': 'rouge',
'rouge-linenums-mode': 'table',
'rouge-style': 'monokai',
'linkcss': 'true',
toc: 'left',
toclevels: 4,
sectnums: false,
sectnumlevels: 3,
sectanchors: true,
fontsDir: 'cfg/fonts',
graphvizdot: '/usr/local/bin/dot',
stylesdir: 'css',
'spring-version': project.version
])
// It is OK.
pdfThemes {
local 'Source', {
themeDir = file('cfg/theme')
themeName = 'Source'
}
}
modules {
pdf {
version '1.6.0'
}
epub {
version '1.5.1'
}
diagram {
version '2.1.2'
}
}
}
But the plugin could not find the font. So the PDF also has a problem: Chinese characters cannot be displayed correctly. Let me try again.
Maybe the theme did not been used. How to use my theme?
asciidoctorj {
version = '2.5.1'
fatalWarnings ".*"
// outputDir "$buildDir/docs/html"
options doctype: 'book', eruby: 'erubis'
attributes([
icons: 'font',
idprefix: '',
idseparator: '-',
docinfo: 'shared',
revnumber: project.version,
sectanchors: '',
sectnums: '',
'source-highlighter': 'rouge',
'rouge-linenums-mode': 'table',
'rouge-style': 'monokai',
'linkcss': 'true',
toc: 'left',
toclevels: 4,
sectnums: false,
sectnumlevels: 3,
sectanchors: true,
fontsDir: 'cfg/fonts',
graphvizdot: '/usr/local/bin/dot',
stylesdir: 'css',
'spring-version': project.version
])
fontsDir file('cfg/fonts') // add the option, it will throw an error.
pdfThemes {
local 'Source', {
themeDir = file('cfg/theme')
themeName = 'Source'
}
}
modules {
pdf {
version '1.6.0'
}
epub {
version '1.5.1'
}
diagram {
version '2.1.2'
}
}
}
If I add the fontsDir
option, run the task asciidoctorPdf
, it will throw an error:
╭─☞ ~/spring-framework git:(analysis) ✗
╰─➜ ./gradlew :truman:clean && ./gradlew :truman:asciidoctorPdf
FAILURE: Build failed with an exception.
* Where:
Build file '/path/to/spring-framework/truman/build.gradle' line: 51
* What went wrong:
A problem occurred evaluating project ':truman'.
> No signature of method: build_2t5dwx4lqxv24c3x6pvoqjatk.asciidoctorj() is applicable for argument types: (build_2t5dwx4lqxv24c3x6pvoqjatk$_run_closure4) values: [build_2t5dwx4lqxv24c3x6pvoqjatk$_run_closure4@695ac417]
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.8.3/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 1s
A build scan was not published as you have not authenticated with server 'ge.spring.io'.
Reference my Asciidoctor Gradle Plugin Examples
https://github.com/life888888/asciidoctor-pdf-cjk-ext-gradle-examples
It demo some condition usage examples.
Please try 4.0.0-alpha.1 and tell me if the problem still exists
I use 4.0.0-alpha.1, and follow https://github.com/life888888/asciidoctor-pdf-cjk-ext-gradle-examples examples to use pdf-fontsdir
, pdf-themesdir
and pdf-theme
. It works well.
asciidoctorPdf {
baseDirFollowsSourceDir()
asciidoctorj {
attributes "pdf-fontsdir": "${project.projectDir}/cfg/fonts;GEM_FONTS_DIR;",
"pdf-themesdir": "${project.projectDir}/cfg/theme",
"pdf-theme": "Source"
}
sources {
include 'index.adoc'
}
outputDir "${project.buildDir}/docs/pdf"
forkOptions {
jvmArgs += ["--add-opens", "java.base/sun.nio.ch=ALL-UNNAMED",
"--add-opens", "java.base/java.io=ALL-UNNAMED"]
}
logDocuments = true
}
@ysb33r @life888888 Thanks a lot.
I have a document project written in Chinese. If I want to convert the document to PDF, it must be configurated with the theme with Chinese fonts.
The maven project was configurated well by me: https://github.com/diguage/jdk-source-analysis.
I need to convert the Maven plugin config to the Gradle plugin config in the project: spring-framework/truman at analysis.
The project is special: the parent module configures the task
asciidoctorPdf
, and the submodule must override the task or override the config of the task.