This repository has been archived by the owner on Aug 31, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
177 lines (149 loc) · 5.19 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
buildscript {
ext {
springBootVersion = '2.1.1.RELEASE'
// path to snippets generated by Spring REST Docs
snippetsDir = file('build/generated-snippets')
// used by Spring Auto REST Docs
javadocJsonDir = file("$buildDir/generated-javadoc-json")
}
repositories {
mavenCentral()
// used for restdoc-apispec
jcenter()
// asciidoctor diagram
maven {url = uri("https://jitpack.io") }
// dependency asciidoctor-diagram/viz.js
maven {url "https://plugins.gradle.org/m2/"}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
// restdoc-apispec
classpath("com.epages:restdocs-api-spec-gradle-plugin:0.6.0")
// fetching from confluence
classpath 'net.sourceforge.htmlcleaner:htmlcleaner:2.4'
classpath 'org.codehaus.groovy.modules.http-builder:http-builder:0.7.1'
// diagram
classpath "com.github.jruby-gradle:jruby-gradle-plugin:[1.1.4,2.0)"
// graphiz; you might also have graphviz installed
classpath 'com.github.jeysal:gradle-graphviz-plugin:master-SNAPSHOT'
}
}
// needed for Spring Auto REST Docs
configurations {
jsondoclet
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
// asciidoctor
apply plugin: 'org.asciidoctor.convert'
// restdocs-apispec
apply plugin: 'com.epages.restdocs-api-spec'
// diagram
apply plugin: 'com.github.jruby-gradle.base'
// graphviz
apply plugin: 'com.github.jeysal.graphviz'
group = 'com.heidelpay.jm'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
// restdoc-apispec
jcenter()
}
dependencies {
implementation('org.springframework.boot:spring-boot-starter-data-jpa')
implementation('org.springframework.boot:spring-boot-starter-validation')
implementation('org.springframework.boot:spring-boot-starter-web')
runtimeOnly('org.springframework.boot:spring-boot-devtools')
runtimeOnly('com.h2database:h2')
testImplementation('org.springframework.boot:spring-boot-starter-test')
// diagram
gems 'rubygems:asciidoctor-diagram:1.5.11'
// enable asciidoctor task
asciidoctor 'org.springframework.restdocs:spring-restdocs-asciidoctor:2.0.3.RELEASE'
// Spring REST Docs
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc:2.0.3.RELEASE'
// Spring Auto REST Docs
testImplementation 'capital.scalable:spring-auto-restdocs-core:2.0.3'
jsondoclet 'capital.scalable:spring-auto-restdocs-json-doclet:2.0.3'
// restdoc-apispec
testCompile('com.epages:restdocs-api-spec-mockmvc:0.8.0')
}
openapi {
basePath = "/api"
host = "localhost:8080"
schemes = ["https"]
format = "json"
title = 'heidelpay API'
version = "1.0.0"
separatePublicApi = true
snippetsDirectory="build/generated-snippets/openapi/spec/charge"
outputDirectory="build/openapi/"
}
openapi3 {
server = 'http://localhost:8080'
title = 'heidelpay API'
version = '0.1.0'
format = 'json'
outputDirectory="build/openapi/"
snippetsDirectory="build/generated-snippets/openapi/spec/charge"
}
// used by Spring REST Docs
task jsonDoclet(type: Javadoc, dependsOn: compileJava) {
source = sourceSets.main.allJava
classpath = sourceSets.main.compileClasspath
destinationDir = javadocJsonDir
options.docletpath = configurations.jsondoclet.files.asType(List)
options.doclet = 'capital.scalable.restdocs.jsondoclet.ExtractDocumentationAsJsonDoclet'
options.memberLevel = JavadocMemberLevel.PACKAGE
}
test {
// folder used by spring restdoc
outputs.dir snippetsDir
// Spring Auto REST Docs
systemProperty 'org.springframework.restdocs.outputDir', snippetsDir
systemProperty 'org.springframework.restdocs.javadocJsonDir', javadocJsonDir
// call for auto REST Doc
dependsOn jsonDoclet
}
task("slate", dependsOn: test) {
doLast {
String indexFile = 'src/docs/index.md.gsp'
def template = new groovy.text.SimpleTemplateEngine().createTemplate(new File(indexFile)).make()
mkdir "build/slate"
new File("build/slate/index.html.md").write(template.toString())
}
}
// NOTE: call gradlew importConfluence -Dorg.gradle.daemon=false --console=plain
// --> System.console() from where the pwd is read won't work
task("importConfluence") {
mkdir "build/generated-snippets/confluence"
doLast {
binding.setProperty("outputDir", new File("build/generated-snippets/confluence"))
binding.setProperty("pages",[ [ 'id':'72286211', 'title':'intro'],[ 'id':'72417281', 'title':'Info' ] ] )
evaluate(new File("src/build/confluenceImport.groovy"))
}
}
// NOTE: call gradlew asciidoctor -Dorg.gradle.daemon=false --console=plain
// --> System.console() from where the pwd is read won't work
asciidoctor {
sourceDir = file('src/docs')
outputDir = file('build/docs')
// execute tests first for Spring REST Docs; jRubyPrepare for diagram plugin
dependsOn jrubyPrepare, test, importConfluence
mustRunAfter importConfluence, test
requires = ['asciidoctor-diagram']
gemPath = jrubyPrepare.outputDir
}
task("docs") {
dependsOn asciidoctor, slate
}
// optional task: ship docs as static content
bootJar {
dependsOn docs
from ("${asciidoctor.outputDir}/html5") {
into 'static/docs'
}
}