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

What is the equivalent of the `ruby.gems()` repository extensions with the kotlin DSL ? #627

Open bric3 opened 2 years ago

bric3 commented 2 years ago

Nowaday I tend to favor Kotlin DSL as it is type safe, and IntelliJ offers better suggestions.

However when I initiated a new project with asciidoctor revealjs. I had to go back to use the groovy DSL because ruby.gems() raises an unresolvable reference error on the ruby identifier.

plugins {
    id("org.asciidoctor.jvm.revealjs") version "3.3.2"
}

repositories {
    mavenCentral()
    ruby.gems()
}

I suppose the syntax is different, I have tried various combination but I cannot get it right. If you have any clue that would be appreciated. Many thanks in advance.

ghilainm commented 2 years ago

This is the answer I found somewhere else:

val repositoriesInternal = repositories as ExtensionAware
repositoriesInternal.extensions.configure(com.github.jrubygradle.api.core.RepositoryHandlerExtension::class) {
    gems()
}

However this should be documented imo.

bric3 commented 2 years ago

Hi all, I just read the Gradle 7.4 RC1 release note, and this problem might be fixed:

Starting with this version of Gradle, Kotlin DSL generates type-safe model accessors for custom extensions added to the repositories {} block. Custom extensions now have full content assist in the IDE.

So it's now possible to use

repositories {
    ruby {
        gems()
    }
}
ysb33r commented 1 year ago

Do we just need to document how to do this in < Gradle 7.4?