How to add a Jar as a dependency via Gradle Plugin

files('/path/to/my/lib.jar') as a String is not a valid dependency notation. When using implementation files('...') you are adding a FileCollection to the configuration (the Project.files(...) method returns a FileCollection).

You do not need to create a Dependency object, just create a FileCollection and pass it to dependencies.add. Something like:

project.getDependencies().add( "implementation", project.files( jarLocation ) )

*Note: I didn’t test this.