Home > Net >  How to override a plugin dependency in a Gradle conventions plugin
How to override a plugin dependency in a Gradle conventions plugin

Time:09-17

I'm using Gradle's conventions as described here: https://docs.gradle.org/current/samples/sample_convention_plugins.html

And in the convention plugin, I'm applying a plugin (io.freefair.gradle:lombok-plugin:6.5.1) however I now need to override a dependency that it uses (I need org.projectlombok:lombok:1.18.22 not 1.18.24)

I've tried this:

buildscript {
    dependencies {
        classpath 'org.projectlombok:lombok:1.18.22'
    }
}

plugins {
    id 'groovy-gradle-plugin'
}

...

dependencies {
    implementation 'io.freefair.gradle:lombok-plugin:6.5.1'
    ...
    implementation 'org.projectlombok:lombok:1.18.22'
}

But version 1.18.24 was used. I've also tried adding this to my build.gradle:

buildscript {
    dependencies {
        classpath 'org.projectlombok:lombok:1.18.22'
    }
}

plugins {
    id 'billforward.java-conventions'
}

but still 1.18.24 was used.

As an aside, the two underlying issues I'm trying to solve are:

CodePudding user response:

The lombok version used by io.freefair.lombok can be customized by using the lombok extension property:

plugins {
  id "io.freefair.lombok" version "6.5.1"
}

lombok.version = "1.18.22"

This is documented here: https://docs.freefair.io/gradle-plugins/6.5.1/reference/#_io_freefair_lombok_base

Adding lombok itself to the buildscript classpath (or the runtime classpath of your gradle plugin) will not do anything.

  • Related