forked from rhythms06/repseqio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
257 lines (223 loc) · 7.84 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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage
import com.bmuschko.gradle.docker.tasks.image.Dockerfile
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import com.palantir.gradle.gitversion.VersionDetails
import groovy.lang.Closure
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.net.InetAddress
import java.time.Duration
import java.util.*
plugins {
`java-library`
application
kotlin("jvm") version "1.7.10"
`maven-publish`
signing
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
id("com.palantir.git-version") version "0.13.0" // don't upgrade, latest version that runs on Java 8
id("com.github.johnrengelman.shadow") version "7.1.2"
id("com.bmuschko.docker-java-application") version "7.4.0"
}
val versionDetails: Closure<VersionDetails> by extra
val gitDetails = versionDetails()
val longTests: String? by project
group = "io.repseq"
version = if (version != "unspecified") version else ""
description = "RepSeqIO"
java {
sourceCompatibility = JavaVersion.VERSION_1_8
withSourcesJar()
withJavadocJar()
}
val compileKotlin: KotlinCompile by tasks
compileKotlin.kotlinOptions.freeCompilerArgs += "-Xjvm-default=all"
application {
mainClass.set("io.repseq.cli.Main")
}
tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}
repositories {
mavenCentral()
// Snapshot versions of cc.redberry:pipe and com.milaboratory:milib distributed via this repo
maven {
url = uri("https://pub.maven.milaboratory.com")
}
}
val milibVersion = "2.3.0-19-alleles"
val jacksonBomVersion = "2.14.1"
dependencies {
api("com.milaboratory:milib:$milibVersion")
implementation(platform("com.fasterxml.jackson:jackson-bom:$jacksonBomVersion"))
implementation("com.fasterxml.jackson.core:jackson-databind")
implementation("org.reflections:reflections:0.10.2")
implementation("commons-io:commons-io:2.7")
implementation("org.apache.httpcomponents:httpclient:4.5.13")
implementation("ch.qos.logback:logback-classic:1.3.0-alpha14")
implementation("com.beust:jcommander:1.72")
implementation("net.sf.trove4j:trove4j:3.0.3")
testImplementation("junit:junit:4.13.2")
testImplementation(testFixtures("com.milaboratory:milib:$milibVersion"))
testImplementation("org.mockito:mockito-all:1.10.19")
testImplementation("io.kotest:kotest-assertions-core:5.3.0")
}
val writeBuildProperties by tasks.registering(WriteProperties::class) {
outputFile = file("${sourceSets.main.get().output.resourcesDir}/${project.name}-build.properties")
property("version", version)
property("name", "RepSeqIO")
property("revision", gitDetails.gitHash)
property("branch", gitDetails.branchName ?: "")
property("host", InetAddress.getLocalHost().hostName)
property("timestamp", System.currentTimeMillis())
}
tasks.processResources {
dependsOn(writeBuildProperties)
}
val buildLibrary by tasks.registering(JavaExec::class) {
mainClass.set("io.repseq.maven.CompileLibraryGradleStage")
classpath = sourceSets["main"].runtimeClasspath
args(project.rootDir)
}
tasks.classes {
finalizedBy(buildLibrary)
}
val shadowJar = tasks.withType<ShadowJar> {
minimize {
exclude(dependency("org.slf4j:slf4j-api"))
exclude(dependency("ch.qos.logback:logback-core"))
exclude(dependency("ch.qos.logback:logback-classic"))
exclude(dependency("commons-logging:commons-logging"))
exclude(dependency("com.fasterxml.jackson.core:jackson-databind"))
exclude(dependency("log4j:log4j"))
exclude(dependency("com.milaboratory:milib"))
}
}
val distributionZip by tasks.registering(Zip::class) {
group = "distribution"
archiveFileName.set("${project.name}-${project.version}.zip")
destinationDirectory.set(file("$buildDir/distributions"))
from(shadowJar) {
rename("-.*\\.jar", "\\.jar")
}
from("${project.rootDir}/${project.name}")
from("${project.rootDir}/LICENSE")
}
val prepareDockerContext by tasks.registering(Copy::class) {
group = "docker"
from(shadowJar) {
rename("-.*\\.jar", "\\.jar")
}
from("${project.rootDir}/${project.name}")
from("${project.rootDir}/LICENSE")
into(layout.buildDirectory.dir("docker"))
}
val createDockerfile by tasks.registering(Dockerfile::class) {
group = "docker"
dependsOn(prepareDockerContext)
from("eclipse-temurin:17-jre")
label(mapOf("maintainer" to "MiLaboratories Inc <[email protected]>"))
workingDir("/data")
runCommand("mkdir /opt/${project.name}")
environmentVariable("PATH", "/opt/${project.name}:\${PATH}")
copyFile("LICENSE", "/opt/${project.name}/LICENSE")
copyFile(project.name, "/opt/${project.name}/${project.name}")
copyFile("${project.name}.jar", "/opt/${project.name}/${project.name}.jar")
entryPoint(project.name)
}
val buildDockerImage by tasks.registering(DockerBuildImage::class) {
group = "docker"
dependsOn(createDockerfile)
images.set(setOf(project.name) + if (version == "") emptySet() else setOf("${project.name}:${version}"))
}
val miRepoAccessKeyId: String? by project
val miRepoSecretAccessKey: String? by project
publishing {
repositories {
if (miRepoAccessKeyId != null) {
maven {
name = "mipub"
url = uri("s3://milaboratory-artefacts-public-files.s3.eu-central-1.amazonaws.com/maven")
authentication {
credentials(AwsCredentials::class) {
accessKey = miRepoAccessKeyId!!
secretKey = miRepoSecretAccessKey!!
}
}
}
}
}
publications.create<MavenPublication>("mavenJava") {
from(components["java"])
pom {
withXml {
asNode().apply {
appendNode("name", "RepseqIO")
appendNode(
"description",
"Command line helper to manipulate RepSeq.IO formatted V/D/J/C reference data."
)
appendNode("url", "https://milaboratory.com/")
}
}
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
developers {
developer {
id.set("dbolotin")
name.set("Dmitry Bolotin")
email.set("[email protected]")
}
developer {
id.set("PoslavskySV")
name.set("Stanislav Poslavsky")
email.set("[email protected]")
}
}
scm {
url.set("scm:git:https://github.com/repseqio/repseqio")
}
}
}
}
val signingKey: String? by project
if (signingKey != null) {
signing {
useInMemoryPgpKeys(
Base64.getMimeDecoder().decode(signingKey).decodeToString(),
""
)
sign(publishing.publications["mavenJava"])
}
}
tasks.withType<Javadoc> {
options {
this as StandardJavadocDocletOptions
addStringOption("Xdoclint:none", "-quiet")
}
}
nexusPublishing {
clientTimeout.set(Duration.ofMinutes(25))
connectTimeout.set(Duration.ofMinutes(20))
transitionCheckOptions {
maxRetries.set(100)
delayBetween.set(Duration.ofSeconds(20))
}
repositories {
sonatype()
}
}
val checkMiLibNotSnapshot by tasks.registering {
doLast {
if (milibVersion.contains('-'))
throw GradleException("Can't publish to maven central with snapshot dependencies.")
}
}
afterEvaluate {
tasks.named("publishToSonatype") {
dependsOn(checkMiLibNotSnapshot)
}
}