Hello,
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:
-
download jar from https://jitpack.io/com/github/ajoberstar/grgit/grgit-core/3.0.0/grgit-core-3.0.0.jar
-
created a libs folder in root project directory(same level as build.gradle)
-
copy grgit-core-3.0.0.jar to “libs” folder
-
include this jar with following build.gradle
plugins {
id ‘groovy’
}
repositories {
mavenCentral()
}
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: [’.jar’])
}
sourceSets {
main {
groovy {
srcDirs = [‘buildSrc/src/main/groovy’]
}
}
}
- 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!