grails-3.0dependency-resolution

using POJO domain jar in Grails 3


I'm trying to port a Grails 2.x project to Grails 3. The 2.x based project has domain made up of POJOs in a JAR but now v3 does not have a /lib directory any more and doc suggest the following:

4.7 Dependency Resolution

Dependency resolution is handled by the Gradle build tool, all dependencies are defined in the build.gradle file. Refer to the Gradle user guide for more information.

(doc link)

... can anyone offer a short-short version of how to handle adding a jar dependency (I have 0 familiarity with Gradle)

When I attempt running 'run-app' command it get this error (so at least the hibernate config file is being read):

Error creating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException: Unable to load class [ com.flightloglib.domain.AircraftMakeAndModel] declared in Hibernate configuration entry


Solution

  • Create a directory for you jar, say lib. Then

    In the dependencies block of your build.gradle, create a compile time dependency on your jar.

    dependencies {
        compile files('lib/pojos.jar')
        // ...
    }
    

    The applicable docs are here: Chapter 52