spring-io / spring-asciidoctor-extensions

Asciidoctor Extensions developed by the Spring team
46 stars 18 forks source link

Asciidoctor build with block-switch extension fails if using Kotlin DSL in Gradle #53

Closed ghost closed 4 years ago

ghost commented 4 years ago

I have been using the block-switch extension successfully in Asciidoctor Gradle builds for some time, having followed this documentation:

https://asciidoctor.github.io/asciidoctor-gradle-plugin/development-3.x/user-guide/#_as_external_library

Now I am using the Kotlin DSL in Gradle build script for the first time, and I get this failure when running the asciidoctor task:

Could not determine the dependencies of task ':docs:asciidoctor'.
> Configuration with name '~/.gradle/caches/modules-2/files-2.1/io.spring.asciidoctor/spring-asciidoctor-extensions-block-switch/0.4.3.RELEASE/6821b68fe5ae8c3971869bddba62e99d721ba6e6/spring-asciidoctor-extensions-block-switch-0.4.3.RELEASE.jar' not found.

The JAR is definitely at that location and this works if I use the Groovy DSL.

Here is the relevant config in my build.gradle.kts:

val asciidoctorExt by configurations.creating

dependencies {
    asciidoctorExt("io.spring.asciidoctor:spring-asciidoctor-extensions-block-switch:0.4.3.RELEASE")
}

tasks.withType<AsciidoctorTask> {
   configurations(asciidoctorExt)
   ...
}

Any ideas?

wilkinsona commented 4 years ago

For some reason the result of resolving the asciidoctorExt configuration is being treated as the name of a configuration. In Groovy DSL example it's passed in as a String whereas in your Kotlin DSL snippet above it's a Configuration. That may be the cause.

This is all happening before this extension is involved so this isn't really the right place to address this. If the above doesn't help, a question on Stack Overflow would be more appropriate.

ghost commented 4 years ago

Thanks for the reply @wilkinsona. I wasn't sure where to ask the question. Had to start somewhere :)

ghost commented 4 years ago

In Groovy DSL example it's passed in as a String whereas in your Kotlin DSL snippet above it's a Configuration.

Turns out the fix was very simple. I just needed pointing in the right direction:

configurations("asciidoctorExt")

Thanks again.