ajoberstar / gradle-stutter

A Gradle plugin plugin
Apache License 2.0
17 stars 1 forks source link

The first and last versions in compatibleRange are not included #37

Open qux7 opened 1 month ago

qux7 commented 1 month ago

The first and last versions are not tested against!

  1. Create a project with Gradle 8.9 and id 'org.ajoberstar.stutter' version '1.0.0'
  2. Specify compatibleRange '6.0.0', '6.5':
    stutter {
    //sparse = false // defaults to true
    matrices {
    java11 {
      javaToolchain {
        languageVersion = JavaLanguageVersion.of(11)
      }
      gradleVersions {
        compatibleRange '6.0.0', '6.5'
      }
    }
    }
  3. Perform stutterWriteLocks
  4. See the locks file after stutterWriteLocks:
    $ cat stutter.lockfile 
    # DO NOT MODIFY: Generated by Stutter plugin.
    java11=6.0.1,6.4.1

Expected: both '6.0.0' and '6.5'` are included

Actual: neither '6.0.0' nor '6.5'` are included

The same misbehavior happens with sparse = false:

$ cat stutter.lockfile 
# DO NOT MODIFY: Generated by Stutter plugin.
java11=6.0.1,6.1.1,6.2.2,6.3,6.4.1

(My guess is that this is somehow related to using the last available patch.)

ajoberstar commented 1 month ago

This is caused by two (intentional) parts of the implementation:

  1. 6.5 is excluded because the compatibleRange() takes an inclusive start version and an exclusive end version. So by definition, 6.5 would not be included in this range. The intent of this method is to say something like compatibleRange('7.3', '8.0') where you know that 8.0 is not compatible with your plugin.
  2. 6.0 is replaced with 6.0.1 because we intentionally only include the latest patch version of any given minor. See the code here. This motivated by #17 where the requester highlighted that including every version in a range would often result in far more tests than anyone practically wants to run. It's a performance optimization relying on the presumption that a Gradle patch release should be functionally equivalent to the x.y.0 base release outside of bugs Gradle acknowledged and fixed.