Charlie Dalsass
Charlie Dalsass

Reputation: 2014

Adding External JAR's to Grails 4.0 Application

I have tried adding an external .jar file to a grails 4.0 application, and though this has been answered in 3.0 version, I can't find an answer for 4.0. (Grails 4.0 has changed significantly from 3.0.)

Here's what I've done so far:

 runtime fileTree(dir: '/vagrant/libs', include: '*.jar')
import ext.*;

...

AnnotationRenderer ar = new AnnotationRenderer()

But I always get "unable to resolve class AnnotationRenderer".

Any tips to resolve this?

Upvotes: 2

Views: 489

Answers (1)

Charlie Dalsass
Charlie Dalsass

Reputation: 2014

To link to an external jar which is not in Maven or any other public repo, in build.gradle repositories section add:

flatDir {
    dirs 'libs'
}

Then in dependencies section add:

implementation name: 'myjarfilename'

Where my actual filename is myjarfilename.jar (e.g. don't include ".jar" in build.grade),.

Upvotes: 0

Related Questions