-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
184 lines (155 loc) · 4.83 KB
/
build.gradle
File metadata and controls
184 lines (155 loc) · 4.83 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
plugins {
id 'java'
id 'application'
id 'jacoco'
}
group = 'com.fastcache'
version = '1.0.0'
description = 'A high-performance distributed cache system with consistent hashing'
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
repositories {
mavenCentral()
}
dependencies {
// Netty for network communication
implementation 'io.netty:netty-all:4.1.100.Final'
// JSON processing
implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.2'
// Logging
implementation 'org.slf4j:slf4j-api:2.0.9'
implementation 'ch.qos.logback:logback-classic:1.4.11'
// Spring Boot for service discovery API
implementation 'org.springframework.boot:spring-boot-starter-web:3.2.0'
implementation 'org.springframework.boot:spring-boot-starter-actuator:3.2.0'
// Utilities
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'com.google.guava:guava:32.1.2-jre'
// Testing
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.0'
testImplementation 'org.mockito:mockito-core:5.7.0'
testImplementation 'org.mockito:mockito-junit-jupiter:5.7.0'
testImplementation 'org.springframework.boot:spring-boot-starter-test:3.2.0'
}
application {
mainClass = 'com.fastcache.server.FastCacheServer'
}
test {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
}
}
jacoco {
toolVersion = "0.8.10"
}
jacocoTestReport {
reports {
xml.required = true
html.required = true
}
}
test.finalizedBy jacocoTestReport
jar {
manifest {
attributes(
'Main-Class': 'com.fastcache.server.FastCacheServer',
'Implementation-Title': project.name,
'Implementation-Version': project.version,
'Implementation-Vendor': 'FastCache Team'
)
}
// Include all dependencies in the JAR
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
// Create a distribution JAR without dependencies
task distJar(type: Jar) {
archiveClassifier = 'dist'
from sourceSets.main.output
manifest {
attributes(
'Main-Class': 'com.fastcache.server.FastCacheServer',
'Implementation-Title': project.name,
'Implementation-Version': project.version,
'Implementation-Vendor': 'FastCache Team'
)
}
}
// Create a fat JAR with all dependencies
task fatJar(type: Jar) {
archiveClassifier = 'fat'
from sourceSets.main.output
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
manifest {
attributes(
'Main-Class': 'com.fastcache.server.FastCacheServer',
'Implementation-Title': project.name,
'Implementation-Version': project.version,
'Implementation-Vendor': 'FastCache Team'
)
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
// Task to run the server
task runServer(type: JavaExec) {
group = 'application'
description = 'Run the FastCache server'
mainClass = 'com.fastcache.server.FastCacheServer'
classpath = sourceSets.main.runtimeClasspath
standardInput = System.in
// Default arguments
args = ['--host', 'localhost', '--port', '6379']
}
// Task to run the example
task runExample(type: JavaExec) {
group = 'application'
description = 'Run the FastCache example'
mainClass = 'com.fastcache.examples.CacheExample'
classpath = sourceSets.main.runtimeClasspath
}
// Task to run the persistence example
task runPersistenceExample(type: JavaExec) {
group = 'application'
description = 'Run the FastCache persistence example'
mainClass = 'com.fastcache.examples.PersistenceExample'
classpath = sourceSets.main.runtimeClasspath
}
// Task to build and run tests
task buildAndTest {
group = 'verification'
description = 'Build the project and run tests'
dependsOn clean, test, jar
}
// Task to create a complete distribution
task createDistribution(type: Copy) {
group = 'distribution'
description = 'Create a complete distribution package'
dependsOn fatJar
from fatJar
from 'README.md'
from 'LICENSE'
into "dist/${project.name}-${project.version}"
doLast {
copy {
from 'src/main/resources'
into "dist/${project.name}-${project.version}/config"
}
}
}
// Configure all Java compilation tasks
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
options.compilerArgs += ['-Xlint:unchecked', '-Xlint:deprecation']
}
// Configure all test tasks
tasks.withType(Test) {
maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
forkEvery = 100
}