Skip to content

Commit 8ca8c85

Browse files
committed
Merge pull request #250 from Jennifer Strater
* gh-250: Polish "Add Grails sample app" (1338df9) Add Grails sample app
2 parents c1d245f + 34ec9d5 commit 8ca8c85

File tree

21 files changed

+908
-0
lines changed

21 files changed

+908
-0
lines changed

build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,10 @@ samples {
163163
dependOn 'spring-restdocs-mockmvc:install'
164164
dependOn 'spring-restdocs-restassured:install'
165165

166+
restNotesGrails {
167+
workingDir "$projectDir/samples/rest-notes-grails"
168+
}
169+
166170
restNotesSpringHateoas {
167171
workingDir "$projectDir/samples/rest-notes-spring-hateoas"
168172
}
@@ -183,6 +187,7 @@ samples {
183187
workingDir "$projectDir/samples/rest-notes-slate"
184188
build false
185189
}
190+
186191
}
187192

188193
task api (type: Javadoc) {

buildSrc/src/main/groovy/org/springframework/restdocs/build/SampleBuildConfigurer.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ public class SampleBuildConfigurer {
6161
replaceVersion(new File(this.workingDir, 'build.gradle'),
6262
"ext\\['spring-restdocs.version'\\] = '.*'",
6363
"ext['spring-restdocs.version'] = '${project.version}'")
64+
replaceVersion(new File(this.workingDir, 'build.gradle'),
65+
"restDocsVersion = \".*\"",
66+
"restDocsVersion = \"${project.version}\"")
6467
}
6568
}
6669
else if (new File(sampleDir, 'pom.xml').isFile()) {

docs/src/docs/asciidoc/getting-started.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ If you want to jump straight in, a number of sample applications are available:
1818
| Gradle
1919
| Demonstrates the use of Spring REST Docs with http://rest-assured.io[REST Assured].
2020

21+
| {samples}/rest-notes-grails[Grails]
22+
| Gradle
23+
| Demonstrates the use of Spring REST docs with https://grails.org[Grails] and https://github.com/spockframework/spock[Spock]
24+
2125
| {samples}/rest-notes-slate[Slate]
2226
| Gradle
2327
| Demonstrates the use of Spring REST Docs with Markdown and
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Thumbs.db
2+
.DS_Store
3+
.gradle
4+
build/
5+
classes/
6+
.idea
7+
*.iml
8+
*.ipr
9+
*.iws
10+
.project
11+
.settings
12+
.classpath
13+
gradlew*
14+
gradle/wrapper
15+
16+
17+
src/docs/generated-snippets
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# grails-spring-restdocs-example
2+
Example of using Spring REST Docs with Grails
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
buildscript {
2+
ext {
3+
grailsVersion = project.grailsVersion
4+
}
5+
repositories {
6+
mavenLocal()
7+
maven { url "https://repo.grails.org/grails/core" }
8+
maven { url 'https://repo.spring.io/libs-snapshot' }
9+
}
10+
dependencies {
11+
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
12+
classpath "org.grails.plugins:hibernate:4.3.10.5"
13+
classpath 'org.ajoberstar:gradle-git:1.1.0'
14+
}
15+
}
16+
17+
plugins {
18+
id "io.spring.dependency-management" version "0.5.4.RELEASE"
19+
id 'org.asciidoctor.convert' version '1.5.3'
20+
}
21+
22+
version "0.1"
23+
group "com.example"
24+
25+
apply plugin: "spring-boot"
26+
apply plugin: "war"
27+
apply plugin: 'eclipse'
28+
apply plugin: 'idea'
29+
apply plugin: "org.grails.grails-web"
30+
31+
ext {
32+
grailsVersion = project.grailsVersion
33+
gradleWrapperVersion = project.gradleWrapperVersion
34+
restDocsVersion = "1.1.0.BUILD-SNAPSHOT"
35+
snippetsDir = file('src/docs/generated-snippets')
36+
}
37+
38+
repositories {
39+
mavenLocal()
40+
maven { url 'https://repo.spring.io/libs-snapshot' }
41+
maven { url "https://repo.grails.org/grails/core" }
42+
}
43+
44+
dependencyManagement {
45+
dependencies {
46+
dependency "org.springframework.restdocs:spring-restdocs-restassured:$restDocsVersion"
47+
}
48+
imports {
49+
mavenBom "org.grails:grails-bom:$grailsVersion"
50+
}
51+
applyMavenExclusions false
52+
}
53+
54+
dependencies {
55+
compile "org.springframework.boot:spring-boot-starter-logging"
56+
compile "org.springframework.boot:spring-boot-starter-actuator"
57+
compile "org.springframework.boot:spring-boot-autoconfigure"
58+
compile "org.springframework.boot:spring-boot-starter-tomcat"
59+
compile "org.grails:grails-plugin-url-mappings"
60+
compile "org.grails:grails-plugin-rest"
61+
compile "org.grails:grails-plugin-interceptors"
62+
compile "org.grails:grails-plugin-services"
63+
compile "org.grails:grails-plugin-datasource"
64+
compile "org.grails:grails-plugin-databinding"
65+
compile "org.grails:grails-plugin-async"
66+
compile "org.grails:grails-web-boot"
67+
compile "org.grails:grails-logging"
68+
69+
compile "org.grails.plugins:hibernate"
70+
compile "org.grails.plugins:cache"
71+
compile "org.hibernate:hibernate-ehcache"
72+
73+
runtime "com.h2database:h2"
74+
75+
testCompile "org.grails:grails-plugin-testing"
76+
testCompile "org.grails.plugins:geb"
77+
testCompile 'org.springframework.restdocs:spring-restdocs-restassured'
78+
79+
console "org.grails:grails-console"
80+
}
81+
82+
task wrapper(type: Wrapper) {
83+
gradleVersion = gradleWrapperVersion
84+
}
85+
86+
ext {
87+
snippetsDir = file('src/docs/generated-snippets')
88+
}
89+
90+
task cleanTempDirs(type: Delete) {
91+
delete fileTree(dir: 'src/docs/generated-snippets')
92+
}
93+
94+
test {
95+
dependsOn cleanTempDirs
96+
outputs.dir snippetsDir
97+
}
98+
99+
asciidoctor {
100+
dependsOn integrationTest
101+
inputs.dir snippetsDir
102+
sourceDir = file('src/docs')
103+
separateOutputDirs = false
104+
attributes 'snippets': snippetsDir
105+
}
106+
107+
build.dependsOn asciidoctor
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
grailsVersion=3.0.15
2+
gradleWrapperVersion=2.3
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
---
2+
grails:
3+
profile: web-api
4+
codegen:
5+
defaultPackage: com.example
6+
info:
7+
app:
8+
name: '@info.app.name@'
9+
version: '@info.app.version@'
10+
grailsVersion: '@info.app.grailsVersion@'
11+
spring:
12+
groovy:
13+
template:
14+
check-template-location: false
15+
16+
---
17+
grails:
18+
mime:
19+
disable:
20+
accept:
21+
header:
22+
userAgents:
23+
- Gecko
24+
- WebKit
25+
- Presto
26+
- Trident
27+
types:
28+
all: '*/*'
29+
atom: application/atom+xml
30+
css: text/css
31+
csv: text/csv
32+
form: application/x-www-form-urlencoded
33+
html:
34+
- text/html
35+
- application/xhtml+xml
36+
js: text/javascript
37+
json:
38+
- application/json
39+
- text/json
40+
multipartForm: multipart/form-data
41+
rss: application/rss+xml
42+
text: text/plain
43+
hal:
44+
- application/hal+json
45+
- application/hal+xml
46+
xml:
47+
- text/xml
48+
- application/xml
49+
urlmapping:
50+
cache:
51+
maxsize: 1000
52+
controllers:
53+
defaultScope: singleton
54+
converters:
55+
encoding: UTF-8
56+
hibernate:
57+
cache:
58+
queries: false
59+
60+
---
61+
dataSource:
62+
pooled: true
63+
jmxExport: true
64+
driverClassName: org.h2.Driver
65+
username: sa
66+
password:
67+
68+
environments:
69+
development:
70+
dataSource:
71+
dbCreate: create-drop
72+
url: jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
73+
test:
74+
dataSource:
75+
dbCreate: update
76+
url: jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
77+
production:
78+
dataSource:
79+
dbCreate: update
80+
url: jdbc:h2:./prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE
81+
properties:
82+
jmxEnabled: true
83+
initialSize: 5
84+
maxActive: 50
85+
minIdle: 5
86+
maxIdle: 25
87+
maxWait: 10000
88+
maxAge: 600000
89+
timeBetweenEvictionRunsMillis: 5000
90+
minEvictableIdleTimeMillis: 60000
91+
validationQuery: SELECT 1
92+
validationQueryTimeout: 3
93+
validationInterval: 15000
94+
testOnBorrow: true
95+
testWhileIdle: true
96+
testOnReturn: false
97+
jdbcInterceptors: ConnectionState
98+
defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2014-2016 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import grails.util.BuildSettings
18+
import grails.util.Environment
19+
20+
// See http://logback.qos.ch/manual/groovy.html for details on configuration
21+
appender('STDOUT', ConsoleAppender) {
22+
encoder(PatternLayoutEncoder) {
23+
pattern = "%level %logger - %msg%n"
24+
}
25+
}
26+
27+
root(ERROR, ['STDOUT'])
28+
29+
def targetDir = BuildSettings.TARGET_DIR
30+
if (Environment.isDevelopmentMode() && targetDir) {
31+
appender("FULL_STACKTRACE", FileAppender) {
32+
file = "${targetDir}/stacktrace.log"
33+
append = true
34+
encoder(PatternLayoutEncoder) {
35+
pattern = "%level %logger - %msg%n"
36+
}
37+
}
38+
logger("StackTrace", ERROR, ['FULL_STACKTRACE'], false)
39+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Place your Spring DSL code here
2+
beans = {}

0 commit comments

Comments
 (0)