forked from aerospike-community/skyhook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
188 lines (167 loc) · 6.31 KB
/
build.gradle.kts
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
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
java
application
kotlin("jvm") version "1.9.0"
id("com.github.johnrengelman.shadow") version "7.1.2"
id("nebula.ospackage") version "9.1.1"
}
group = "com.aerospike"
repositories {
mavenCentral()
}
application {
mainClass.set("com.aerospike.skyhook.MainKt")
}
tasks.withType<Jar> {
manifest {
attributes(
mapOf(
"Main-Class" to application.mainClass,
"Implementation-Version" to archiveVersion
)
)
}
}
// Common dependency versions.
extra["nettyVersion"] = "4.1.96.Final"
extra["logbackVersion"] = "1.3.11" // latest for JDK 8
extra["jacksonVersion"] = "2.15.2"
extra["junitVersion"] = "5.10.0"
dependencies {
implementation("com.aerospike:aerospike-client:7.1.0")
implementation("io.netty:netty-all:${project.extra["nettyVersion"]}")
implementation("io.netty:netty-codec-redis:${project.extra["nettyVersion"]}")
implementation("com.google.inject:guice:5.1.0")
implementation("io.github.microutils:kotlin-logging:3.0.5")
implementation("ch.qos.logback:logback-classic:${project.extra["logbackVersion"]}")
implementation("ch.qos.logback:logback-core:${project.extra["logbackVersion"]}")
implementation("info.picocli:picocli:4.7.4")
implementation("commons-io:commons-io:2.13.0")
implementation("com.fasterxml.jackson.core:jackson-core:${project.extra["jacksonVersion"]}")
implementation("com.fasterxml.jackson.core:jackson-annotations:${project.extra["jacksonVersion"]}")
implementation("com.fasterxml.jackson.core:jackson-databind:${project.extra["jacksonVersion"]}")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:${project.extra["jacksonVersion"]}")
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${project.extra["jacksonVersion"]}")
implementation("com.google.guava:guava:32.1.2-jre")
testImplementation(kotlin("test-junit5"))
testImplementation("org.junit.jupiter:junit-jupiter-api:${project.extra["junitVersion"]}")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${project.extra["junitVersion"]}")
}
tasks.test {
useJUnitPlatform()
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
val distZip: Zip by tasks
distZip.duplicatesStrategy = DuplicatesStrategy.EXCLUDE
fun setUpPackaging(
packagingTask: com.netflix.gradle.plugins.packaging.SystemPackagingTask,
installFolder: String = "install",
debFolder: String = "deb"
) {
packagingTask.dependsOn("distZip")
// Mark configuration file as configuration file.
val targetConfigFile =
"/etc/${packagingTask.project.name}/${packagingTask.project.name}.yml"
packagingTask.configurationFile(targetConfigFile)
val sourceConfigFile =
File("${projectDir}/pkg/$installFolder/$targetConfigFile")
if (packagingTask is com.netflix.gradle.plugins.rpm.Rpm && sourceConfigFile.isFile) {
packagingTask.from(sourceConfigFile) {
// For rpm this is the way to mark configuration files.
com.netflix.gradle.plugins.packaging.CopySpecEnhancement
.setFileType(
this,
org.redline_rpm.payload.Directive(
org.redline_rpm.payload.Directive.RPMFILE_CONFIG or org.redline_rpm.payload.Directive
.RPMFILE_NOREPLACE
)
)
into(
sourceConfigFile.parentFile.path.replace(
".*pkg/$installFolder".toRegex(), ""
)
)
}
}
// Package config and other dependent files.
val installDir = File(project.projectDir, "pkg/$installFolder")
if (installDir.isDirectory) {
for (file in installDir.listFiles()!!) {
packagingTask.from(file) {
into(
file.path.replace(".*pkg/$installFolder".toRegex(), "")
)
packagingTask.addParentDirs = false
fileMode = 0x755
if (packagingTask is com.netflix.gradle.plugins.rpm.Rpm) {
// We have config it separately above.
exclude("**/" + sourceConfigFile.name)
}
}
}
}
// Copy installation scripts.
val installScriptsDir = File(project.projectDir, "pkg/$debFolder")
if (installScriptsDir.isDirectory) {
packagingTask.postInstall(
packagingTask.project.file(
"${projectDir}/pkg/$debFolder/postInstall.sh"
)
)
packagingTask.preUninstall(
packagingTask.project.file
("${projectDir}/pkg/$debFolder/preUninstall.sh")
)
packagingTask.postUninstall(
packagingTask.project.file(
"${projectDir}/pkg/$debFolder/postUninstall.sh"
)
)
}
// Copy the installer.
packagingTask.from(
project.zipTree(
distZip.archiveFile.get().asFile.absolutePath
)
) {
into("/opt/${packagingTask.project.name}/")
packagingTask.addParentDirs = false
eachFile {
path =
path.replaceFirst(
"/${packagingTask.project.name}-${packagingTask.project.version}/",
"/"
)
}
}
}
/**
* Create the Debian package.
*/
task("deb", com.netflix.gradle.plugins.deb.Deb::class) {
// Currently we cannot specify a dependency on any package providing
// java 8+ (for e.g java 11). Exact dependency on Java 8 is the only
// thing that works. Skip adding a packaging dependency until this
// works reliably.
// requires("java8-runtime").or("java8-sdk")
setUpPackaging(this)
}
/**
* Create the RPM package.
*/
task("rpm", com.netflix.gradle.plugins.rpm.Rpm::class) {
os = org.redline_rpm.header.Os.LINUX
release = "1"
user = "root"
packageGroup = "root"
// Currently we cannot specify a dependency on any package providing
// java 8+ (for e.g java 11). Exact dependency on Java 8 is the only
// thing that works. Skip adding a packaging dependency until this
// works reliably.
// requires("java", "1.8", Flags.GREATER or Flags.EQUAL).or("java",
// "11", Flags.GREATER or Flags.EQUAL)
setUpPackaging(this)
}