-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
55 lines (41 loc) · 1.12 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
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
base
kotlin("jvm") version "1.3.72"
id("org.jlleitschuh.gradle.ktlint") version "9.1.1"
}
repositories {
mavenCentral()
}
dependencies {
implementation(kotlin("stdlib-jdk8"))
implementation("com.github.ajalt", "clikt", "2.3.0")
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
val fatJar = task("fatJar", type = Jar::class) {
from(configurations.runtimeClasspath.get().map { if (it.isDirectory) it else zipTree(it) })
with(tasks.jar.get() as CopySpec)
archiveClassifier.set("fat")
manifest {
attributes["Main-Class"] = "com.alecstrong.conway.Main"
}
}
val binaryJar = task("binaryJar") {
val binaryDir = File(buildDir, "bin")
val binaryFile = File(binaryDir, "conway")
doLast {
val fatJarFile = fatJar.archiveFile.get().asFile
binaryFile.parentFile.mkdirs()
binaryFile.writeText("#!/bin/sh\n\nexec java -jar \$0 \"\$@\"\n\n")
binaryFile.appendBytes(fatJarFile.readBytes())
binaryFile.setExecutable(true)
}
}
tasks {
"assemble" {
dependsOn(binaryJar)
}
binaryJar.dependsOn(fatJar)
}