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

HOW TO CONFIG - Asciidoctor Gradle plugin like Asciidoctor Maven plugin (One Plugin with TWO or MANY execution) #650

Closed life888888 closed 1 year ago

life888888 commented 1 year ago

Asciidoctor Maven plugin example , one plugin config two execution ( generate-pdf-doc-default-theme, generate-pdf-doc-custom-theme) with different configuration attributes.

HOW TO DO SAME THING WITH Asciidoctor Gradle plugin ? One Plugin with TWO or MANY execution ?

https://github.com/asciidoctor/asciidoctor-maven-examples/tree/main/asciidoctor-pdf-with-theme-example

pom.xml

        <plugins>
            <plugin>
                <groupId>org.asciidoctor</groupId>
                <artifactId>asciidoctor-maven-plugin</artifactId>
                ...
                <executions>
                    <execution>
                        <id>generate-pdf-doc-default-theme</id>
                        ...
                        <configuration>
                            <backend>pdf</backend>
                            <outputDirectory>${project.build.directory}/generated-docs-default-theme</outputDirectory>
                            <doctype>book</doctype>
                            <attributes>
                                <source-highlighter>rouge</source-highlighter>
                                <icons>font</icons>
                        ...
                       </configuration>
                    </execution>
                    <execution>
                        <id>generate-pdf-doc-custom-theme</id>
                        ...
                        <configuration>
                            <backend>pdf</backend>
                            <outputDirectory>${project.build.directory}/generated-docs-custom-theme</outputDirectory>
                            <!-- Use `book` docType to enable title page generation -->
                            <doctype>book</doctype>
                            <attributes>
                                <pdf-theme>custom</pdf-theme>
                            ...

https://github.com/asciidoctor/asciidoctor-gradle-examples/tree/master/asciidoc-to-pdf-example

build.gradle

asciidoctorPdf {
  dependsOn asciidoctorGemsPrepare

  baseDirFollowsSourceFile()

  asciidoctorj {
    requires 'rouge'
    attributes 'build-gradle': file('build.gradle'),
        'sourcedir': project.sourceSets.main.java.srcDirs[0],
        'endpoint-url': 'http://example.org',
        'source-highlighter': 'rouge',
        'imagesdir': './images',
        'toc': 'left',
        'icons': 'font',
        'idprefix': '',
        'idseparator': '-'
  }
}

HOW TO CONFIG one plugin with two execution ?

asciidoctorPdf {
  dependsOn asciidoctorGemsPrepare

  baseDirFollowsSourceFile()

  asciidoctorj {
    outputDir  file('build/AAAdocs')
    requires 'rouge'
    attributes 'build-gradle': file('build.gradle'),
        'sourcedir': project.sourceSets.main.java.srcDirs[0],
        'endpoint-url': 'http://example.org',
        'source-highlighter': 'rouge',
        'imagesdir': './images',
        'toc': 'left',
        'icons': 'font',
        'idprefix': '',
        'idseparator': '-'
  }

  asciidoctorjBBB {
    outputDir  file('build/BBBocs')  
    requires 'rouge'
    attributes 'build-gradle': file('build.gradle'),
        'sourcedir': project.sourceSets.main.java.srcDirs[0],
        'endpoint-url': 'http://example.org',
        'source-highlighter': 'rouge',
        'imagesdir': './images',
        'toc': 'left',
        'icons': 'font',
        'idprefix': '',
        'idseparator': '-',
        'pdf-theme': 'custom' 
    }

}
mojavelinux commented 1 year ago

Please direct usage questions to the project chat at https://chat.asciidoctor.org. The issue tracker should be used for reporting bugs and submitting feature requests only. See https://docs.asciidoctor.org/about/support/ for more about the support policy of this organization.

life888888 commented 1 year ago

Sorry, it was my mistake, I won't make it again

mojavelinux commented 1 year ago

No worries. It not only helps the project, but I think you'll find that you get better feedback in the chat. It's where you can discuss topics freely.