-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
executable file
·132 lines (110 loc) · 3.02 KB
/
build.gradle.kts
File metadata and controls
executable file
·132 lines (110 loc) · 3.02 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
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.buildconfig)
alias(libs.plugins.shadow)
alias(libs.plugins.spotless)
}
version = "0.3.0-SNAPSHOT"
val baseName = "string-res-exporter"
buildConfig {
buildConfigField("VERSION_NAME", version.toString())
packageName = "io.github.goooler.exporter"
}
kotlin {
compilerOptions {
jvmTarget = JvmTarget.fromTarget(libs.versions.jdkRelease.get())
freeCompilerArgs.add("-Xjdk-release=${libs.versions.jdkRelease.get()}")
}
}
spotless {
kotlin {
ktlint(libs.ktlint.get().version)
target("**/src/**/*.kt")
}
kotlinGradle {
ktlint(libs.ktlint.get().version)
}
}
val r8 by configurations.registering
dependencies {
implementation(libs.poi)
implementation(libs.jdom2)
implementation(libs.clikt)
r8(libs.r8)
testImplementation(platform(libs.junit.bom))
testImplementation(libs.junit.jupiter)
testImplementation(libs.junit.systemExit)
testImplementation(libs.assertk)
testRuntimeOnly(libs.junit.platform.launcher)
}
tasks.withType<JavaCompile>().configureEach {
options.release = libs.versions.jdkRelease.get().toInt()
}
tasks.jar {
// We don't need the standard jar.
enabled = false
}
tasks.shadowJar {
archiveBaseName = baseName
archiveVersion = version.toString()
duplicatesStrategy = DuplicatesStrategy.INCLUDE
failOnDuplicateEntries = true
mergeServiceFiles()
manifest {
attributes["Main-Class"] = "io.github.goooler.exporter.MainKt"
}
exclude(
"**/*.kotlin_metadata",
"**/*.kotlin_builtins",
"**/*.kotlin_module",
"**/module-info.class",
"assets/**",
"font_metrics.properties",
"META-INF/AL2.0",
"META-INF/DEPENDENCIES",
"META-INF/jdom-info.xml",
"META-INF/LGPL2.1",
"META-INF/maven/**",
"META-INF/native-image/**",
"META-INF/*.version",
"**/*.proto",
"**/*.dex",
"**/LICENSE**",
"**/NOTICE**",
"r8-version.properties",
"migrateToAndroidx/*",
)
}
val r8Jar by tasks.registering(JavaExec::class) {
group = LifecycleBasePlugin.BUILD_GROUP
val rulesFile = file("src/main/rules.pro")
val r8File = file("build/libs/$baseName-$version-r8.jar")
val binaryFile = file("build/libs/$baseName-$version-binary.jar")
inputs.files(tasks.shadowJar, rulesFile)
outputs.file(binaryFile)
classpath(r8)
mainClass = "com.android.tools.r8.R8"
args(
"--release",
"--classfile",
"--output", r8File.path,
"--pg-conf", rulesFile.path,
"--lib", providers.systemProperty("java.home").get(),
tasks.shadowJar.get().archiveFile.get().asFile.path,
)
doLast("binaryJar") {
with(binaryFile) {
writeText($$"#!/bin/sh\n\nexec java $JAVA_OPTS -jar $0 \"$@\"\n\n")
appendBytes(r8File.readBytes())
setExecutable(true, false)
}
}
}
tasks.test {
dependsOn(r8Jar)
systemProperty("CLI_PATH", r8Jar.get().outputs.files.singleFile.path)
// https://github.com/tginsberg/junit5-system-exit/issues/10
systemProperty("java.security.manager", "allow")
useJUnitPlatform()
}