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
286 stars 122 forks source link

Ensure consistent ordering in Sets returned from `Transform.toSet()` #592

Closed bigdaz closed 3 years ago

bigdaz commented 3 years ago

The Transform.toSet() methods return a HashSet instance that has non-deterministic ordering. These methods are used to construct a number of task inputs and outputs, including:

It is important that task inputs and outputs are consistent to ensure Gradle can correctly determine if a task is up-to-date.

These are not just theoretical issues, as reported by #591. When docExtensions are added as Closures to asciidoctorj, the AbstractAsciiDoctorTask adds a number of Gradle/Groovy dependencies to the Classpath used to invoke Asciidoctor. Since AbstractAsciidoctorTask.configurations is registered as a task input, this inconsistent classpath ordering leads to cache misses and tasks not being considered UP-TO-DATE, resulting in unneccessary re-execution.

This change simply changes Transform.toSet() methods to return a LinkedHashSet, ensuring consistent iteration order for the returned Sets.

Fixes #591

ysb33r commented 3 years ago

Thanks