The Grails Dependency Generator Task is a Gradle task that can produce the various Maven POM files required to build Grails applications and plugins. The task uses the org.codehaus.groovy.grails.resolve.GrailsCoreDependencies class from the grails-bootstrap module to determine the dependencies (and their exclusions) that should be included in the POM for the requested scope.
In order to use the Grails Dependency Generator Task, the project must first be built and pushed to a repository:
gradle clean install
Once the task JAR has been built and pushed to your local repository, you can use the task in any Gradle project:
buildscript {
repositories {
mavenLocal()
maven {
url 'http://repo.grails.org/grails/core'
}
mavenCentral()
}
dependencies {
classpath("org.grails:grails-dependency-generator-task:1.0.0-SNAPSHOT") {
transitive = false
}
classpath("org.grails:grails-bootstrap:2.1.1") {
transitive = false
}
}
}
...
task generate(type: org.grails.gradle.task.dependency.GrailsDependencyGenerationTask) {
grailsVersion = '2.1.1'
scope = 'runtime'
}
To run the task from your Gradle project, simply use the following:
gradle generate
The Gradle task supports the following parameters/properties:
grailsVersionThe version of Grails used to generate the POM file (required, no default)scopeThe dependency scope used to select dependencies for inclusion in the generated POM file (optional, default =runtime)
The Gradle task generates a Maven POM file with the following GAV:
<groupId>org.grails</groupId>
<artifactId>grails-${dependencyScope}-dependencies</artifactId>
<packaging>pom</packaging>
<version>${grailsVersion}</version>
where the dependencyScope is the value scope parameter passed to the task and the grailsVersion is the grailsVersion scoped also passed to the task.
The Grails Dependency Generator Task currently supports the following scopes:
build(mapped to the Mavencompilescope)compile(mapped to the Mavencompilescope)docs(mapped to the Mavencompilescope)provided(mapped to the Mavenprovidedscope)runtime(mapped to the Mavenruntimescope)test(mapped to the Maventestscope)
These scopes map to the Ivy scopes used in the aforementioned GrailsCoreDependencies class. By default, a scope value of runtime is used if no value is provided to the task.