Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gradle kotlin configuration :asciidoctor #678

Open
vifeng opened this issue Jun 9, 2023 · 0 comments
Open

gradle kotlin configuration :asciidoctor #678

vifeng opened this issue Jun 9, 2023 · 0 comments

Comments

@vifeng
Copy link

vifeng commented Jun 9, 2023

Hi,
I report my first issue, so thank you for your comprehension.
Problem : I think it is the way that asciidoctor implemented their code that makes the users write the gradle configuration unnaturally. FYI, Gradle is now using kotlin as default instead of groovy. see below for detail code.

Error message when gradle clean build or gradle jar :

Could not determine the dependencies of task ':asciidoctor'.
> Configuration with name '<path>/spring-restdocs-asciidoctor-3.0.0.jar' not found.

Related code for build.gradle.kts

val asciidoctorExt by configurations.creating

dependencies {
    asciidoctorExt("org.springframework.restdocs:spring-restdocs-asciidoctor")
    }

tasks.asciidoctor {
    configurations(listOf(asciidoctorExt))
   // this line should in fact be written as such : configurations(asciidoctorExt) which doesn't build
}

see here, the message from Vampire from the gradle community for the reason of this syntax issue:
that's imho a shortcoming of the Asciidoctor plugin that you should report.
There is configurations(Object... configs) and configurations(Iterable configs) and it can handle either Configuration objects or anything else by converting it to a String and using that as configuration name.
Configuration is iterable, so the second variant is chosen. The configuration is iterated and so the File instances are used.
On those then toString() is called which gives the paths of the files in the configuration and that is then used as configuration name which gives the error you mentioned.
Before you gave a String which is not Iterable, so the first variant was used and interpreted as configuration name correctly.
So you either need to use configurations(asciidoctorExt as Any) or configurations(listOf(asciidoctorExt)) or configurations(asciidoctorExt.name).
source

FYI link to a whole kotlin build file (following the best practices -as I can any way thanks to vampire help) can be found on my [github] (vifeng/TicketToTheMoon@3564599)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant