How to replace a gradle dependency with a jar?

Hello.
My project has a dependency - com.google.code.gson:gson:2.8.5

How to replace it with libs/gson-2.8.5.jar

I have already used this method

 implementation files('libs/gson-2.8.5.jar')


configurations.all {
     exclude group: 'com.google.code.gson', module: 'gson'
  }

This works, but I need to make a replacement using these

dependencies {
modules {
    module("com.google.collections:google-collections") {
        replacedBy("com.google.guava:guava", "google-collections is now part of Guava")
    }
}

}

includeBuild('anonymous-library') {
dependencySubstitution {
    substitute module('org.sample:number-utils') with project(':')
}

}

Is it possible?