2

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:

  • generated a clean project with grails create-app --inplace
  • added the following to dependencies section of build.gradle (from root)
 runtime fileTree(dir: '/vagrant/libs', include: '*.jar')
  • Created a /vagrant/libs folder and dropped in .jar file
  • From controller class, imported the path and tried constructing object.
import ext.*;

...

AnnotationRenderer ar = new AnnotationRenderer()

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

Any tips to resolve this?

Charlie Dalsass
  • 1,986
  • 18
  • 23

1 Answers1

0

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),.

Charlie Dalsass
  • 1,986
  • 18
  • 23