da-discovery-dev / build.gradle.kts
Ajay Yadav
Initial deployment of da-discovery-dev
442299c
plugins {
java
id("org.springframework.boot") version "3.2.5"
id("io.spring.dependency-management") version "1.1.4"
id("org.liquibase.gradle") version "2.2.0" // Check for latest Liquibase plugin version
id("checkstyle")
jacoco
id("com.google.cloud.tools.jib") version "3.4.0" // Jib plugin for Docker image building
// id("com.diffplug.spotless") version "6.25.0" // Spotless plugin
// Consider adding other plugins like git-commit-id if needed
}
group = "com.dalab.discovery"
version = "0.0.1-SNAPSHOT"
java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
// Define versions from pom.xml properties
val jhipsterDependenciesVersion = "8.1.0"
val hibernateVersion = "6.4.0.Final"
val archunitJunit5Version = "1.2.1"
val springCloudGcpVersion = "6.1.1" // Note: Using spring-cloud-gcp.version from pom
val googleCloudLibrariesBomVersion = "26.60.0"
val googleAuthVersion = "1.23.0"
val googleCloudAssetVersion = "3.41.0"
val awsSdkVersion = "2.25.1" // Assuming AWS SDK v2
val azureIdentityVersion = "1.11.0"
val azureCoreVersion = "1.45.0"
val azureResourcemanagerVersion = "2.31.0"
val azureStorageBlobVersion = "12.25.0"
val azureCosmosVersion = "4.54.0"
val azureMonitorQueryVersion = "1.5.7"
val ociSdkVersion = "3.22.0"
val mapstructVersion = "1.5.5.Final" // Added MapStruct version
repositories {
mavenCentral()
maven { url = uri("https://maven.google.com") }
}
// Add resolution strategy for dependency conflicts
configurations.all {
resolutionStrategy {
// Force Guava version and exclude the outdated google-collections
force("com.google.guava:guava:33.4.0-jre")
exclude(group = "com.google.collections", module = "google-collections")
}
}
dependencyManagement {
imports {
mavenBom("tech.jhipster:jhipster-dependencies:${jhipsterDependenciesVersion}")
mavenBom("com.google.cloud:spring-cloud-gcp-dependencies:${springCloudGcpVersion}")
mavenBom("com.google.cloud:libraries-bom:${googleCloudLibrariesBomVersion}")
mavenBom("org.springframework.shell:spring-shell-dependencies:3.2.0")
// Potentially add AWS SDK BOM if needed: software.amazon.awssdk:bom:${awsSdkVersion}
// Potentially add Azure SDK BOM if needed: com.azure:azure-sdk-bom:...
}
}
dependencies {
implementation("tech.jhipster:jhipster-framework")
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.springframework.boot:spring-boot-starter-cache")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-logging")
implementation("org.springframework.boot:spring-boot-starter-mail")
implementation("org.springframework.boot:spring-boot-starter-oauth2-client")
implementation("org.springframework.boot:spring-boot-starter-oauth2-resource-server")
implementation("org.springframework.boot:spring-boot-starter-thymeleaf")
implementation("org.springframework.boot:spring-boot-starter-undertow")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-mail")
implementation("org.springframework.security:spring-security-data")
implementation("org.springdoc:springdoc-openapi-starter-webmvc-api")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-hibernate6")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-hppc")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
implementation("com.fasterxml.jackson.module:jackson-module-jaxb-annotations")
implementation("com.github.ben-manes.caffeine:caffeine")
implementation("com.mysql:mysql-connector-j")
implementation("com.zaxxer:HikariCP")
implementation("io.dropwizard.metrics:metrics-core")
implementation("io.micrometer:micrometer-registry-prometheus")
implementation("jakarta.annotation:jakarta.annotation-api")
implementation("javax.cache:cache-api")
implementation("org.apache.commons:commons-lang3")
implementation("org.ehcache:ehcache")
implementation("org.hibernate.orm:hibernate-core:${hibernateVersion}")
implementation("org.hibernate.orm:hibernate-jcache:${hibernateVersion}")
implementation("org.hibernate.validator:hibernate-validator")
implementation("org.liquibase:liquibase-core") // Version managed by BOM or plugin
implementation("org.springframework.cloud:spring-cloud-starter")
implementation("org.springframework.cloud:spring-cloud-starter-bootstrap")
implementation("org.springframework.cloud:spring-cloud-starter-circuitbreaker-resilience4j")
implementation("org.springframework.cloud:spring-cloud-starter-config")
implementation("org.springframework.kafka:spring-kafka")
implementation("org.springframework.retry:spring-retry:2.0.5")
implementation("org.springframework.cloud:spring-cloud-starter-netflix-eureka-client")
implementation("org.springframework.data:spring-data-r2dbc:3.3.2")
implementation("org.springframework.cloud:spring-cloud-starter-stream-kafka")
implementation("org.assertj:assertj-core:3.13.2")
implementation("org.fusesource.jansi:jansi:2.4.0")
// Google Cloud Dependencies (Versions from BOMs)
// implementation("com.google.cloud:google-cloud-sql-connector-jdbc") // Replaced with starter below
implementation("com.google.cloud:spring-cloud-gcp-starter-sql-postgresql")
implementation("com.google.cloud:google-cloud-compute")
implementation("com.google.cloud:google-cloud-bigquery")
implementation("com.google.cloud:google-cloud-storage")
implementation("com.google.cloud:google-cloud-resourcemanager")
implementation("com.google.cloud:google-cloud-logging")
implementation("com.google.cloud:google-cloud-storage-control")
// Other Google Cloud Dependencies (Explicit Versions)
implementation("com.google.auth:google-auth-library-oauth2-http")
implementation("com.google.auth:google-auth-library-credentials")
//implementation("com.google.auth:google-auth-library-oauth2-http:${googleAuthVersion}")
implementation("com.google.cloud:google-cloud-asset:${googleCloudAssetVersion}")
//implementation("com.google.auth:google-auth-library-credentials:${googleAuthVersion}")
implementation("com.google.apis:google-api-services-cloudresourcemanager:v3-rev20240310-2.0.0")
implementation("com.google.apis:google-api-services-sqladmin:v1-rev20250310-2.0.0")
// AWS SDK Dependencies (Using specific versions for now)
// Consider using the AWS SDK BOM: implementation(platform("software.amazon.awssdk:bom:${awsSdkVersion}"))
compileOnly("software.amazon.awssdk:aws-sdk-java:${awsSdkVersion}") // compileOnly maps to <optional>true + <scope>compile
implementation("software.amazon.awssdk:ec2:${awsSdkVersion}")
implementation("software.amazon.awssdk:s3:${awsSdkVersion}")
implementation("software.amazon.awssdk:rds:${awsSdkVersion}")
// Azure SDK Dependencies (Using specific versions for now)
// Consider using the Azure SDK BOM: implementation(platform("com.azure:azure-sdk-bom:..."))
implementation("com.azure:azure-identity:${azureIdentityVersion}")
implementation("com.azure:azure-core:${azureCoreVersion}")
implementation("com.azure.resourcemanager:azure-resourcemanager:${azureResourcemanagerVersion}")
implementation("com.azure:azure-storage-blob:${azureStorageBlobVersion}")
implementation("com.azure:azure-cosmos:${azureCosmosVersion}")
implementation("com.azure:azure-monitor-query:${azureMonitorQueryVersion}")
// Oracle Cloud SDK Dependencies
implementation("com.oracle.oci.sdk:oci-java-sdk-common:${ociSdkVersion}")
implementation("com.oracle.oci.sdk:oci-java-sdk-core:${ociSdkVersion}")
implementation("com.oracle.oci.sdk:oci-java-sdk-objectstorage:${ociSdkVersion}")
implementation("com.oracle.oci.sdk:oci-java-sdk-database:${ociSdkVersion}")
implementation("com.oracle.oci.sdk:oci-java-sdk-identity:${ociSdkVersion}")
implementation("com.oracle.oci.sdk:oci-java-sdk-audit:${ociSdkVersion}")
// Annotation Processors & Provided Dependencies
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")
compileOnly("org.hibernate.orm:hibernate-jpamodelgen")
annotationProcessor("org.hibernate.orm:hibernate-jpamodelgen:${hibernateVersion}")
// Test Dependencies
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.springframework.boot:spring-boot-test")
testImplementation("org.springframework.security:spring-security-test")
testImplementation("com.tngtech.archunit:archunit-junit5-api:${archunitJunit5Version}")
testRuntimeOnly("com.tngtech.archunit:archunit-junit5-engine:${archunitJunit5Version}")
testImplementation("org.testcontainers:jdbc")
testImplementation("org.testcontainers:mysql")
testImplementation("com.h2database:h2:2.2.224")
// Spring Data JPA
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
// Database drivers - PostgreSQL as primary
implementation("org.postgresql:postgresql:42.6.0")
// implementation("com.h2database:h2:2.2.224") // Keep H2 for testing - REMOVED due to being in 'implementation'
// Hibernate Types for JSON support - REMOVING THIS as Hibernate 6.4+ has better native support
// implementation("com.vladmihalcea:hibernate-types-60:2.21.1") {
// transitive = true
// }
// Jackson types
implementation("com.fasterxml.jackson.datatype:jackson-datatype-hibernate6")
// Lombok for reducing boilerplate
compileOnly("org.projectlombok:lombok")
annotationProcessor("org.projectlombok:lombok")
implementation("org.springframework.boot:spring-boot-starter-aop") // Required for @Retryable
implementation("org.springframework.shell:spring-shell-starter")
// MapStruct
implementation("org.mapstruct:mapstruct:${mapstructVersion}")
annotationProcessor("org.mapstruct:mapstruct-processor:${mapstructVersion}")
annotationProcessor("org.projectlombok:lombok-mapstruct-binding:0.2.0") // For Lombok and MapStruct integration
// OpenFeign for declarative REST clients
implementation("org.springframework.cloud:spring-cloud-starter-openfeign")
}
// Spring Boot configuration
springBoot {
mainClass.set("com.dalab.discovery.application.DADiscoveryAgent")
}
tasks.withType<Test> {
useJUnitPlatform()
systemProperty("spring.profiles.active", "test")
// Enable ByteBuddy experimental mode for Java 24 compatibility
systemProperty("net.bytebuddy.experimental", "true")
// Enable parallel test execution
maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).takeIf { it > 0 } ?: 1
// Exclude tests that require specific infrastructure or Docker
// exclude {
// // it.name.contains("TechnicalStructureTest") ||
// // it.name.contains("UserResourceIT") ||
// // it.name.contains("PublicUserResourceIT") ||
// // it.name.contains("AWSConfigServiceTest") ||
// // it.name.contains("HibernateTimeZoneIT") ||
// // it.name.contains("CrawlerIntegrationTest")
// }
testLogging {
events("passed", "skipped", "failed")
showExceptions = true
showCauses = true
showStackTraces = true
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
// Enable test output on console
showStandardStreams = true
}
}
// Checkstyle Configuration
checkstyle {
toolVersion = "10.12.5" // Use version from pom
configFile = file("checkstyle.xml") // Assumes checkstyle.xml is in root
// You might need to configure source sets if they differ from default
}
// Configure configurations to exclude google-collections
configurations.checkstyle {
exclude(group = "com.google.collections", module = "google-collections")
}
// Disable checkstyle tasks to avoid build failures
tasks.withType<Checkstyle> {
enabled = false
}
tasks.checkstyleMain {
source("src/main/java")
}
tasks.checkstyleTest {
source("src/test/java")
}
// JaCoCo Configuration
jacoco {
toolVersion = "0.8.11" // Use version from pom
}
tasks.jacocoTestReport {
reports {
xml.required.set(true)
csv.required.set(false)
html.outputLocation.set(layout.buildDirectory.dir("jacocoHtml"))
}
// Depends on test task completion
dependsOn(tasks.test)
}
// Liquibase Configuration (Basic setup, might need more config based on pom)
// liquibase {
// activities {
// main {
// changeLogFile("config/liquibase/master.xml")
// url = "jdbc:mysql://localhost:3306/DADiscovery" // Example, configure appropriately
// username = "root"
// password = ""
// // contexts = "!test" // How contexts are handled differs
// }
// }
// }
// Configure Java Compile to use annotationProcessor configuration
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
options.annotationProcessorPath = configurations.annotationProcessor.get()
// Increase memory for Java compilation
options.forkOptions.jvmArgs = listOf("-Xmx1g")
}
// Task to help VS Code recognize dependencies
tasks.register("createClasspath") {
doLast {
val classpath = configurations.runtimeClasspath.get()
.resolvedConfiguration.resolvedArtifacts
.joinToString("\n") { it.file.absolutePath }
file(".classpath").writeText(classpath)
println("Dependencies written to .classpath file")
println("Spring Shell JAR locations:")
configurations.runtimeClasspath.get().files
.filter { it.name.contains("spring-shell") }
.forEach { println(it.absolutePath) }
}
}
// Add Jib configuration for Docker image building
jib {
from {
image = "openjdk:21-slim"
}
to {
image = "da-discovery"
tags = setOf("latest")
}
container {
creationTime = "USE_CURRENT_TIMESTAMP"
jvmFlags = listOf("-Xmx512m", "-Xms256m")
ports = listOf("8080")
workingDirectory = "/app"
}
}