-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
212 lines (175 loc) · 4.77 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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
/*
* This file was generated by the Gradle 'init' task.
*
* This is a general purpose Gradle build.
* To learn more about Gradle by exploring our Samples at https://docs.gradle.org/8.3/samples
* This project uses @Incubating APIs which are subject to change.
*/
plugins {
id 'java-library'
id "org.openapi.generator" version "6.6.0"
id 'io.github.gradle-nexus.publish-plugin' version '1.1.0'
id "maven-publish"
id 'signing'
id 'jacoco'
id 'com.diffplug.spotless' version "6.13.0"
id "org.springframework.boot" version "2.7.16"
}
bootJar {
enabled = false
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
withJavadocJar()
withSourcesJar()
}
tasks.withType(Javadoc) {
// Specify the files or packages to be excluded from Javadoc generation
exclude '**/AsyncStateOptions.java'
exclude '**/ProcessOptions.java'
}
repositories {
mavenCentral()
}
dependencies {
// for openapi generator
implementation 'com.google.guava:guava:32.1.2-jre'
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310"
implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.2'
implementation 'io.github.openfeign:feign-okhttp:12.5'
implementation 'io.github.openfeign:feign-jackson:12.5'
implementation 'io.github.openfeign:feign-slf4j:12.5'
implementation 'io.github.openfeign.form:feign-form:3.8.0'
implementation 'org.openapitools:jackson-databind-nullable:0.2.6'
implementation 'javax.annotation:javax.annotation-api:1.3.2'
// lombok
compileOnly 'org.projectlombok:lombok:1.18.30'
annotationProcessor 'org.projectlombok:lombok:1.18.30'
// bytebuddy
implementation 'net.bytebuddy:byte-buddy-gradle-plugin:1.14.9'
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.0'
testCompileOnly 'org.projectlombok:lombok:1.18.30'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.30'
testImplementation 'org.springframework.boot:spring-boot-starter-web:2.7.16'
}
// open api
openApiValidate {
inputSpec.set("$rootDir/apis/api-schema/xcherry.yaml")
}
openApiGenerate {
generatorName = "java"
inputSpec = "$rootDir/apis/api-schema/xcherry.yaml".toString()
outputDir = "$buildDir/generated".toString()
apiPackage = "io.xcherry.gen.api"
modelPackage = "io.xcherry.gen.models"
invokerPackage = "io.xcherry.gen.api"
configOptions = [
configPackage: "io.xcherry.gen.configuration",
basePackage : "io.xcherry.gen",
library : "feign",
interfaceOnly: "true"
]
}
compileJava.dependsOn tasks.openApiGenerate
sourceSets.main.java.srcDirs += "$buildDir/generated/src/main/java"
tasks.named('sourcesJar').configure {
dependsOn tasks.openApiGenerate
}
// test
tasks.named('test') {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
}
jacocoTestReport {
reports {
html.required = true
xml.required = true
}
}
check.dependsOn tasks.jacocoTestReport
// spotless
spotless {
def prettierPlugins = [
"prettier": "2.5.1",
"prettier-plugin-java": "1.6.1",
]
def ignoredDirs = [
'.gradle/**',
'.idea/**',
'build/**'
]
format 'misc', {
// define the files to apply `misc` to
target '*.gradle', '.gitignore'
targetExclude(ignoredDirs)
// define the steps to apply to those files
trimTrailingWhitespace()
indentWithTabs() // or spaces. Takes an integer argument if you don't like 4
endWithNewline()
}
format 'markdown', {
target '*.md'
targetExclude(ignoredDirs)
prettier(prettierPlugins).config([
'parser': 'markdown'
])
}
java {
targetExclude(ignoredDirs)
importOrder()
removeUnusedImports()
prettier(prettierPlugins).config([
'parser': 'java',
'tabWidth': 4,
'printWidth': 120
])
}
}
test.dependsOn tasks.spotlessApply
// publish
publishing {
publications {
mavenJava(MavenPublication) {
from(components.java)
pom {
name = "xcherry-java-sdk"
description = "xcherry java sdk core"
url = 'https://github.com/xcherryio/sdk-java'
scm {
connection = 'scm:[email protected]:xcherryio/sdk-java.git'
developerConnection = 'scm:[email protected]:xcherryio/sdk-java.git'
url = 'https://github.com/xcherryio/sdk-java'
}
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'zhukaili'
name = 'Kaili Zhu'
email = '[email protected]'
}
}
}
}
}
}
signing {
sign publishing.publications.mavenJava
}
group = "io.xcherry"
version = "0.0.1"
nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
// username = project.property('myNexusUsername')
// password = project.property('myNexusPassword')
}
}
}