-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
158 lines (134 loc) Β· 4.39 KB
/
Copy pathbuild.gradle
File metadata and controls
158 lines (134 loc) Β· 4.39 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
plugins {
id 'java'
id 'org.springframework.boot' version "${springBootVersion}" apply false
id 'io.spring.dependency-management' version "${springDependencyManagementVersion}" apply false
id 'com.diffplug.spotless' version "${spotlessVersion}" apply false
id 'com.google.cloud.tools.jib' version '3.5.3' apply false
}
group = projectGroup
version = "${projectVersion}-SNAPSHOT"
description = 'yogieat'
// Common configuration for all subprojects
subprojects {
// Apply java-library plugin for library modules, java plugin for application modules
if (project.path.startsWith(':apps:api')
|| project.path.startsWith(':apps:admin')
|| project.path.startsWith(':batch:sync')) {
apply plugin: 'java'
} else {
apply plugin: 'java-library'
}
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'com.diffplug.spotless'
group = rootProject.group
version = rootProject.version
java {
toolchain {
languageVersion = JavaLanguageVersion.of(25)
}
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
// Common dependencies for ALL modules
dependencies {
// Lombok for all modules
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
// Testing for all modules
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
// Configuration processor for @ConfigurationProperties
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
}
// Dependency management - Spring Boot BOM
dependencyManagement {
imports {
mavenBom "org.springframework.boot:spring-boot-dependencies:${springBootVersion}"
}
}
// Spotless configuration for all subprojects
spotless {
java {
target("**/*.java")
targetExclude("**/generated/**", "**/build/generated/**")
importOrder()
removeUnusedImports()
trimTrailingWhitespace()
endWithNewline()
}
sql {
target 'src/**/*.sql'
targetExclude 'src/main/resources/db/migration/**/*.sql'
dbeaver()
}
format 'misc', {
target '*.md', '.gitignore', '*.yml', '*.yaml'
trimTrailingWhitespace()
endWithNewline()
}
}
// Default: disable bootJar for all subprojects (enabled only in application modules)
tasks.named('bootJar') {
enabled = false
}
// Enable plain jar for libraries
tasks.named('jar') {
enabled = true
}
tasks.named('test') {
useJUnitPlatform()
}
}
// Git Hook installation at root level
tasks.register('installGitHook', Copy) {
def hooksDir = layout.projectDirectory.dir('.git/hooks')
from layout.projectDirectory.file('scripts/pre-commit')
into hooksDir
doFirst {
hooksDir.asFile.mkdirs()
}
}
// Apply git hook on build
allprojects {
tasks.matching { it.name == 'build' }.configureEach {
dependsOn rootProject.tasks.installGitHook
}
}
def deployableModules = [
':apps:api',
':apps:admin',
':batch:sync'
]
tasks.register('validateJibPushEnv') {
doLast {
def requiredEnvNames = [
'API_IMAGE_FULL_URL',
'ADMIN_IMAGE_FULL_URL',
'BATCH_IMAGE_FULL_URL',
'DOCKERHUB_USERNAME',
'DOCKERHUB_TOKEN'
]
def missingEnvNames = requiredEnvNames.findAll { !System.getenv(it) }
if (!missingEnvNames.isEmpty()) {
throw new GradleException("Missing Jib push environment variables: ${missingEnvNames.join(', ')}")
}
}
}
tasks.register('jibPushAll') {
group = 'container'
description = 'Builds and pushes API, Admin, and Batch images with Jib.'
dependsOn tasks.named('validateJibPushEnv')
dependsOn deployableModules.collect { "${it}:jib" }
}
tasks.register('jibDockerBuildAll') {
group = 'container'
description = 'Builds API, Admin, and Batch images into the local Docker daemon with Jib.'
dependsOn deployableModules.collect { "${it}:jibDockerBuild" }
}