0
votes

Running into issues where by I am forced to add custom jars in the grails/lib project. We have two projects (web projects). In the eclipse ide I do create project reference to take care of compile time dependency, but run into issue when I generate war... as 'grails war' ends up recompiling all the groovy classes, its unable to find refrences of dependent jars/classes.

For now I have to bundle those jars as 3rd party jar in the lib directory, wondering if there is a better solution. One thing to remember at run time both the project do exists in the same web container and interact with one another

1

1 Answers

0
votes

Yes there is a better way. Use its built-in dependency resolution. You can add your dependencies to the BuildConfig.groovy instead of adding Jars to the lib folder. This is how you define a dependency

runtime 'com.mysql:mysql-connector-java:5.1.16'

The Grails knows five different dependencies scopes.

  • build: Dependencies for the build system only
  • compile: Dependencies for the compile step
  • runtime: Dependencies needed at runtime but not for compilation (see above)
  • test: Dependencies needed for testing but not at runtime (see above)
  • provided: Dependencies needed at development time, but not during WAR deployment