-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathbuild.gradle
More file actions
215 lines (172 loc) · 6.37 KB
/
build.gradle
File metadata and controls
215 lines (172 loc) · 6.37 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
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
213
214
215
buildscript {
repositories { mavenCentral() }
dependencies { classpath("org.flywaydb:flyway-database-postgresql:10.1.0") }
}
plugins {
id 'application'
id 'org.springframework.boot' version '3.4.5'
id 'io.spring.dependency-management' version '1.1.7'
id "org.sonarqube" version "5.1.0.4882"
id "com.diffplug.spotless" version "6.19.0"
id "org.flywaydb.flyway" version "10.1.0"
id 'java'
id 'jacoco'
}
group = 'dev.findfirst'
version = '1.0.0'
// Apply a specific Java toolchain to ease working on different environments.
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
spotless {
// optional: limit format enforcement to just the files changed by this feature branch
//ratchetFrom 'origin/main'
format 'misc', {
// define the files to apply `misc` to
target '*.gradle', '*.md', '.gitignore'
// define the steps to apply to those files
trimTrailingWhitespace()
indentWithSpaces(2)
endWithNewline()
encoding 'UTF-8'
}
java {
// optional: you can specify import groups directly
// note: you can use an empty string for all the imports you didn't specify explicitly, and '\\#` prefix for static imports
importOrder('java', 'jakarta', 'dev.findfirst')
// optional: instead of specifying import groups directly you can specify a config file
// export config file: https://github.com/diffplug/spotless/blob/main/ECLIPSE_SCREENSHOTS.md#creating-spotlessimportorder
removeUnusedImports()
// Choose one of these formatters.
eclipse().configFile("eclipse-java-google-style.xml")
formatAnnotations() // fixes formatting of type annotations, see below
//licenseHeader '/* (C) $YEAR */' // or licenseHeaderFile
}
}
task createKeys(type: JavaExec) {
main = 'dev.findfirst.security.util.KeyGenerator' // Replace with the fully qualified class name of your utility
classpath = sourceSets.main.runtimeClasspath
}
tasks.named("build") {
dependsOn("spotlessApply")
}
tasks.named("bootRun") {
dependsOn('flywayMigrate')
}
repositories {
mavenCentral()
}
dependencies {
compileOnly 'org.projectlombok:lombok'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'org.springframework.boot:spring-boot-starter-mail'
implementation 'org.jsoup:jsoup:1.17.2'
implementation 'org.flywaydb:flyway-core:10.17.1'
// https://mvnrepository.com/artifact/org.springframework.data/spring-data-jdbc
implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
implementation group: 'com.github.crawler-commons', name: 'crawler-commons', version: '1.4'
implementation 'org.apache.httpcomponents.client5:httpclient5:5.5-alpha1'
implementation 'org.typesense:typesense-java:1.3.0'
runtimeOnly 'org.flywaydb:flyway-database-postgresql:11.8.1'
runtimeOnly 'org.postgresql:postgresql:42.7.5'
runtimeOnly group: 'io.jsonwebtoken', name: 'jjwt-impl', version: '0.11.5'
//implementation 'io.jsonwebtoken:jjwt-api:0.12.6'
//runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.12.6'
runtimeOnly 'io.jsonwebtoken:jjwt-jackson:0.11.5'
implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
annotationProcessor 'org.projectlombok:lombok'
testAnnotationProcessor 'org.projectlombok:lombok'
testCompileOnly 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
testImplementation 'org.testcontainers:postgresql'
testImplementation 'org.springframework.boot:spring-boot-testcontainers'
testImplementation "org.testcontainers:junit-jupiter"
testImplementation 'org.junit.jupiter:junit-jupiter-api'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
}
application {
mainClass = 'dev.findfirst.FindFirstApplication'
}
bootRun
{
String activeProfile = System.properties['spring.profiles.active']
if(activeProfile == null || activeProfile.isBlank()) {
systemProperty "spring.profiles.active", "dev";
}
}
test {
systemProperty 'spring.profiles.active', 'integration'
useJUnitPlatform()
testLogging.showStandardStreams = true
finalizedBy jacocoTestReport // report is always generated after tests run
dependsOn("createKeys")
}
jacocoTestReport {
reports {
xml.required = true
csv.required = true
xml.destination = file("$buildDir/reports/coverage.xml")
}
}
sonar {
properties {
property "sonar.projectKey", "findfirst_server"
property "sonar.organization", "findfirst"
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.gradle.skipCompile", "true"
}
}
def setFlywayDev(dbScripts) {
addDevScriptsToMigrations(dbScripts);
flyway.cleanDisabled = false;
}
def isDevProfile(String profile) {
return profile == null || profile.equalsIgnoreCase("integration") || profiles.equalsIgnoreCase("dev");
}
def addDevScriptsToMigrations(dbScripts) {
dbScripts.add("classpath:db/dev");
flyway.locations = dbScripts;
}
def setFlywayPrefrences(profiles, dbScripts) {
if(profiles != null) {
boolean isList = profiles instanceof List;
if (isList) {
for(String prof in profiles) {
if(isDevProfile(prof)) {
setFlywayDev(dbScripts);
break;
}
}
} else if(isDevProfile(profiles)) {
setFlywayDev(dbScripts);
}
}
// spring.profiles.active are always set for production,
// otherwise assume we're in development if null.
else {
setFlywayDev(dbScripts);
}
}
flyway {
// our defaults
def dbScripts = ["classpath:db/migration"];
locations = dbScripts;
cleanDisabled = true;
// Set env preferences
String profiles = System.getenv("SPRING_PROFILES_ACTIVE");
setFlywayPrefrences(profiles, dbScripts);
// Get the system property or use the default, i.e. development defaults.
url = System.getProperty("SPRING_DATASOURCE_URL", "jdbc:postgresql://localhost:5432/findfirst")
user = System.getProperty("POSTGRES_USER", "postgres")
password = System.getProperty("POSTGRES_PASSWORD", "admin")
driver = "org.postgresql.Driver"
}
flywayMigrate.dependsOn classes