6 Answer:

I think we might have to drop support for older versions of gradle for this. There's ~630 public repos on GitHub with at least mentions of this plugin, having done a very quick analysis of the gradle wrappers in the projects we've got the following numbers:

  34 6.5.1
 241 6.5
  85 6.4.1
  19 6.4
 113 6.3
  20 6.2.2
   4 6.2.1
  12 6.2
  60 6.1.1
 234 6.1
 160 6.0.1
  16 6.0
  13 5.6.4
   5 5.6.3
 113 5.6.2
   2 5.6.1
   5 5.6
  15 5.5.1
   4 5.5
  18 5.4.1
   6 5.4
   8 5.3
  24 5.2.1
 106 5.1.1
   2 5.1
   6 5.0
   2 4.8.1
   2 4.8
   1 4.4.1
   3 4.4
  12 4.10.3
   2 4.10.2
   5 4.10
   2 4.0
   6 3.5.1
  16 3.5
   4 3.1
   4 2.6
Version Users Percentage
Gradle 6 998 72.11%
Gradle 5 327 23.63%
Gradle 4 29 2.10%
Gradle 3 26 1.88%
Gradle 2 4 0.29%
Total 1,384 100%
1
Answered Aug 10 '20 at 08:42
avatar  of deepy
deepy

It depends (famous answer :) ). With the configuration cache, some things are unsupported, but you can still branch depending on the current Gradle version to provide support.

Looking at the numbers above, targeting Gradle >= 5 .0 could be considered but even with that there are APIs that are only available in >6.x and branching per Gradle version would be mandatory here and there anyway 🤷

The plugin is quite different but this PR https://github.com/michel-kraemer/gradle-download-task/pull/157 made the Download task compatible with the configuration cache without losing compatibility with Gradle >=2.0.

1
Answered Aug 12 '20 at 13:29
avatar  of eskatos
eskatos

Thank you so much for the information @eskatos!

The dance performed in ProjectApiHelper is pretty much exactly what we need :-)

I'll see if I can get a branch going this week

1
Answered Aug 12 '20 at 14:30
avatar  of deepy
deepy

Started working on the branch 2.x-configuration-cache

Everything worked fine up until I switched from project.exec, I think everything is working but we just need to change mockExec in the tests. https://github.com/node-gradle/gradle-node-plugin/blob/2.2.4/src/test/groovy/com/moowork/gradle/node/task/AbstractTaskTest.groovy#L33

1
Answered Aug 12 '20 at 16:20
avatar  of deepy
deepy

Sounds good!

To make sure the support is complete I would make sure that there's at least tests that runs builds with the configuration cache enabled, reusing the cached state, for a clean build, i.e. running all tasks after skipping the configuration phase. In other words, with build cache disabled and configuration cache enabled, run once to store the cache then clean and then run again reusing the cache.

1
Answered Aug 14 '20 at 07:02
avatar  of eskatos
eskatos

Having looked some at this and tested on an example project I think we can make this work pretty easily on 2.x for the download = false cases.

1
Answered Aug 14 '20 at 10:41
avatar  of deepy
deepy