Grails features 5 dependency resolution configurations (or 'scopes') which you can take advantage of:
-
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
Within the
dependencies
block you can specify a dependency that falls into one of these configurations by calling the equivalent method. For example if your application requires the MySQL driver to function at
runtime
you can specify as such:
runtime 'com.mysql:mysql-connector-java:5.1.5'
The above uses the string syntax which is
group:name:version
. You can also use a map-based syntax:
runtime group:'com.mysql', name:'mysql-connector-java', version:'5.1.5'
Multiple dependencies can be specified by passing multiple arguments:
runtime 'com.mysql:mysql-connector-java:5.1.5',
'net.sf.ehcache:ehcache:1.6.1'// Orruntime(
[group:'com.mysql', name:'mysql-connector-java', version:'5.1.5'],
[group:'net.sf.ehcache', name:'ehcache', version:'1.6.1']
)