-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
176 lines (152 loc) · 5.38 KB
/
build.gradle
File metadata and controls
176 lines (152 loc) · 5.38 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
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath "org.flywaydb:flyway-database-postgresql:11.1.0"
}
}
plugins {
id 'org.jetbrains.kotlin.jvm' version '1.9.25'
id 'org.jetbrains.kotlin.plugin.spring' version '1.9.25'
id 'org.jetbrains.kotlin.kapt' version '1.9.25'
id 'org.springframework.boot' version '3.3.5'
id 'io.spring.dependency-management' version '1.1.6'
id 'org.jetbrains.kotlin.plugin.jpa' version '1.9.25'
id 'com.ncorti.ktfmt.gradle' version '0.21.0'
id 'org.flywaydb.flyway' version '11.1.0'
id 'co.uzzu.dotenv.gradle' version '4.0.0'
}
// plugin config
ktfmt {
kotlinLangStyle()
}
flyway {
url = env.fetch('JDBC_DATABASE_URL', '')
user = env.fetch('JDBC_DATABASE_USERNAME', '')
password = env.fetch('JDBC_DATABASE_PASSWORD', '')
}
group = 'iterative.harmony'
version = '0.1' // Semantic versioning: MAJOR.MINOR
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencies {
developmentOnly 'org.springframework.boot:spring-boot-devtools'
implementation "org.mapstruct:mapstruct:1.5.3.Final"
kapt "org.mapstruct:mapstruct-processor:1.5.3.Final"
implementation 'me.paulschwarz:spring-dotenv:4.0.0'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-mail'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'org.springframework.boot:spring-boot-starter-security'
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.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1"
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-reactor'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-csv'
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin'
implementation 'org.flywaydb:flyway-database-postgresql:11.1.0'
implementation 'org.jetbrains.kotlin:kotlin-reflect'
implementation 'org.postgresql:postgresql'
implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
implementation 'io.jsonwebtoken:jjwt-impl:0.11.5'
implementation 'io.jsonwebtoken:jjwt-jackson:0.11.5'
implementation 'io.sentry:sentry-spring-boot-starter-jakarta:8.6.0'
implementation 'com.bucket4j:bucket4j_jdk17-core:8.15.0'
implementation 'org.springframework.boot:spring-boot-starter-cache'
implementation 'com.github.ben-manes.caffeine:caffeine'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.jetbrains.kotlin:kotlin-test-junit5'
testImplementation 'org.springframework.security:spring-security-test'
testImplementation 'org.mockito:mockito-core:5.9.0'
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.2'
testImplementation 'org.mockito.kotlin:mockito-kotlin:5.3.1'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
testRuntimeOnly 'com.h2database:h2'
}
kapt {
arguments {
arg("mapstruct.defaultComponentModel", "spring")
arg("mapstruct.unmappedTargetPolicy", "IGNORE")
}
correctErrorTypes = true
}
kotlin {
compilerOptions {
freeCompilerArgs.addAll '-Xjsr305=strict'
}
}
allOpen {
annotation 'jakarta.persistence.Entity'
annotation 'jakarta.persistence.MappedSuperclass'
annotation 'jakarta.persistence.Embeddable'
}
tasks.named('test') {
useJUnitPlatform()
}
tasks.withType(Test) {
reports {
junitXml.required = true // Ensure XML reports are generated
html.required = true // Enable HTML reports
}
}
// docker tasks
tasks.register('buildDockerImage', Exec) {
dependsOn bootJar
commandLine 'docker', 'build', '-t', 'harmony-backend:latest', '.'
}
tasks.register('runDockerContainer', Exec) {
dependsOn buildDockerImage
doFirst {
// Remove any existing container
exec {
ignoreExitValue = true
commandLine 'docker', 'rm', '-f', 'harmony-backend'
}
}
commandLine 'docker', 'run', '--name', 'harmony-backend', '--rm', '-p', '8080:8080', '--env-file', '.env', 'harmony-backend:latest'
}
tasks.register('newMigration') {
def templateFile = file('src/main/resources/templates/migration_template.sql')
inputs.file(templateFile)
doLast {
def migrationsDir = file('src/main/resources/db/migration')
def version = new Date().format('yyyyMMddHHmmss') // Timestamp for versioning
def description = project.hasProperty('desc') ? project.desc : 'new_migration'
def fileName = "V${version}__${description.replaceAll('\\s+', '_')}.sql"
def migrationFile = new File(migrationsDir, fileName)
if (!migrationsDir.exists()) {
migrationsDir.mkdirs()
}
def templateContent
if (templateFile.exists()) {
templateContent = templateFile.text
} else {
println "Warning: Migration template not found at ${templateFile.path}. Using default content."
templateContent = "-- Write your migration SQL here\n"
}
migrationFile.text = templateContent
println "Created migration file: $migrationFile"
}
}
// The task below prints the DB URL during gradle build for troubleshooting purposes
//tasks.register('printDatabaseUrl') {
// doLast {
// println "JDBC_DATABASE_URL: ${env.fetch('JDBC_DATABASE_URL')}"
// }
//}
//buildDockerImage.dependsOn printDatabaseUrl
//bootRun.dependsOn printDatabaseUrl