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
283 stars 120 forks source link

Cannot implement plugin by using task avoidance #692

Closed Chrispie closed 6 months ago

Chrispie commented 7 months ago

We use this plugin to convert .adoc files into HTML files that we use to distribute as documentation and we try not to create unnecessary Gradle tasks until it is needed. Hence for any changes that we make to our Gradle build, we run a Gradle build scan to try and avoid task creation. See Gradle's avoidance page.

To keep things as simple as possible I created an empty Gradle project and modified the build.gradle.kts file to look as follows:

import org.asciidoctor.gradle.jvm.AsciidoctorTask

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

group = "org.example"
version = "1.0-SNAPSHOT"

repositories {
    mavenCentral()
}

val asciidoctorTaskName = "asciidoctor"
tasks.named<AsciidoctorTask>(asciidoctorTaskName).configure {
    sourceDir(rootDir)
    setOutputDir("build/docs")
    sources {
        include("*.adoc")
    }
}

Running a build scan via the command line .\gradlew.bat help --scan I can see that the task "asciidoctorEditorConfig" gets created immediately. If it is a multi level project this gets created per subproject.

Had a look and it seems to be in the AsciidoctorEditorConfigPlugin class where the task is created every time:

public void apply(Project project) {
        AsciidoctorEditorConfigGenerator task = (AsciidoctorEditorConfigGenerator)ScriptBytecodeAdapter.castToType(project.getTasks().create(DEFAULT_TASK_NAME, AsciidoctorEditorConfigGenerator.class), AsciidoctorEditorConfigGenerator.class);
        this.configureIdea(task);
        Object var10000 = null;
    }

Is there any future plans to make the plugin task avoidance compliant?