buildscript { repositories { mavenCentral() } } plugins { id 'java' id "org.sonarqube" version "3.4.0.2513" id 'org.springframework.boot' version '3.4.4' id 'io.spring.dependency-management' version '1.1.7' id 'com.bmuschko.docker-remote-api' version '7.4.0' id 'maven-publish' id 'project-report' id 'build-dashboard' id 'com.github.jk1.dependency-license-report' version '1.17' } java { toolchain { languageVersion = JavaLanguageVersion.of(21) // Java 21로 설정 } } javadoc { destinationDir = file("${buildDir}/docs/javadoc") } import com.github.jk1.license.render.* licenseReport { // By default this plugin will collect the union of all licenses from // the immediate pom and the parent poms. If your legal team thinks this // is too liberal, you can restrict collected licenses to only include the // those found in the immediate pom file // Defaults to: true //unionParentPomLicenses = false // Set output directory for the report data. // Defaults to ${project.buildDir}/reports/dependency-license. outputDir = "$projectDir/build/licenses" // Select projects to examine for dependencies. // Defaults to current project and all its subprojects projects = [project] + project.subprojects // Adjust the configurations to fetch dependencies. Default is 'runtimeClasspath' // For Android projects use 'releaseRuntimeClasspath' or 'yourFlavorNameReleaseRuntimeClasspath' // Use 'ALL' to dynamically resolve all configurations: // configurations = ALL configurations = ['runtimeClasspath'] // List the groups ids to exclude from dependency report. Supports regular expressions. // For finer granularity, see: excludes. excludeGroups = ['do.not.want'] // List the ids (in module:name format) to exclude from dependency report. Supports regular expressions. // By default excludes is empty. excludes = ['moduleGroup:moduleName'] // Don't include artifacts of project's own group into the report excludeOwnGroup = true // Don't exclude bom dependencies. // If set to true, then all boms will be excluded from the report excludeBoms = false // Set custom report renderer, implementing ReportRenderer. // Yes, you can write your own to support any format necessary. //renderers = [new XmlReportRenderer('third-party-libs.xml', 'Back-End Libraries')] renderers = [new InventoryHtmlReportRenderer("index.html", "Backend")] // Set importers to import any external dependency information, i.e. from npm. // Custom importer should implement DependencyDataImporter interface. //importers = [new XmlReportImporter('Frontend dependencies', file(frontend_libs.xml))] // This is for the allowed-licenses-file in checkLicense Task // Accepts File, URL or String path to local or remote file allowedLicensesFile = new File("$projectDir/allowed-licenses.json") } import org.apache.tools.ant.taskdefs.condition.Os ext { image = "313devgrp/java-service-tree-framework-ai" set('springCloudVersion', "2024.0.0") //향후 릴리즈와 스냅샷을 구분할 때 하기 코드를 사용할 것. //artifactType = System.getenv("ARTIFACT_TYPE") ? System.getenv("ARTIFACT_TYPE").toUpperCase() : "SNAPSHOT" //repositoryType = "${artifactType}".equalsIgnoreCase("RELEASE") ? "release" : "snapshot" //업로드 타입 정의 ( maven-release, maven-snapshot, ${repositoryType}) repositoryUrl = "http://www.313.co.kr/nexus/repository/ple-releases/" metadataUrl = "${repositoryUrl}313devgrp/Java-Service-Tree-Framework-AI/maven-metadata.xml" //version 정보 majorVersion = 25 minorVersion = 12 //patchVersion = auto generation if (Os.isFamily(Os.FAMILY_WINDOWS)) { println "*** Windows " }else if (Os.isFamily(Os.FAMILY_MAC)) { println "*** Mac " }else { exec { executable "wget" args "-O", "${projectDir}/metadata.xml", "${metadataUrl}" } } def metadataFile = new XmlSlurper().parse(new File("${projectDir}/metadata.xml")) String latest = metadataFile."versioning"."latest" String versionPrefix = latest.split("-")[0] def (latestMajorVersion, latestMinorVersion, latestPatchVersion) = versionPrefix.tokenize(".") if ( majorVersion > latestMajorVersion.toInteger()){ minorVersion = 0 patchVersion = 0 } else if (minorVersion > latestMinorVersion.toInteger()){ patchVersion = 0 } else { patchVersion = latestPatchVersion.toInteger() + 1 } } task printVersion(){ doLast { println bootJar.version } } group = "313devgrp" version = "${majorVersion}.${minorVersion}.${patchVersion}" bootJar { version = project.version } task generatePublishInfo { def targetFile = new File("${projectDir}/spinnaker.properties") targetFile.parentFile.mkdirs() targetFile.withWriter("UTF-8") { w -> w.writeLine "groupId = " + project.group w.writeLine "artifactId = " + project.name w.writeLine "version = " + project.version } } publish { dependsOn generatePublishInfo } def getMavenSettingsCredentials = { String userHome = System.getProperty("user.home") File mavenSettings = new File ( userHome, ".m2/settings.xml") if (Os.isFamily(Os.FAMILY_WINDOWS)||Os.isFamily(Os.FAMILY_MAC)) { if(!mavenSettings.exists()){ mavenSettings = new File("${projectDir}/settings.xml") } }else { if(!mavenSettings.exists()){ mavenSettings = new File ("${projectDir}/settings.xml") } } def xmlSlurper = new XmlSlurper() def output = xmlSlurper.parse(mavenSettings) return output."servers"."server" } def getCredentials = { def entries = getMavenSettingsCredentials() for ( entry in entries ) { if (project.version.endsWith("-SNAPSHOT") && entry."id".text() == "snapshots"){ return [username: entry.username.text(), password: entry.password.text()] }else { return [username: entry.username.text(), password: entry.password.text()] } } } publishing { def mvnCredential = getCredentials() repositories { maven { credentials{ username mvnCredential["username"] password mvnCredential["password"] } url "${repositoryUrl}" allowInsecureProtocol true } } publications { maven(MavenPublication) { groupId = project.group artifactId = project.name version = project.version artifact bootJar } } } configurations { compileOnly { extendsFrom annotationProcessor } } repositories { mavenCentral() maven { url 'http://www.313.co.kr/nexus/repository/ple-releases' allowInsecureProtocol true } } dependencyManagement { imports { mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}" } } dependencies { // Swagger implementation 'org.springdoc:springdoc-openapi-starter-webflux-ui:2.0.2' implementation 'org.springframework.ai:spring-ai-ollama-spring-boot-starter:1.0.0-M6' implementation 'org.springframework.boot:spring-boot-starter-webflux' implementation 'org.springframework.ai:spring-ai:1.0.0-M6' implementation 'org.hibernate.validator:hibernate-validator:8.0.1.Final' implementation 'org.glassfish:jakarta.el:4.0.2' implementation("org.springframework.ai:spring-ai-opensearch-store:1.0.0-M6") implementation 'org.springframework.ai:spring-ai-pdf-document-reader:1.0.0-M6' implementation 'org.springframework.ai:spring-ai-advisors-vector-store:1.0.0-M8' implementation 'org.springframework.ai:spring-ai-tika-document-reader:1.0.0-M6' implementation 'org.springframework.ai:spring-ai-markdown-document-reader:1.0.0-M6' implementation 'org.springframework.cloud:spring-cloud-starter-config' implementation "org.springframework.boot:spring-boot-starter-actuator" // implementation 'dev.langchain4j:langchain4j-spring-boot-starter:1.0.0-beta3' compileOnly 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok' testImplementation('org.springframework.boot:spring-boot-starter-test') { exclude module: 'junit' } testRuntimeOnly 'org.junit.platform:junit-platform-launcher' } tasks.named('test') { useJUnitPlatform() } import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage import com.bmuschko.gradle.docker.tasks.image.DockerPushImage def jarFile = tasks.bootJar.outputs.files.singleFile def imageName = "313.co.kr:5550/${project.findProperty('image') ?: 'default-image'}:${project.version}" println "🔧 Docker Image: ${imageName}" // ← 콘솔에 이미지 이름 확인용 task prepareDockerContext(type: Copy) { dependsOn bootJar from jarFile from 'docker-entrypoint.sh' from "$projectDir/Dockerfile" into "$buildDir/docker" } task buildDockerImage(type: DockerBuildImage) { dependsOn prepareDockerContext inputDir = file("$buildDir/docker") dockerFile = file("$buildDir/docker/Dockerfile") images = [imageName] noCache = true buildArgs = [ 'JAR_FILE' : jarFile.name, 'ENTRY_FILE': 'docker-entrypoint.sh' ] } task pushDockerImage(type: DockerPushImage) { dependsOn buildDockerImage images = [imageName] }