-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
272 lines (222 loc) · 8.87 KB
/
build.gradle.kts
File metadata and controls
272 lines (222 loc) · 8.87 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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
import java.security.MessageDigest
plugins {
`java-library`
`maven-publish`
}
description = "Command-line interface for Flamingock audit and issue management operations"
dependencies {
implementation(project(":core:flamingock-core"))
implementation(project(":community:flamingock-community"))
implementation(project(":utils:sql-util"))
// CLI framework
implementation("info.picocli:picocli:4.7.5")
// YAML configuration
implementation("org.yaml:snakeyaml:2.2")
// JSON formatting
implementation("com.google.code.gson:gson:2.10.1")
// Database clients (community edition)
implementation("org.mongodb:mongodb-driver-sync:4.9.1")
implementation("software.amazon.awssdk:dynamodb:2.20.0")
implementation ("com.couchbase.client:java-client:3.7.3")
// SQL drivers
implementation("mysql:mysql-connector-java:8.0.33")
implementation("com.microsoft.sqlserver:mssql-jdbc:12.4.2.jre8")
implementation("com.oracle.database.jdbc:ojdbc8:21.9.0.0")
implementation("org.postgresql:postgresql:42.7.3")
implementation("org.mariadb.jdbc:mariadb-java-client:3.3.2")
implementation("com.h2database:h2:2.2.224")
implementation("org.xerial:sqlite-jdbc:3.41.2.1")
implementation("com.ibm.informix:jdbc:4.50.10")
implementation("org.firebirdsql.jdbc:jaybird:4.0.10.java8")
// HikariCP for SQL database connection pooling
implementation("com.zaxxer:HikariCP:3.4.5")
// SLF4J API - needed for interface compatibility (provided by flamingock-core)
// implementation("org.slf4j:slf4j-api:1.7.36") // Already provided by core dependencies
// Test dependencies
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.1")
testImplementation("org.junit.jupiter:junit-jupiter-engine:5.10.1")
testImplementation("org.junit.jupiter:junit-jupiter-params:5.10.1")
testImplementation("org.mockito:mockito-core:5.8.0")
testImplementation("org.mockito:mockito-junit-jupiter:5.8.0")
testImplementation("org.assertj:assertj-core:3.24.2")
testImplementation("org.testcontainers:junit-jupiter:1.19.3")
testImplementation("org.testcontainers:mongodb:1.19.3")
testImplementation("org.testcontainers:couchbase:1.19.3")
testImplementation("com.github.stefanbirkner:system-lambda:1.2.1")
// SQL Testcontainers
testImplementation("org.testcontainers:mysql:1.19.3")
testImplementation("org.testcontainers:mssqlserver:1.19.3")
testImplementation("org.testcontainers:oracle-xe:1.19.3")
testImplementation("org.testcontainers:postgresql:1.19.3")
testImplementation("org.testcontainers:mariadb:1.19.3")
}
// Create UberJar with all dependencies
val uberJar by tasks.registering(Jar::class) {
group = "build"
description = "Create a self-contained JAR with all dependencies"
archiveBaseName.set("flamingock-cli")
archiveClassifier.set("uber")
archiveVersion.set(project.version.toString())
isZip64 = true
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
manifest {
attributes["Main-Class"] = "io.flamingock.cli.FlamingockCli"
attributes["Implementation-Title"] = project.name
attributes["Implementation-Version"] = project.version
}
from(sourceSets.main.get().output)
dependsOn(configurations.runtimeClasspath)
from({
configurations.runtimeClasspath.get().filter { it.name.endsWith("jar") }.map { zipTree(it) }
}) {
exclude("META-INF/*.SF", "META-INF/*.DSA", "META-INF/*.RSA")
}
}
val createScripts by tasks.registering(CreateStartScripts::class) {
mainClass.set("io.flamingock.cli.FlamingockCli")
applicationName = "flamingock"
outputDir = layout.buildDirectory.dir("scripts").get().asFile
classpath = files(uberJar.get().archiveFile)
}
val distImage by tasks.registering(Sync::class) {
group = "distribution"
description = "Creates the distribution image"
dependsOn(uberJar, createScripts)
into(layout.buildDirectory.dir("dist-image"))
from(createScripts) {
into("bin")
fileMode = "755".toInt(8)
}
from(uberJar.get().archiveFile) {
into("lib")
}
from("src/dist") {
into("bin")
}
}
val distZip by tasks.registering(Zip::class) {
group = "distribution"
description = "Builds the ZIP distribution"
dependsOn(distImage)
from(distImage.get().destinationDir) {
into("flamingock-cli")
}
archiveBaseName.set("flamingock-cli")
archiveVersion.set("")
archiveExtension.set("zip")
destinationDirectory.set(layout.buildDirectory.dir("distributions"))
}
val distTar by tasks.registering(Tar::class) {
group = "distribution"
description = "Builds the TAR distribution"
dependsOn(distImage)
from(distImage.get().destinationDir) {
into("flamingock-cli")
}
archiveBaseName.set("flamingock-cli")
archiveVersion.set("")
archiveExtension.set("tar.gz")
compression = Compression.GZIP
destinationDirectory.set(layout.buildDirectory.dir("distributions"))
}
// Test configuration
tasks.test {
useJUnitPlatform()
testLogging {
events("passed", "skipped", "failed")
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
showStandardStreams = false
}
}
// Debug task - run CLI with debugging enabled
val debugCli by tasks.registering(JavaExec::class) {
group = "debug"
description = "Run CLI in debug mode with development logging"
classpath = sourceSets.main.get().runtimeClasspath
mainClass.set("io.flamingock.cli.FlamingockCli")
// Enable debug logging using CLI flags
systemProperty("flamingock.debug", "true")
// JVM debugging
jvmArgs = listOf(
"-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005",
"-XX:+ShowCodeDetailsInExceptionMessages"
)
// Set working directory to distribution directory
workingDir = file("${project.rootDir}/flamingock-cli-dist")
// Default arguments with debug flag (can be overridden)
args = listOf("--debug", "--help")
}
// Quick test task - run CLI without MongoDB dependency
val testCli by tasks.registering(JavaExec::class) {
group = "debug"
description = "Test CLI commands without database connections"
classpath = sourceSets.main.get().runtimeClasspath
mainClass.set("io.flamingock.cli.FlamingockCli")
systemProperty("flamingock.debug", "true")
workingDir = file("${project.rootDir}/flamingock-cli-dist")
args = listOf("--verbose", "--help")
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
// Add uber jar as additional artifact to existing maven publication
afterEvaluate {
publishing {
publications {
named<MavenPublication>("maven") {
// Add the uber jar as additional artifact
artifact(uberJar.get()) {
classifier = "uber"
}
// Override description for CLI module
pom {
name.set("Flamingock CLI")
description.set("Command-line interface for Flamingock audit and issue management operations")
}
}
}
}
}
// Generate checksums for distributions
val generateChecksums by tasks.registering {
group = "distribution"
description = "Generate checksums for distribution files"
dependsOn(distZip, distTar)
doLast {
val distDir = file("${layout.buildDirectory.get()}/distributions")
val checksumFile = file("${distDir}/checksums.txt")
val checksums = mutableListOf<String>()
distDir.listFiles()?.forEach { distFile ->
if (distFile.extension in listOf("gz", "zip")) {
val sha256 = MessageDigest.getInstance("SHA-256")
distFile.inputStream().use { input ->
val buffer = ByteArray(8192)
var bytesRead = input.read(buffer)
while (bytesRead != -1) {
sha256.update(buffer, 0, bytesRead)
bytesRead = input.read(buffer)
}
}
val checksum = sha256.digest().joinToString("") { byte -> "%02x".format(byte) }
checksums.add("${checksum} ${distFile.name}")
}
}
checksumFile.writeText(checksums.joinToString("\n"))
println("Checksums written to: ${checksumFile.absolutePath}")
}
}
// Ensure distributions are built on every build (neccesary?)
tasks.named("assemble").configure {
dependsOn(generateChecksums)
}
// Ensure distributions are built before JReleaser tasks
tasks.matching { it.name.startsWith("jreleaser") }.configureEach {
dependsOn(generateChecksums)
}
// Add task to build all distributions
tasks.register("buildDistributions") {
group = "distribution"
description = "Build all distribution archives"
dependsOn(distZip, distTar, generateChecksums)
}