-
Notifications
You must be signed in to change notification settings - Fork 65
/
build.gradle
135 lines (118 loc) · 4.22 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
import java.util.regex.Pattern
plugins {
id 'java'
id 'idea'
id 'io.freefair.lombok' version '8.6'
id 'com.github.ben-manes.versions' version '0.51.0'
// https://docs.spring.io/spring-boot/docs/current/reference/html/dependency-versions.html
id 'org.springframework.boot' version '3.3.1'
id 'io.spring.dependency-management' version '1.1.5'
id "com.vaadin" version "24.4.4"
id "org.openapi.generator" version '7.6.0'
}
apply from: './gradle/dependencies.gradle'
apply from: './gradle/testing.gradle'
group = theGroup
archivesBaseName = theArchivesBaseName
idea {
module {
downloadJavadoc = true
downloadSources = true
}
}
compileJava {
options.encoding = 'UTF-8'
}
java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
wrapper {
distributionType = Wrapper.DistributionType.ALL
gradleVersion = '8.8'
doLast {
delete "$projectDir/gradlew.bat", "$projectDir/gradlew"
}
}
vaadin {
nodeAutoUpdate = false
nodeVersion = 'v20.13.1'
pnpmEnable = true
productionMode = true
forceProductionBuild
}
classes {
doLast {
def resourcesDir = sourceSets.main.output.resourcesDir as File
def releaseVersion = System.env.RELEASE_VERSION as String
if (releaseVersion) {
new File(resourcesDir, "version.info").text = releaseVersion
} else {
new File(resourcesDir, "version.info").text = version
}
}
}
springBoot {
mainClass = "ru.iopump.qa.allure.Application"
}
tasks.named("bootJar") {
manifest {
attributes 'Main-Class': 'org.springframework.boot.loader.launch.PropertiesLauncher'
}
}
//// OPENAPI ////
// https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator-gradle-plugin
// https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators.md
// https://openapi-generator.tech/docs/generators/spring/
openApiGenerate {
generatorName = "spring"
library = "spring-boot"
inputSpec = "$rootDir/src/test/resources/tms/openapi-youtrack.json"
outputDir = "$projectDir/build/generated"
apiPackage = "org.brewcode.api.youtrack"
invokerPackage = "org.brewcode.api.youtrack.invoker"
modelPackage = "org.brewcode.api.youtrack.model"
modelNameSuffix = "Dto"
importMappings = [
SavedQueryDto: "org.brewcode.api.youtrack.model.SavedQueryDto",
]
configOptions = [
useBeanValidation : "false",
useJakartaEe : "true",
serializationLibrary : "jackson",
annotationLibrary : "swagger2",
generatedConstructorWithRequiredArgs: "true",
dateLibrary : "java8",
useSpringBoot3 : "true",
interfaceOnly : "true",
openApiNullable : "false",
useResponseEntity : "false", // Не использовать ResponseEntity<Е>, а сразу вернуть Е
skipDefaultInterface : "true" // Не добавлять в интерфейс default реализацию
]
}
tasks.named("openApiGenerate") {
doLast {
def directory = file("build/generated/src/main/java/org/brewcode/api/youtrack/model")
directory.eachFile {
def pattern = Pattern.compile('Type\\(value = (.+).class')
def matcher = pattern.matcher(it.text)
if (matcher.find())
it.text = matcher.replaceAll { match -> 'Type(value = org.brewcode.api.youtrack.model.%s.class'.formatted(match.group(1)) }
if (it.name == 'BaseBundleDto.java') {
it.text = it.text.readLines().withIndex().findAll { line, index -> index < 72 || index > 98 }.collect { it[0] }.join("\n")
}
}
}
}
compileJava.dependsOn tasks.openApiGenerate
compileTestJava.dependsOn tasks.openApiGenerate
sourceSets.main.java.srcDirs += tasks.openApiGenerate
bootJar {
manifest {
attributes 'Main-Class': 'org.springframework.boot.loader.launch.PropertiesLauncher'
}
}
wrapper {
gradleVersion = '8.8'
distributionType = Wrapper.DistributionType.ALL
}