Can't load external JAR file


I’m trying to load an external jar, grgit-core-3.0.0.jar, into my project. Always got “unable to resolve class org.ajoberstar.grgit.Branch” error.

Here is what I did:

  1. download jar from

  2. created a libs folder in root project directory(same level as build.gradle)

  3. copy grgit-core-3.0.0.jar to “libs” folder

  4. include this jar with following build.gradle

plugins {
id ‘groovy’

repositories {

dependencies {
implementation gradleApi()
implementation localGroovy()
//implementation files(‘libs/grgit-core-3.0.0.jar’)
//plugin fileTree(dir: ‘libs’, include: ‘.jar’)
implementation fileTree(dir: ‘libs’, include: [’

sourceSets {
main {
groovy {
srcDirs = [‘buildSrc/src/main/groovy’]

  1. I used “import org.ajoberstar.grgit.Branch” to import branch in Groovy code, got the following error:
    C:\work\MessageBrokerGradlePlugin\buildSrc\src\main\groovy\ca\cooperators\mb\tasks\CloneGitRepoTask.groovy: 10: unable to resolve class org.ajoberstar.grgit.Branch
    @ line 10, column 1.
    import org.ajoberstar.grgit.Branch

1 error

:buildSrc:compileGroovy FAILED

I did a lot search to include external “.jar” file and tried many ways, none of them works.

Appreciate for help!

It would be greatly appreciated if someone is willing to help! I am completely blocked by this issue.