Groovy for Domain-specific Languages - Second Edition

(nextflipdebug2) #1
Chapter 12

[ 341 ]

dependencies {
classpath (
"org.springframework.boot:spring-boot-gradle-plugin:1.2.3.RELEASE"
)
classpath (
'com.sourcemuse.gradle.plugin:gradle-mongo-plugin:0.1.0'
)
}
}

apply plugin: 'spring-boot'
apply plugin: 'mongo'
apply plugin: 'groovy'

repositories {
jcenter()
maven { url 'http://repo.spring.io/release' }
}

dependencies {
compile project(':ast')
compile "org.codehaus.groovy:groovy:2.4.3"
compile "org.springframework.boot:spring-boot-starter-web"
compile (
"org.springframework.boot:spring-boot-starter-data-mongodb"
)
testCompile 'org.spockframework:spock-core:0.7-groovy-2.0'
testCompile "org.mongodb:mongo-java-driver:2.12.0"
}

As usual, configuring a project with the Gradle DSL is surprisingly easy. All we need
to do is apply the plugins for Spring Boot and Mongo and supply the dependencies
for the libraries. Running Gradle will cause all the dependent components to be
installed. You don't even need to install a MongoDB database since the Mongo
plugin will create an embedded MongoDB instance for you. To start the embedded
MongoDB, just issue the following Gradle command:


$gradle startMongo


Now we can start the Spring Boot server and try out some responses:


$gradle clean run

Free download pdf