This repository was archived by the owner on Mar 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle
More file actions
105 lines (82 loc) · 3.28 KB
/
build.gradle
File metadata and controls
105 lines (82 loc) · 3.28 KB
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
plugins {
id 'java'
id 'groovy'
id 'org.springframework.boot' version '2.2.6.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'org.unbroken-dome.test-sets' version '2.1.1'
id "com.github.ben-manes.versions" version "0.28.0"
// add processor-gradle plugin
id 'com.github.hauner.openapi-processor' version '1.0.0.M7'
}
group = 'com.github.hauner'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral ()
maven { url 'https://repo.spring.io/milestone' }
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'org.mapstruct:mapstruct:1.3.1.Final'
annotationProcessor 'org.mapstruct:mapstruct-processor:1.3.1.Final'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'io.projectreactor:reactor-test'
testImplementation 'org.spockframework:spock-core:1.3-groovy-2.5'
testImplementation 'org.spockframework:spock-spring:1.3-groovy-2.5'
testAnnotationProcessor 'org.mapstruct:mapstruct-processor:1.3.1.Final'
}
// add the targetDir of the processor as additional source folder to java.
sourceSets {
main {
java {
// add generated files
srcDir 'build/openapi'
}
resources {
srcDir "$buildDir/json"
}
}
}
test {
useJUnitPlatform()
}
testSets {
testInt
}
// generate api before compiling
compileJava.dependsOn ('processSpring')
processResources.dependsOn ('processJson')
check.dependsOn testInt
// configure an openapi-processor inside the 'openapiProcessor' configuration by adding a nested
// configuration with the name of the openapi-processor and its options inside it.
//
// ... using 'spring' and 'json'.
openapiProcessor {
// the path to the open api yaml file. Usually the same for all processors.
apiPath "${projectDir}/src/api/openapi.yaml"
// based on the name of the processor configuration the plugin creates a gradle task with name
// "process${name of processor}" (in this case "processSpring") to run the processor.
spring {
// the spring processor dependency
processor 'com.github.hauner.openapi:openapi-processor-spring:1.0.0.M13'
// setting api path inside a processor configuration overrides the one at the top.
// apiPath "${projectDir}/src/api/openapi.yaml"
// the destination folder for generating interfaces & models. This is the parent of the
// {package-name} folder tree configured in the mapping file.
targetDir "$projectDir/build/openapi"
// file name of the mapping yaml configuration file. Note that the yaml file name must end
// with either {@code .yaml} or {@code .yml}.
mapping "${projectDir}/src/api/mapping.yaml"
// sets the parser to SWAGGER or OPENAPI4J. if not set SWAGGER is used.
// OPENAPI4J provides better validation.
parser 'OPENAPI4J'
// show warnings from the open api parser.
showWarnings true
}
// applying the rules described above the task to run this one is "processJson".
json {
// the json processor dependency
processor 'com.github.hauner.openapi:openapi-processor-json:1.0.0.M3'
targetDir "$buildDir/json"
}
}