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
286 stars 122 forks source link

How to override the task in the subproject? #605

Open diguage opened 3 years ago

diguage commented 3 years ago

I created a submodule in the spring framework project. The spring framework project uses the plugin to convert the manual document to HTML and PDF. I want to follow the spring framework project to use the plugin to deal with my document.

The global config is as following:

asciidoctor {
    baseDirFollowsSourceDir()
    configurations 'asciidoctorExt'
    sources {
        include '*.adoc'
    }
    outputDir "$buildDir/docs/ref-docs/html5"
    logDocuments = true
    resources {
        from(sourceDir) {
            include 'images/*.png', 'css/**', 'js/**'
        }
        from extractDocResources
    }
}

The submodule task is as following:

asciidoctor {
    baseDirIsProjectDir()
    sourceDir  file('docs')
    sources {
        include '*.adoc'
    }
    outputDir "$buildDir/docs/html5"
//    outputDir  file('build/docs/html5')
    logDocuments = true
    resources {
        from(sourceDir) {
            include 'images/*.png', 'css/**', 'js/**'
        }
//      from extractDocResources
    }
    into 'build/docs/html5/assets'
}

I need to override the global task, but it always throws an error. The log is as following:

╭─☞ spring-framework git:(analysis) 
╰─➜ ./gradlew :truman:clean && ./gradlew :truman:asciidoctor

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/lijun695/develop/java/javaprojects/spring-framework/truman/build.gradle' line: 91

* What went wrong:
A problem occurred evaluating project ':truman'.
> No signature of method: build_2t5dwx4lqxv24c3x6pvoqjatk.asciidoctor() is applicable for argument types: (build_2t5dwx4lqxv24c3x6pvoqjatk$_run_closure5) values: [build_2t5dwx4lqxv24c3x6pvoqjatk$_run_closure5@65df5fd0]

* 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 3s

A build scan was not published as you have not authenticated with server 'ge.spring.io'.

The project is at https://github.com/diguage/spring-framework/tree/analysis

The task is at https://github.com/diguage/spring-framework/blob/analysis/truman/build.gradle#L90

How to override the global task?

And I would really appreciate it that if you can show me some examples of how to use the plugin, and it would be better if you can add the examples to the document of the plugin. All the users of the plugin will thank you for the examples in the document.

sebastianzillessen commented 1 year ago

Hi! Did you solve this issue? I need to do something similar as well.

diguage commented 1 year ago

@sebastianzillessen No.

ysb33r commented 1 year ago

Please try 4.0.0-alpha.1 and tell me if the problem still exists

sebastianzillessen commented 1 year ago

Hi @ysb33r ,

yes, with the updated version it works! When are you planning on releasing it?

Thanks, Seb

ysb33r commented 1 year ago

@sebastianzillessen I am not sure yet.

There are a still some things we would like to fix before release. We would also prefer to release it with the final version of Grolifant 2.0.0 rather than an alpha version of it.

diguage commented 1 year ago

I test it, it is OK. Thanks!


There is an error:

- Finding 'dot' in attributes
- Found value '/usr/local/bin/dot' in attribute 'graphvizdot'
- Is '/usr/local/bin/dot' executable? true
        at org.asciidoctor.gradle.remote.ExecutorBase.failOnWarnings(ExecutorBase.groovy:231)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:107)
        at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:323)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1268)
        at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1035)
        at org.codehaus.groovy.runtime.InvokerHelper.invokePogoMethod(InvokerHelper.java:1029)
        at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper.java:1012)
        at org.codehaus.groovy.runtime.InvokerHelper.invokeMethodSafe(InvokerHelper.java:101)
        at org.asciidoctor.gradle.remote.AsciidoctorJavaExec$_run_closure3.doCall(AsciidoctorJavaExec.groovy:76)
        at org.asciidoctor.gradle.remote.AsciidoctorJavaExec$_run_closure3.call(AsciidoctorJavaExec.groovy)
        at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2359)
        at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2344)
        at org.codehaus.groovy.runtime.DefaultGroovyMethods.each(DefaultGroovyMethods.java:2385)
        at org.asciidoctor.gradle.remote.AsciidoctorJavaExec.run(AsciidoctorJavaExec.groovy:68)
        at org.asciidoctor.gradle.remote.AsciidoctorJavaExec.main(AsciidoctorJavaExec.groovy:49)

But the file is OK:

$  which dot
/usr/local/bin/dot

$ dot -V
dot - graphviz version 7.1.0 (20230121.1956)