-
Notifications
You must be signed in to change notification settings - Fork 20
/
build.gradle.kts
57 lines (48 loc) · 1.43 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
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
plugins {
id("java")
id("com.github.johnrengelman.shadow") version ("7.1.2")
}
buildscript {
repositories {
mavenCentral()
gradlePluginPortal()
}
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
}
}
dependencies {
implementation(libs.kxml)
implementation(libs.apache.commons.lang)
implementation(libs.apache.commons.io)
}
tasks {
named<ShadowJar>("shadowJar") {
manifest {
attributes["Main-Class"] = "com.codyi.xml2axml.test.Main"
}
isZip64 = true
// Ignores the "-all" classifier shadow uses by default
archiveClassifier.set("")
}
register("executable") {
logger.info("Packaging ${project.name} into an executable binary...")
dependsOn("shadowJar")
doLast {
val jarFile = File(
project.buildDir,
"libs/${project.name}-${project.version}.jar"
)
require(jarFile.exists()) { "shadowJar output file at ${jarFile.canonicalPath} does not exist!" }
val executableFile = File(project.buildDir, "libs/${project.name}")
executableFile.apply {
writeText("#!/usr/bin/env bash\nexec java -jar \$0 \"\$@\"\n")
appendBytes(jarFile.readBytes())
setExecutable(true)
}
}
}
}