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

Absolute paths in `gemPath` can cause build cache miss #671

Open erichaagdev opened 1 year ago

erichaagdev commented 1 year ago

Given the following build script:

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

repositories {
    mavenCentral()
}

tasks.asciidoctor {
    sources("index.adoc")
    sourceDirProperty.set(layout.projectDirectory.dir("docs"))
    outputDirProperty.set(layout.buildDirectory.dir("docs"))
}

Then an absolute path will be present in the gemPath input property of the asciidoctor task. This will cause build cache misses between machines, or when executed from different directories.

Reproducer: https://github.com/erichaagdev/asciidoctor-cache-miss-reproducer

See the following Build Scan comparison from the reproducer: https://ge.solutions-team.gradle.com/c/b4xfcm2qax6c2/7pytfeyqywhcg/task-inputs?cacheability=cacheable,overlapping-outputs,validation-failure

Another real world example of this issue present in the spring-kafka project: https://ge.solutions-team.gradle.com/c/lw2a3f5v7z2xw/f3pkynntr7b6q/task-inputs?cacheability=cacheable

Relevant spot in the code where the gemPath property is configured: https://github.com/asciidoctor/asciidoctor-gradle-plugin/blob/996df6a028b69e3f7314ed61ca6af317776ace74/jvm/src/main/groovy/org/asciidoctor/gradle/jvm/AbstractAsciidoctorTask.groovy#L355-L356